-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyspec.txt
62 lines (48 loc) · 2.75 KB
/
keyspec.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Key spec.
The following grammar specifies the keys used for storing each DAG and
related keys in a B-tree.
Basic Types
The following basic types are used as terminals in the rest of the grammar. Each
type must be serialized in little-endian format.
"" empty string
byte 1 byte (8-bits)
Non-terminals
The following specifies the rest of the key grammar. Note that quoted strings
represent terminals, and should be interpreted with C semantics (e.g. "\x01"
represents the byte 0000 0001). Also note that we use the * operator as
shorthand for repetition (e.g. ("\x01"*2) is "\x01\x01"). When used as a unary
operator, * means that the repetition can occur 0 or more times.
key ::= name subkey "" any key is a name followed by a subkey
name ::= sstring name of the key space
subkey ::=
| "\x01" id ival dskey, data store key
| "\x02" ival ikey, i index key
| "\x03" id version headkey, head index key
| "\x04" version vkey, version index key
| "\x05" sstring uskey, user store key
ival ::= lbeint i value, monotonically increasing number
id ::= string used to identify data store values
version ::= lbeint version number
lbeint ::= byte (byte*) Large int - byte is the number of bytes in
(byte*) (max 254). (byte*) should be
interpreted as an unsigned integer in big
endian format.
sstring ::= byte (byte*) "\x00" Size string - byte is the number of bytes in
(byte*) (max 254). (byte*) is zero or more
ASCII encoded characters excluding '\x00'.
The string is ended with a trailing '\x00'
byte.
string ::= (byte*) "\x00" String - (byte*) is zero or more ASCII
encoded characters excluding '\x00'. The
string is ended with a trailing '\x00' byte.
opts ::= byte option bits, single byte:
0x01 = conflict, when a merge with this
item failed
0x02 = delete, if the head is deleted
The values for the given keys are as follows:
key: "\x01", value: BSON serialized javascript object
key: "\x02", value: key of subtype "\x03"
key: "\x03", value: opts ival
key: "\x04", value: key of subtype "\x01"
key: "\x05", value: (byte*) one or more bytes (node Buffer)
Copied from http://bsonspec.org/spec.html and modified by Tim Kuijsten