53 ::ll::TypedStorage<8, 32, ::std::string> mKey;
54 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::std::string>> mValue;
55 ::ll::TypedStorage<4, 4, ::DBHelpers::Category> mCategory;
56 ::ll::TypedStorage<1, 1, bool> mIsDelete;
64 ::ll::TypedStorage<8, 8, ::std::atomic<int>*> mRefCounter;
72 ::ll::TypedStorage<8, 112, ::leveldb::Options> options;
73 ::ll::TypedStorage<8, 24, ::leveldb::ReadOptions> read;
74 ::ll::TypedStorage<1, 1, ::leveldb::WriteOptions> write;
82 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::std::string const>> mLatestValue;
83 ::ll::TypedStorage<1, 1, bool> mIsDeleted;
90 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::DBStorageEnvironmentChain>> mEnvChain;
91 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::leveldb::Cache>> mCache;
92 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::leveldb::FilterPolicy const>> mFilterPolicy;
93 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::DBStorage::Options>> mOptions;
94 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::leveldb::DecompressAllocator>> mDecompressAllocator;
95 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::leveldb::DB>> mDb;
96 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::TaskGroup>> mIOTaskGroup;
97 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::TaskGroup>> mCompactionTaskGroup;
98 ::ll::TypedStorage<8, 16, ::Bedrock::Threading::Async<void>> mCompactionTask;
99 ::ll::TypedStorage<8, 16, ::Bedrock::Threading::Async<void>> mWriteTask;
100 ::ll::TypedStorage<8, 40, ::Core::LevelStorageResult> mState;
101 ::ll::TypedStorage<8, 8, ::ContentIdentity const*> mContentIdentity;
102 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mFullPath;
103 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mDbPath;
104 ::ll::TypedStorage<8, 32, ::std::string> mLevelId;
105 ::ll::TypedStorage<8, 80, ::std::mutex> mCompactionMutex;
106 ::ll::TypedStorage<8, 8, ::std::shared_mutex> mWriteCacheMutex;
107 ::ll::TypedStorage<8, 80, ::std::mutex> mCacheFlushMutex;
108 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastCompactionStartTime;
109 ::ll::TypedStorage<8, 8, ::std::chrono::nanoseconds> mCompactionInterval;
110 ::ll::TypedStorage<8, 8, ::std::chrono::nanoseconds> mWriteFlushInterval;
111 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mAllowFlush;
112 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mSavingInProgress;
113 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mSnapshotInProgress;
114 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mShutdownStarted;
115 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mNoMoreWrites;
116 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mShutdownDone;
117 ::ll::TypedStorage<4, 4, ::std::atomic<int>> mOutstandingJobs;
118 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::SaveTransactionManager>> mSaveTransactionManager;
119 ::ll::TypedStorage<8, 64, ::std::function<void()>> mCriticalSyncSaveCallback;
120 ::ll::TypedStorage<8, 64, ::std::function<void(::CompactionStatus)>> mExternallyRegisteredCompactionCallback;
126 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::LevelStorageObserver>>> mObservers;
127 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mDestructorInProgress;
128 ::ll::TypedStorage<1, 1, bool> mForceCorrupt;
129 ::ll::TypedStorage<1, 1, bool const> mStorageEnabled;
130 ::ll::TypedStorage<1, 1, bool const> mJigsawPersistenceToggle;
131 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mDbSubfolder;
132 ::ll::TypedStorage<8, 128, ::LevelStorageWriteBatch> mSingleKeyWrites;
133 ::ll::TypedStorage<8, 24, ::std::vector<::LevelStorageWriteBatch>> mBatchWrites;
134 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::LevelStorageEventing>> mEventing;
135 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::LevelDbEnv>> mLevelDbEnv;
136 ::ll::TypedStorage<8, 8, ::gsl::not_null<::std::unique_ptr<::DBStorageFolderWatcher>>> mFolderTelemetryWatcher;
137 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mNextSizeTelemetryCaptureTime;
138 ::ll::TypedStorage<8, 8, ::std::chrono::nanoseconds const> mSizeTelemetryCaptureInterval;
139 ::ll::TypedStorage<8, 192, ::DBStoragePerformanceTelemetry> mDBStoragePerformanceTelemetry;
149 virtual ~DBStorage() =
default;
151 virtual void addStorageObserver(::std::unique_ptr<::LevelStorageObserver> observer) ;
153 virtual bool loadedSuccessfully() const ;
155 virtual ::Core::LevelStorageResult getState() const ;
158 createChunkStorage(::
std::unique_ptr<::
ChunkSource> generator, ::StorageVersion) ;
160 virtual ::Core::PathBuffer<::
std::
string> const& getFullPath() const ;
163 getCompoundTag(::
std::
string const& key, ::DBHelpers::Category category) ;
165 virtual
bool hasKey(::
std::string_view key, ::DBHelpers::Category category) const ;
167 virtual
bool loadLevelData(::
LevelData& data) ;
169 virtual
void saveLevelData(::
LevelData const& levelData) ;
171 virtual ::Bedrock::Threading::Async<
void>
172 saveData(::
std::
string const& key, ::
std::
string&& data, ::DBHelpers::Category category) ;
176 virtual ::Bedrock::Threading::Async<
void>
177 deleteData(::
std::
string const& key, ::DBHelpers::Category category) ;
179 virtual
bool loadData(::
std::string_view key, ::
std::
string&
buffer, ::DBHelpers::Category category) const
182 virtual
void forEachKeyWithPrefix(
183 ::
std::string_view prefix,
184 ::DBHelpers::Category category,
185 ::
std::function<
void(::
std::string_view, ::
std::string_view)> const& callback
188 virtual ::Core::LevelStorageResult getLevelStorageState() const ;
192 virtual
void startShutdown() ;
194 virtual
bool isShuttingDown() const ;
196 virtual
bool checkShutdownDone() ;
198 virtual
void getStatistics(::
std::
string& outStats, ::
LevelStorage::StatsType statsType) const ;
201 createSnapshot(::
std::
string const& filePrefix,
bool flushWriteCache) ;
203 virtual
void releaseSnapshot() ;
205 virtual ::Bedrock::Threading::Async<
void> compactStorage() ;
207 virtual
void syncAndSuspendStorage() ;
209 virtual
void resumeStorage() ;
211 virtual
void setFlushAllowed(
bool flushAllowed) ;
213 virtual
void flushToPermanentStorage() ;
215 virtual
void freeCaches() ;
217 virtual
void setCompactionCallback(::
std::function<
void(::CompactionStatus)> callback) ;
219 virtual
void setCriticalSyncSaveCallback(::
std::function<
void()> callback) ;
227 MCAPI ::
TaskResult _flushWriteCacheToLevelDB();
229 MCAPI ::
std::
string _getTelemetryMessage(::leveldb::Status const& status) const;
232 _readPendingWrite(::
std::
string const& key, ::DBHelpers::Category category) const;
234 MCAPI
bool tryRepair(::Core::
Path const& path) const;
248 MCFOLD
bool $loadedSuccessfully() const;
250 MCAPI ::Core::LevelStorageResult $getState() const;
253 $createChunkStorage(::
std::unique_ptr<::
ChunkSource> generator, ::StorageVersion);
255 MCAPI ::Core::PathBuffer<::
std::
string> const& $getFullPath() const;
257 MCAPI ::
std::unique_ptr<::
CompoundTag> $getCompoundTag(::
std::
string const& key, ::DBHelpers::Category category);
259 MCAPI
bool $hasKey(::
std::string_view key, ::DBHelpers::Category category) const;
261 MCAPI
bool $loadLevelData(::
LevelData& data);
263 MCAPI
void $saveLevelData(::
LevelData const& levelData);
265 MCAPI ::Bedrock::Threading::Async<
void>
266 $saveData(::
std::
string const& key, ::
std::
string&& data, ::DBHelpers::Category category);
270 MCAPI ::Bedrock::Threading::Async<
void> $deleteData(::
std::
string const& key, ::DBHelpers::Category category);
272 MCAPI
bool $loadData(::
std::string_view key, ::
std::
string&
buffer, ::DBHelpers::Category category) const;
274 MCAPI
void $forEachKeyWithPrefix(
275 ::
std::string_view prefix,
276 ::DBHelpers::Category category,
277 ::
std::function<
void(::
std::string_view, ::
std::string_view)> const& callback
280 MCAPI ::Core::LevelStorageResult $getLevelStorageState() const;
284 MCAPI
void $startShutdown();
286 MCAPI
bool $isShuttingDown() const;
288 MCAPI
bool $checkShutdownDone();
290 MCAPI
void $getStatistics(::
std::
string& outStats, ::
LevelStorage::StatsType statsType) const;
293 $createSnapshot(::
std::
string const& filePrefix,
bool flushWriteCache);
295 MCAPI
void $releaseSnapshot();
297 MCAPI ::Bedrock::Threading::Async<
void> $compactStorage();
299 MCAPI
void $syncAndSuspendStorage();
301 MCAPI
void $resumeStorage();
303 MCAPI
void $setFlushAllowed(
bool flushAllowed);
305 MCAPI
void $flushToPermanentStorage();
307 MCAPI
void $freeCaches();
309 MCAPI
void $setCompactionCallback(::
std::function<
void(::CompactionStatus)> callback);
311 MCAPI
void $setCriticalSyncSaveCallback(::
std::function<
void()> callback);