LeviLamina
Loading...
Searching...
No Matches
DBStorage.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/common/CompactionStatus.h"
7#include "mc/deps/core/file/PathBuffer.h"
8#include "mc/deps/core/threading/IAsyncResult.h"
9#include "mc/deps/core/utility/NonOwnerPointer.h"
10#include "mc/platform/brstd/move_only_function.h"
11#include "mc/world/level/storage/LevelStorage.h"
12#include "mc/world/level/storage/StorageVersion.h"
13#include "mc/world/level/storage/db_helpers/Category.h"
14
15// auto generated forward declare list
16// clang-format off
17class ChunkSource;
18class CompoundTag;
19class LevelData;
20class LevelDbEnv;
23class TaskResult;
24struct DBStorageConfig;
26namespace Core { class Path; }
27namespace Core { struct LevelStorageResult; }
28// clang-format on
29
30class DBStorage : public ::LevelStorage {
31public:
32 // DBStorage inner types declare
33 // clang-format off
34 struct CommitOperation;
35 class DBStorageToken;
36 class Options;
37 struct PendingWriteResult;
38 // clang-format on
39
40 // DBStorage inner types define
41 class Options {
42 public:
43 // member variables
44 // NOLINTBEGIN
48 // NOLINTEND
49
50 public:
51 // prevent constructor by default
52 Options& operator=(Options const&);
53 Options(Options const&);
54 Options();
55 };
56
58 public:
59 // member variables
60 // NOLINTBEGIN
63 // NOLINTEND
64
65 public:
66 // prevent constructor by default
67 PendingWriteResult& operator=(PendingWriteResult const&);
70
71 public:
72 // member functions
73 // NOLINTBEGIN
74 MCAPI ~PendingWriteResult();
75 // NOLINTEND
76
77 public:
78 // destructor thunk
79 // NOLINTBEGIN
80 MCFOLD void $dtor();
81 // NOLINTEND
82 };
83
85 public:
86 // member variables
87 // NOLINTBEGIN
89 // NOLINTEND
90
91 public:
92 // prevent constructor by default
93 DBStorageToken& operator=(DBStorageToken const&);
96
97 public:
98 // member functions
99 // NOLINTBEGIN
100 MCAPI ~DBStorageToken();
101 // NOLINTEND
102
103 public:
104 // destructor thunk
105 // NOLINTBEGIN
106 MCAPI void $dtor();
107 // NOLINTEND
108 };
109
111 public:
112 // member variables
113 // NOLINTBEGIN
118 // NOLINTEND
119
120 public:
121 // prevent constructor by default
122 CommitOperation& operator=(CommitOperation const&);
125
126 public:
127 // member functions
128 // NOLINTBEGIN
129 MCAPI ~CommitOperation();
130 // NOLINTEND
131
132 public:
133 // destructor thunk
134 // NOLINTBEGIN
135 MCFOLD void $dtor();
136 // NOLINTEND
137 };
138
139public:
140 // member variables
141 // NOLINTBEGIN
188 // NOLINTEND
189
190public:
191 // prevent constructor by default
192 DBStorage& operator=(DBStorage const&);
193 DBStorage(DBStorage const&);
194 DBStorage();
195
196public:
197 // virtual functions
198 // NOLINTBEGIN
199 // vIndex: 0
200 virtual ~DBStorage() /*override*/;
201
202 // vIndex: 1
203 virtual void addStorageObserver(::std::unique_ptr<::LevelStorageObserver> observer) /*override*/;
204
205 // vIndex: 2
206 virtual bool loadedSuccessfully() const /*override*/;
207
208 // vIndex: 20
209 virtual ::Core::LevelStorageResult getState() const /*override*/;
210
211 // vIndex: 7
212 virtual ::std::unique_ptr<::ChunkSource>
213 createChunkStorage(::std::unique_ptr<::ChunkSource>, ::StorageVersion) /*override*/;
214
215 // vIndex: 9
216 virtual ::Core::PathBuffer<::std::string> const& getFullPath() const /*override*/;
217
218 // vIndex: 3
219 virtual ::std::unique_ptr<::CompoundTag>
220 getCompoundTag(::std::string const& key, ::DBHelpers::Category category) /*override*/;
221
222 // vIndex: 4
223 virtual bool hasKey(::std::string_view key, ::DBHelpers::Category category) const /*override*/;
224
225 // vIndex: 6
226 virtual bool loadLevelData(::LevelData& data) /*override*/;
227
228 // vIndex: 8
229 virtual void saveLevelData(::LevelData const& levelData) /*override*/;
230
231 // vIndex: 11
232 virtual ::std::shared_ptr<::Bedrock::Threading::IAsyncResult<void>>
233 saveData(::std::string const& key, ::std::string&& data, ::DBHelpers::Category category) /*override*/;
234
235 // vIndex: 10
236 virtual ::std::shared_ptr<::Bedrock::Threading::IAsyncResult<void>> saveData(::LevelStorageWriteBatch const& batch
237 ) /*override*/;
238
239 // vIndex: 12
240 virtual ::std::shared_ptr<::Bedrock::Threading::IAsyncResult<void>>
241 deleteData(::std::string const& key, ::DBHelpers::Category category) /*override*/;
242
243 // vIndex: 19
244 virtual bool loadData(::std::string_view key, ::std::string& buffer, ::DBHelpers::Category category) const
245 /*override*/;
246
247 // vIndex: 5
248 virtual void forEachKeyWithPrefix(
249 ::std::string_view prefix,
250 ::DBHelpers::Category category,
251 ::std::function<void(::std::string_view, ::std::string_view)> const& callback
252 ) const /*override*/;
253
254 // vIndex: 15
255 virtual ::Core::LevelStorageResult getLevelStorageState() const /*override*/;
256
257 // vIndex: 16
258 virtual void startShutdown() /*override*/;
259
260 // vIndex: 17
261 virtual bool isShuttingDown() const /*override*/;
262
263 // vIndex: 18
264 virtual bool checkShutdownDone() /*override*/;
265
266 // vIndex: 13
267 virtual void getStatistics(::std::string& outStats, ::LevelStorage::StatsType statsType) const /*override*/;
268
269 // vIndex: 21
270 virtual ::std::vector<::SnapshotFilenameAndLength>
271 createSnapshot(::std::string const& filePrefix, bool flushWriteCache) /*override*/;
272
273 // vIndex: 22
274 virtual void releaseSnapshot() /*override*/;
275
276 // vIndex: 23
277 virtual ::std::shared_ptr<::Bedrock::Threading::IAsyncResult<void>> compactStorage() /*override*/;
278
279 // vIndex: 24
280 virtual void syncAndSuspendStorage() /*override*/;
281
282 // vIndex: 25
283 virtual void resumeStorage() /*override*/;
284
285 // vIndex: 26
286 virtual void setFlushAllowed(bool flushAllowed) /*override*/;
287
288 // vIndex: 27
289 virtual void flushToPermanentStorage() /*override*/;
290
291 // vIndex: 28
292 virtual void freeCaches() /*override*/;
293
294 // vIndex: 29
295 virtual void setCompactionCallback(::std::function<void(::CompactionStatus)> callback) /*override*/;
296
297 // vIndex: 30
298 virtual void setCriticalSyncSaveCallback(::std::function<void()> callback) /*override*/;
299 // NOLINTEND
300
301public:
302 // member functions
303 // NOLINTBEGIN
304 MCAPI DBStorage(::DBStorageConfig config, ::Bedrock::NotNullNonOwnerPtr<::LevelDbEnv> levelDbEnv);
305
306 MCAPI ::TaskResult _flushWriteCacheToLevelDB();
307
308 MCAPI ::std::map<::std::string, ::DBStorage::PendingWriteResult> _getAllPendingWrites() const;
309
310 MCAPI ::std::string _getTelemetryMessage(::leveldb::Status const& status) const;
311
312 MCAPI void _handleErrorStatus(::leveldb::Status const& status);
313
314 MCAPI void _markAsCorrupted(::std::string_view message) const;
315
316 MCAPI void _mergeIntoWriteCache(::LevelStorageWriteBatch const& batchToMerge);
317
318 MCAPI void _mergeIntoWriteCache(::std::string const& key, ::std::string&& data, ::DBHelpers::Category category);
319
320 MCAPI void _queueSaveCallback(bool invokeImmediately);
321
322 MCAPI void _read(
323 ::std::string_view prefix,
324 ::DBHelpers::Category category,
325 ::std::function<void(::std::string_view, ::std::string_view)> const& callback
326 ) const;
327
329 _readPendingWrite(::std::string const& key, ::DBHelpers::Category category) const;
330
331 MCAPI void _scheduleNextAutoCompaction();
332
333 MCAPI bool
334 _suspendAndPerformSaveAction(::brstd::move_only_function<::TaskResult()> action, ::std::function<void()> callback);
335
336 MCAPI bool tryRepair(::Core::Path const& path) const;
337 // NOLINTEND
338
339public:
340 // constructor thunks
341 // NOLINTBEGIN
342 MCAPI void* $ctor(::DBStorageConfig config, ::Bedrock::NotNullNonOwnerPtr<::LevelDbEnv> levelDbEnv);
343 // NOLINTEND
344
345public:
346 // destructor thunk
347 // NOLINTBEGIN
348 MCAPI void $dtor();
349 // NOLINTEND
350
351public:
352 // virtual function thunks
353 // NOLINTBEGIN
354 MCAPI void $addStorageObserver(::std::unique_ptr<::LevelStorageObserver> observer);
355
356 MCAPI bool $loadedSuccessfully() const;
357
358 MCFOLD ::Core::LevelStorageResult $getState() const;
359
360 MCAPI ::Core::PathBuffer<::std::string> const& $getFullPath() const;
361
362 MCAPI ::std::unique_ptr<::CompoundTag> $getCompoundTag(::std::string const& key, ::DBHelpers::Category category);
363
364 MCAPI bool $hasKey(::std::string_view key, ::DBHelpers::Category category) const;
365
366 MCAPI bool $loadLevelData(::LevelData& data);
367
368 MCAPI void $saveLevelData(::LevelData const& levelData);
369
370 MCAPI ::std::shared_ptr<::Bedrock::Threading::IAsyncResult<void>>
371 $saveData(::std::string const& key, ::std::string&& data, ::DBHelpers::Category category);
372
373 MCAPI ::std::shared_ptr<::Bedrock::Threading::IAsyncResult<void>> $saveData(::LevelStorageWriteBatch const& batch);
374
375 MCAPI ::std::shared_ptr<::Bedrock::Threading::IAsyncResult<void>>
376 $deleteData(::std::string const& key, ::DBHelpers::Category category);
377
378 MCAPI bool $loadData(::std::string_view key, ::std::string& buffer, ::DBHelpers::Category category) const;
379
380 MCAPI void $forEachKeyWithPrefix(
381 ::std::string_view prefix,
382 ::DBHelpers::Category category,
383 ::std::function<void(::std::string_view, ::std::string_view)> const& callback
384 ) const;
385
386 MCFOLD ::Core::LevelStorageResult $getLevelStorageState() const;
387
388 MCAPI void $startShutdown();
389
390 MCAPI bool $isShuttingDown() const;
391
392 MCAPI bool $checkShutdownDone();
393
394 MCAPI void $getStatistics(::std::string& outStats, ::LevelStorage::StatsType statsType) const;
395
396 MCAPI ::std::vector<::SnapshotFilenameAndLength>
397 $createSnapshot(::std::string const& filePrefix, bool flushWriteCache);
398
399 MCAPI void $releaseSnapshot();
400
401 MCAPI ::std::shared_ptr<::Bedrock::Threading::IAsyncResult<void>> $compactStorage();
402
403 MCAPI void $syncAndSuspendStorage();
404
405 MCAPI void $resumeStorage();
406
407 MCAPI void $setFlushAllowed(bool flushAllowed);
408
409 MCAPI void $flushToPermanentStorage();
410
411 MCAPI void $freeCaches();
412
413 MCAPI void $setCompactionCallback(::std::function<void(::CompactionStatus)> callback);
414
415 MCAPI void $setCriticalSyncSaveCallback(::std::function<void()> callback);
416 // NOLINTEND
417
418public:
419 // vftables
420 // NOLINTBEGIN
421 MCAPI static void** $vftable();
422 // NOLINTEND
423};
Definition ChunkSource.h:34
Definition CompoundTag.h:13
Definition DBStorage.h:84
Definition DBStorage.h:41
Definition DBStorage.h:30
Definition LevelData.h:48
Definition LevelDbEnv.h:8
Definition LevelStorageObserver.h:5
Definition LevelStorageWriteBatch.h:14
Definition LevelStorage.h:24
Definition Path.h:16
Definition TaskResult.h:8
STL namespace.
Definition DBStorageConfig.h:5
Definition DBStorage.h:110
Definition DBStorage.h:57
Definition SnapshotFilenameAndLength.h:5
Definition buffer.h:5
Definition Alias.h:14