ObjectStoreEngine class final
Object-store backed engine (S3-style): segments and the manifest are objects, and every write batch appends one small WAL object.
Request shape per operation, which is what an S3 bill is based on:
| operation | requests |
|---|---|
| put/delete batch | 1 PUT (WAL) |
| flush | 1 PUT segment + 1 PUT manifest + 1 batch DELETE of WAL objects |
| open | 1 GET manifest + 1 LIST WAL + K GET WAL |
| first read of a segment | 1 GET, then served from the LRU cache |
| compact | S GET segments + 1 PUT segment + 1 PUT manifest + 1 batch DELETE |
Segments are fetched lazily and cached in memory (segmentCacheSize); the manifest is the only object read at open, so startup does not scale with database size.
Constructors
- ObjectStoreEngine({required ObjectStore store, String prefix = 'db/', int blockTargetSize = 64 * 1024, int arenaChunkSize = 1 << 20, int segmentCacheSize = 4})
-
Creates an engine over
storeunderprefix.
Properties
- blockTargetSize → int
-
Target block size inside a segment.
final
- cachedSegments → int
-
Segments currently cached in memory.
no setter
- generation → int
-
Manifest generation.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- memoryBytes → int
-
Bytes buffered in the memtable (payload plus keys).
no setter
- prefix → String
-
Key prefix for this database.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- segmentCacheSize → int
-
How many fetched segments stay in memory (LRU).
final
-
segments
→ List<
SegmentInfo> -
Segments known from the manifest, oldest first.
no setter
- store → ObjectStore
-
Backing object store.
final
Methods
-
applyBatch(
List< WalOp> ops) → Future<void> - Applies puts and deletes as one WAL object.
-
close(
{bool flush = true}) → Future< void> - Flushes pending writes.
-
compact(
) → Future< bool> - Merges every segment into one, dropping tombstones.
-
delete(
Uint8List key) → Future< void> -
Deletes
key. -
deleteMany(
List< Uint8List> keys) → Future<void> - Deletes several keys with one WAL object.
-
flush(
) → Future< SegmentInfo?> - Flushes the memtable into a segment object and commits the manifest.
-
get(
Uint8List key) → Future< Bytes?> -
Reads
key, ornull. Fetches a segment object on a cache miss. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
open(
) → Future< void> - Loads the manifest metadata and replays pending WAL objects.
-
put(
Uint8List key, Bytes document) → Future< void> - Inserts or replaces one key.
-
putMany(
List< ({Bytes document, Uint8List key})> entries) → Future<void> - Appends one WAL object containing every put.
-
scanRange(
{Uint8List? start, Uint8List? end, bool includeStart = true, bool includeEnd = false, int? limit}) → Future< List< ({Bytes? document, Uint8List key})> > - Returns entries in ascending key order inside the requested range.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- manifestKey → const String
- segmentPrefix → const String
- segmentSuffix → const String
- walPrefix → const String