actionkv is a key-value store for pairs of arbitrary-length byte sequences. A key identifies one value: a query for “Fiji” can return “Suva,” but the model does not support a broader query for every capital in a region. section 7.5.1
Its command-line interface takes a data file, an operation, and a key:
- get retrieves a value; a missing key is reported as not found. section 7.6
- insert adds a pair, delete removes one, and update replaces a value. section 7.6
The executable dispatches these commands to libactionkv::ActionKV. The library manages the file and encodes and decodes records. To start, open the data file and call load() to build an in-memory index of existing keys’ file offsets. Keys and values use byte slices or byte vectors, so they need not be valid UTF-8 text. section 7.7 section 7.7.1
Figure 7.3 A single record in the Bitcask file format. To parse a record, read the header information, then use that information to read the body. Lastly, verify the body’s contents with the checksum provided in the header.
A Bitcask record has a 12-byte header containing a checksum and the key and value lengths. Those lengths guide reading the body; the checksum verifies it. section 7.7.2
The first executable rebuilds its index each time it starts. The second persists index data in the same file, using a hidden key; retrieval can deserialize that index and use an offset to read a record. The shared library does not need to change. section 7.7.11
