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;
78 ::ll::TypedStorage<8, 8, ::std::atomic<int>*> mRefCounter;
98 ::ll::TypedStorage<8, 112, ::leveldb::Options> options;
99 ::ll::TypedStorage<8, 24, ::leveldb::ReadOptions> read;
100 ::ll::TypedStorage<1, 1, ::leveldb::WriteOptions> write;
108 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::std::string const>> mLatestValue;
109 ::ll::TypedStorage<1, 1, bool> mIsDeleted;
128 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::DBStorageEnvironmentChain>> mEnvChain;
129 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::leveldb::Cache>> mCache;
130 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::leveldb::FilterPolicy const>> mFilterPolicy;
131 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::DBStorage::Options>> mOptions;
132 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::leveldb::DecompressAllocator>> mDecompressAllocator;
133 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::leveldb::DB>> mDb;
134 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::TaskGroup>> mIOTaskGroup;
135 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::TaskGroup>> mCompactionTaskGroup;
136 ::ll::TypedStorage<8, 16, ::Bedrock::Threading::Async<void>> mCompactionTask;
137 ::ll::TypedStorage<8, 16, ::Bedrock::Threading::Async<void>> mWriteTask;
138 ::ll::TypedStorage<8, 40, ::Core::LevelStorageResult> mState;
139 ::ll::TypedStorage<8, 8, ::ContentIdentity const*> mContentIdentity;
140 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mFullPath;
141 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mDbPath;
142 ::ll::TypedStorage<8, 32, ::std::string> mLevelId;
143 ::ll::TypedStorage<8, 80, ::Bedrock::Threading::Mutex> mCompactionMutex;
144 ::ll::TypedStorage<8, 8, ::std::shared_mutex> mWriteCacheMutex;
145 ::ll::TypedStorage<8, 80, ::Bedrock::Threading::Mutex> mCacheFlushMutex;
146 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastCompactionStartTime;
147 ::ll::TypedStorage<8, 8, ::std::chrono::nanoseconds> mCompactionInterval;
148 ::ll::TypedStorage<8, 8, ::std::chrono::nanoseconds> mWriteFlushInterval;
149 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mAllowFlush;
150 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mSavingInProgress;
151 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mSnapshotInProgress;
152 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mShutdownStarted;
153 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mNoMoreWrites;
154 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mShutdownDone;
155 ::ll::TypedStorage<4, 4, ::std::atomic<int>> mOutstandingJobs;
156 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::SaveTransactionManager>> mSaveTransactionManager;
157 ::ll::TypedStorage<8, 64, ::std::function<void()>> mCriticalSyncSaveCallback;
158 ::ll::TypedStorage<8, 64, ::std::function<void(::CompactionStatus)>> mExternallyRegisteredCompactionCallback;
164 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::LevelStorageObserver>>> mObservers;
165 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mDestructorInProgress;
166 ::ll::TypedStorage<1, 1, bool> mForceCorrupt;
167 ::ll::TypedStorage<1, 1, bool const> mStorageEnabled;
168 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mDbSubfolder;
169 ::ll::TypedStorage<8, 128, ::LevelStorageWriteBatch> mSingleKeyWrites;
170 ::ll::TypedStorage<8, 24, ::std::vector<::LevelStorageWriteBatch>> mBatchWrites;
171 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::LevelStorageEventing>> mEventing;
172 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::LevelDbEnv>> mLevelDbEnv;
173 ::ll::TypedStorage<8, 8, ::gsl::not_null<::std::unique_ptr<::DBStorageFolderWatcher>>> mFolderTelemetryWatcher;
174 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mNextSizeTelemetryCaptureTime;
175 ::ll::TypedStorage<8, 8, ::std::chrono::nanoseconds const> mSizeTelemetryCaptureInterval;
176 ::ll::TypedStorage<8, 192, ::DBStoragePerformanceTelemetry> mDBStoragePerformanceTelemetry;
186 virtual ~DBStorage() ;
188 virtual void addStorageObserver(::std::unique_ptr<::LevelStorageObserver> observer) ;
190 virtual bool loadedSuccessfully() const ;
192 virtual ::Core::LevelStorageResult getState() const ;
195 createChunkStorage(::
std::unique_ptr<::
ChunkSource> generator, ::StorageVersion) ;
197 virtual ::Core::PathBuffer<::
std::
string> const& getFullPath() const ;
200 getCompoundTag(::
std::
string const& key, ::DBHelpers::Category category) ;
202 virtual
bool hasKey(::
std::string_view key, ::DBHelpers::Category category) const ;
204 virtual
bool loadLevelData(::
LevelData& data) ;
206 virtual
void saveLevelData(::
LevelData const& levelData) ;
208 virtual ::Bedrock::Threading::Async<
void>
209 saveData(::
std::
string const& key, ::
std::
string&& data, ::DBHelpers::Category category) ;
213 virtual ::Bedrock::Threading::Async<
void>
214 deleteData(::
std::
string const& key, ::DBHelpers::Category category) ;
216 virtual
bool loadData(::
std::string_view key, ::
std::
string&
buffer, ::DBHelpers::Category category) const
219 virtual
void forEachKeyWithPrefix(
220 ::
std::string_view prefix,
221 ::DBHelpers::Category category,
222 ::
std::function<
void(::
std::string_view, ::
std::string_view)> const& callback
225 virtual ::Core::LevelStorageResult getLevelStorageState() const ;
229 virtual
void startShutdown() ;
231 virtual
bool isShuttingDown() const ;
233 virtual
bool checkShutdownDone() ;
235 virtual
void getStatistics(::
std::
string& outStats, ::
LevelStorage::StatsType statsType) const ;
238 createSnapshot(::
std::
string const& filePrefix,
bool flushWriteCache) ;
240 virtual
void releaseSnapshot() ;
242 virtual ::Bedrock::Threading::Async<
void> compactStorage() ;
244 virtual
void syncAndSuspendStorage() ;
246 virtual
void resumeStorage() ;
248 virtual
void setFlushAllowed(
bool flushAllowed) ;
250 virtual
void flushToPermanentStorage() ;
252 virtual
void freeCaches() ;
254 virtual
void setCompactionCallback(::
std::function<
void(::CompactionStatus)> callback) ;
256 virtual
void setCriticalSyncSaveCallback(::
std::function<
void()> callback) ;
264 MCAPI ::
TaskResult _flushWriteCacheToLevelDB();
268 MCAPI ::
std::
string _getTelemetryMessage(::leveldb::Status const& status) const;
270 MCAPI
void _handleErrorStatus(::leveldb::Status const& status);
272 MCAPI
void _markAsCorrupted(::
std::string_view message) const;
276 MCAPI
void _mergeIntoWriteCache(::
std::
string const& key, ::
std::
string&& data, ::DBHelpers::Category category);
278 MCAPI
void _queueSaveCallback(
bool invokeImmediately);
281 ::
std::string_view prefix,
282 ::DBHelpers::Category category,
283 ::
std::function<
void(::
std::string_view, ::
std::string_view)> const& callback
287 _readPendingWrite(::
std::
string const& key, ::DBHelpers::Category category) const;
289 MCAPI
void _removeCorruptedMark() const;
291 MCAPI
void _scheduleNextAutoCompaction();
293 MCAPI
bool _suspendAndPerformSaveAction(
294 ::brstd::move_only_function<::
TaskResult()> action,
295 ::brstd::move_only_function<
void()> callback
298 MCAPI
bool tryRepair(::Core::
Path const& path) const;
318 MCFOLD
bool $loadedSuccessfully() const;
320 MCFOLD ::Core::LevelStorageResult $getState() const;
323 MCAPI ::std::unique_ptr<::ChunkSource>
324 $createChunkStorage(::std::unique_ptr<::ChunkSource> generator, ::StorageVersion);
327 MCAPI ::Core::PathBuffer<::std::string>
const& $getFullPath()
const;
329 MCAPI ::std::unique_ptr<::CompoundTag> $getCompoundTag(::std::string
const& key, ::DBHelpers::Category category);
331 MCAPI
bool $hasKey(::std::string_view key, ::DBHelpers::Category category)
const;
335 MCAPI
void $saveLevelData(
::LevelData const& levelData);
337 MCAPI ::Bedrock::Threading::Async<void>
338 $saveData(::std::string
const& key, ::std::string&& data, ::DBHelpers::Category category);
342 MCAPI ::Bedrock::Threading::Async<void> $deleteData(::std::string
const& key, ::DBHelpers::Category category);
344 MCAPI
bool $loadData(::std::string_view key, ::std::string&
buffer, ::DBHelpers::Category category)
const;
346 MCAPI
void $forEachKeyWithPrefix(
347 ::std::string_view prefix,
348 ::DBHelpers::Category category,
349 ::std::function<
void(::std::string_view, ::std::string_view)>
const& callback
352 MCFOLD ::Core::LevelStorageResult $getLevelStorageState()
const;
354 MCFOLD ::ContentIdentity
const* $getContentIdentity()
const;
356 MCAPI
void $startShutdown();
358 MCAPI
bool $isShuttingDown()
const;
360 MCAPI
bool $checkShutdownDone();
362 MCAPI
void $getStatistics(::std::string& outStats, ::LevelStorage::StatsType statsType)
const;
364 MCAPI ::std::vector<::SnapshotFilenameAndLength>
365 $createSnapshot(::std::string
const& filePrefix,
bool flushWriteCache);
367 MCAPI
void $releaseSnapshot();
369 MCAPI ::Bedrock::Threading::Async<void> $compactStorage();
371 MCAPI
void $syncAndSuspendStorage();
373 MCAPI
void $resumeStorage();
375 MCAPI
void $setFlushAllowed(
bool flushAllowed);
377 MCAPI
void $flushToPermanentStorage();
379 MCAPI
void $freeCaches();
381 MCAPI
void $setCompactionCallback(::std::function<
void(::CompactionStatus)> callback);
383 MCAPI
void $setCriticalSyncSaveCallback(::std::function<
void()> callback);