51 struct CommitOperation {
55 ::ll::TypedStorage<8, 32, ::std::string> mKey;
56 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::std::string>> mValue;
57 ::ll::TypedStorage<4, 4, ::DBHelpers::Category> mCategory;
58 ::ll::TypedStorage<1, 1, bool> mIsDelete;
69 ::std::string
const& key,
70 ::std::shared_ptr<::std::string> value,
72 ::DBHelpers::Category category
82 ::std::string
const& key,
83 ::std::shared_ptr<::std::string> value,
85 ::DBHelpers::Category category
100 ::ll::TypedStorage<8, 8, ::std::atomic<int>*> mRefCounter;
108 ::ll::TypedStorage<8, 112, ::leveldb::Options> options;
109 ::ll::TypedStorage<8, 24, ::leveldb::ReadOptions> read;
110 ::ll::TypedStorage<1, 1, ::leveldb::WriteOptions> write;
118 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::std::string const>> mLatestValue;
119 ::ll::TypedStorage<1, 1, bool> mIsDeleted;
138 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::DBStorageEnvironmentChain>> mEnvChain;
139 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::leveldb::Cache>> mCache;
140 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::leveldb::FilterPolicy const>> mFilterPolicy;
141 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::DBStorage::Options>> mOptions;
142 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::leveldb::DecompressAllocator>> mDecompressAllocator;
143 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::leveldb::DB>> mDb;
144 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::TaskGroup>> mIOTaskGroup;
145 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::TaskGroup>> mCompactionTaskGroup;
146 ::ll::TypedStorage<8, 16, ::Bedrock::Threading::Async<void>> mCompactionTask;
147 ::ll::TypedStorage<8, 16, ::Bedrock::Threading::Async<void>> mWriteTask;
148 ::ll::TypedStorage<8, 40, ::Core::LevelStorageResult> mState;
149 ::ll::TypedStorage<8, 8, ::ContentIdentity const*> mContentIdentity;
150 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mFullPath;
151 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mDbPath;
152 ::ll::TypedStorage<8, 32, ::std::string> mLevelId;
153 ::ll::TypedStorage<8, 80, ::Bedrock::Threading::Mutex> mCompactionMutex;
154 ::ll::TypedStorage<8, 8, ::std::shared_mutex> mWriteCacheMutex;
155 ::ll::TypedStorage<8, 80, ::Bedrock::Threading::Mutex> mCacheFlushMutex;
156 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastCompactionStartTime;
157 ::ll::TypedStorage<8, 8, ::std::chrono::nanoseconds> mCompactionInterval;
158 ::ll::TypedStorage<8, 8, ::std::chrono::nanoseconds> mWriteFlushInterval;
159 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mAllowFlush;
160 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mSavingInProgress;
161 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mSnapshotInProgress;
162 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mShutdownStarted;
163 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mNoMoreWrites;
164 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mShutdownDone;
165 ::ll::TypedStorage<4, 4, ::std::atomic<int>> mOutstandingJobs;
166 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::SaveTransactionManager>> mSaveTransactionManager;
167 ::ll::TypedStorage<8, 64, ::std::function<void()>> mCriticalSyncSaveCallback;
168 ::ll::TypedStorage<8, 64, ::std::function<void(::CompactionStatus)>> mExternallyRegisteredCompactionCallback;
174 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::LevelStorageObserver>>> mObservers;
175 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mDestructorInProgress;
176 ::ll::TypedStorage<1, 1, bool> mForceCorrupt;
177 ::ll::TypedStorage<1, 1, bool const> mStorageEnabled;
178 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mDbSubfolder;
179 ::ll::TypedStorage<8, 128, ::LevelStorageWriteBatch> mSingleKeyWrites;
180 ::ll::TypedStorage<8, 24, ::std::vector<::LevelStorageWriteBatch>> mBatchWrites;
181 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::LevelStorageEventing>> mEventing;
182 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::LevelDbEnv>> mLevelDbEnv;
183 ::ll::TypedStorage<8, 8, ::gsl::not_null<::std::unique_ptr<::DBStorageFolderWatcher>>> mFolderTelemetryWatcher;
184 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mNextSizeTelemetryCaptureTime;
185 ::ll::TypedStorage<8, 8, ::std::chrono::nanoseconds const> mSizeTelemetryCaptureInterval;
186 ::ll::TypedStorage<8, 192, ::DBStoragePerformanceTelemetry> mDBStoragePerformanceTelemetry;
196 virtual ~DBStorage() ;
198 virtual void addStorageObserver(::std::unique_ptr<::LevelStorageObserver> observer) ;
200 virtual bool loadedSuccessfully() const ;
202 virtual ::Core::LevelStorageResult getState() const ;
205 createChunkStorage(::
std::unique_ptr<::
ChunkSource> generator, ::StorageVersion) ;
207 virtual ::Core::PathBuffer<::
std::
string> const& getFullPath() const ;
210 getCompoundTag(::
std::
string const& key, ::DBHelpers::Category category) ;
212 virtual
bool hasKey(::
std::string_view key, ::DBHelpers::Category) const ;
214 virtual
bool loadLevelData(::
LevelData& data) ;
216 virtual
void saveLevelData(::
LevelData const& levelData) ;
218 virtual ::Bedrock::Threading::Async<
void>
219 saveData(::
std::
string const& key, ::
std::
string&& data, ::DBHelpers::Category category) ;
223 virtual ::Bedrock::Threading::Async<
void>
224 deleteData(::
std::
string const& key, ::DBHelpers::Category category) ;
226 virtual
bool loadData(::
std::string_view key, ::
std::
string&
buffer, ::DBHelpers::Category category) const
229 virtual
void forEachKeyWithPrefix(
230 ::
std::string_view prefix,
231 ::DBHelpers::Category category,
232 ::
std::function<
void(::
std::string_view, ::
std::string_view)> const& callback
235 virtual ::Core::LevelStorageResult getLevelStorageState() const ;
239 virtual
void startShutdown() ;
241 virtual
bool isShuttingDown() const ;
243 virtual
bool checkShutdownDone() ;
245 virtual
void getStatistics(::
std::
string& outStats, ::
LevelStorage::StatsType statsType) const ;
248 createSnapshot(::
std::
string const& filePrefix,
bool flushWriteCache) ;
250 virtual
void releaseSnapshot() ;
252 virtual ::Bedrock::Threading::Async<
void> compactStorage() ;
254 virtual
void syncAndSuspendStorage() ;
256 virtual
void resumeStorage() ;
258 virtual
void setFlushAllowed(
bool flushAllowed) ;
260 virtual
void flushToPermanentStorage() ;
262 virtual
void freeCaches() ;
264 virtual
void setCompactionCallback(::
std::function<
void(::CompactionStatus)> callback) ;
266 virtual
void setCriticalSyncSaveCallback(::
std::function<
void()> callback) ;
274 MCAPI ::
TaskResult _flushWriteCacheToLevelDB();
278 MCAPI ::
std::
string _getTelemetryMessage(::leveldb::Status const& status) const;
280 MCAPI
void _handleErrorStatus(::leveldb::Status const& status);
282 MCAPI
bool _isMarkedAsCorrupted() const;
284 MCAPI
void _markAsCorrupted(::
std::string_view message) const;
286 MCAPI
void _mergeIntoDeleteCache(::
std::
string const& key, ::DBHelpers::Category category);
290 MCAPI
void _mergeIntoWriteCache(::
std::
string const& key, ::
std::
string&& data, ::DBHelpers::Category category);
292 MCAPI
void _queueSaveCallback(
bool invokeImmediately);
295 ::
std::string_view prefix,
296 ::DBHelpers::Category category,
297 ::
std::function<
void(::
std::string_view, ::
std::string_view)> const& callback
300 MCAPI ::DBStorage::
PendingWriteResult _readPendingWrite(::
std::
string const& key, ::DBHelpers::Category) const;
302 MCAPI
void _removeCorruptedMark() const;
304 MCAPI
void _scheduleNextAutoCompaction();
306 MCAPI
bool _suspendAndPerformSaveAction(
307 ::brstd::move_only_function<::
TaskResult()> action,
308 ::brstd::move_only_function<
void()> callback
311 MCAPI
void _write(::leveldb::WriteBatch& batch, uint batchSizeInBytes, uint writesInBatch);
314 MCFOLD ::TaskGroup& getTaskGroup();
323 MCAPI
void* $ctor(
::DBStorageConfig config, ::Bedrock::NotNullNonOwnerPtr<::LevelDbEnv> levelDbEnv);
335 MCAPI
void $addStorageObserver(::std::unique_ptr<::LevelStorageObserver> observer);
337 MCFOLD
bool $loadedSuccessfully()
const;
339 MCFOLD ::Core::LevelStorageResult $getState()
const;
341 MCAPI ::std::unique_ptr<::ChunkSource>
342 $createChunkStorage(::std::unique_ptr<::ChunkSource> generator, ::StorageVersion);
344 MCFOLD ::Core::PathBuffer<::std::string>
const& $getFullPath()
const;
346 MCAPI ::std::unique_ptr<::CompoundTag> $getCompoundTag(::std::string
const& key, ::DBHelpers::Category category);
348 MCAPI
bool $hasKey(::std::string_view key, ::DBHelpers::Category)
const;
352 MCAPI
void $saveLevelData(
::LevelData const& levelData);
354 MCAPI ::Bedrock::Threading::Async<void>
355 $saveData(::std::string
const& key, ::std::string&& data, ::DBHelpers::Category category);
359 MCAPI ::Bedrock::Threading::Async<void> $deleteData(::std::string
const& key, ::DBHelpers::Category category);
361 MCAPI
bool $loadData(::std::string_view key, ::std::string&
buffer, ::DBHelpers::Category category)
const;
363 MCAPI
void $forEachKeyWithPrefix(
364 ::std::string_view prefix,
365 ::DBHelpers::Category category,
366 ::std::function<
void(::std::string_view, ::std::string_view)>
const& callback
369 MCFOLD ::Core::LevelStorageResult $getLevelStorageState()
const;
371 MCFOLD ::ContentIdentity
const* $getContentIdentity()
const;
373 MCAPI
void $startShutdown();
375 MCAPI
bool $isShuttingDown()
const;
377 MCAPI
bool $checkShutdownDone();
379 MCAPI
void $getStatistics(::std::string& outStats, ::LevelStorage::StatsType statsType)
const;
381 MCAPI ::std::vector<::SnapshotFilenameAndLength>
382 $createSnapshot(::std::string
const& filePrefix,
bool flushWriteCache);
384 MCAPI
void $releaseSnapshot();
386 MCAPI ::Bedrock::Threading::Async<void> $compactStorage();
388 MCAPI
void $syncAndSuspendStorage();
390 MCAPI
void $resumeStorage();
392 MCAPI
void $setFlushAllowed(
bool flushAllowed);
394 MCAPI
void $flushToPermanentStorage();
396 MCAPI
void $freeCaches();
398 MCAPI
void $setCompactionCallback(::std::function<
void(::CompactionStatus)> callback);
400 MCAPI
void $setCriticalSyncSaveCallback(::std::function<
void()> callback);