BPTreeV1 class abstract
Represents a B+-tree node with sorted, arbitrary length key-value pairs, key compression and offset index.
The structure starts with the following:
Node identification (always present):
uint8[3]
:`0xab`, `0xf4`, `0x70`
- first 3 bytes of the md5 hash ofbptree/v1
.uint8
byte - internal version and endian-nessbits 0-6
- the minimum internal version required to parse the bytesbit 7
: the endian-ness of the multi-byte encodings (0
: little-endian,1
: big-endian).
Node options (always present):
uint8
bytebit 0
: whether custom data is presentbit 1
: whether entries are sortedbit 2
: whether key compression is presentbit 3
: whether offset index is presentbits 4-7
: reserved for future use.
varint
for the number of entries
Custom data (when flag is set):
varint
for bytes lengthuint8[]
containing the custom data
Key compression (when flag is set):
varint
for prefix bytes lengthuint8[]
containing the prefix bytesvarint
for postfix bytes lengthuint8[]
containing the postfix bytes
NOTE: The keys inside this node will be stored without the given prefix or postfix.
Offset index (when flag is set):
uint8
bytebit 0-1
: size code0
:uint8
1-byte index1
:uint16
2-bytes index2
:uint32
4-bytes index3
:uint64
8-bytes index
bit 2
: whether there is an item count for this index (or it will use a previously defined count if there is any)bit 3
: whether start offset is padded to offset dividible by 8.bits 4-7
: reserved for future use (sparse index specification)
- (optional)
varint
- the number of entries in the position index (if the flag above is set) - (optional)
uint8[]
padding0x00
(zero) bytes so that index starts at offset divisible by 8 uint8[]
position index bytes
Key-value entries (always present):
uint8
: key and value length specificationbits 0-2
: the length encoding of keys:0
: length is prefixed with a 1-byteuint8
1
: length is prefixed with a 2-bytesuint16
2
: length is prefixed with a 4-bytesuint32
3
: length is prefixed with a 8-bytesuint64
4
: length is prefixed with avarint
value5
-6
: reserved for future use7
: length is const, specified with a follow-upvarint
value
bits 3-5
: the length encoding of values (see values for keys).bit 6
: whether start offset is padded to offset dividible by 8.bit 7
: reserved for future use
- (optional)
varint
for const key length (if key encoding code is7
) - (optional)
varint
for const value length (if value encoding code is7
) varint
total bytes length of the entries- (optional) padding
0x00
(zero) bytes so that the entries start at an offset dividible by 8. - entries encoded as
- key length prefix (or absent for const key length) depending on the key length encoding
- key bytes
- value length prefix (or absent for const value length) depending on the value length encoding
- value bytes
NOTE: there is no end marker for key-value entries, the last entry ends at the last byte.
- Implemented types
Constructors
- BPTreeV1()
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getValue(
List< int> key) → Uint8List? -
Returns the corresponding value of
key
.inherited -
listKeys(
) → Iterable< Uint8List> -
List keys that are part of the data structure.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited