Skip to content

Latest commit

 

History

History
113 lines (105 loc) · 3.94 KB

store-kv-spec.md

File metadata and controls

113 lines (105 loc) · 3.94 KB

Key-Value Store Specification

In PuzzleDB, records, schemas, and indices are all represented as key-value pairs. This section explains the format of the key-value data used in PuzzleDB.

Key Categories

The key-value store is a collection of key-value records, where each record is a key-value pair, consisting of a header as the key. The key-value store supports the following categories of key-value records:

Category Key Order Value

0

1

2

3

Database

Header (D)

Database

-

-

CBOR (Options)

Collection

Header ©

Database

Collection

-

CBOR (Schema)

Object

Header (O)

Database

Collection

Element

CBOR (Object)

Index

Header (I)

Database

Collection

Element

Tuple (Key)

Key Header Specification

The key header is a 2-byte header that is prepended to every key in the key-value store. The key header is reserved as follows:

Field Name Size (bits) Description Example Value

Key category

8

The record key type

D:Database C:Collection O:Document I:Index

Version

4

The version number

0:reserved 1-7

Value type

4

The record value type

0:reserved 1:CBOR 1:PRIMARY 2:SECONDARY

The key header begins with a 1-byte identifier for the key type, enabling key type-based searching. Duplication is tolerated because a value type is reserved for each key type.