merkle-db.key

Record keys are immutable byte sequences which uniquely identify a record within a table. Keys are stored in sorted order by comparing them lexicographically.

The first byte that differs between two keys determines their sort order, with the lower byte value ranking first. If the prefix of the longer key matches all the bytes in the shorter key, the shorter key ranks first.

after?

(after? k x)

Returns true if k is ranked after x.

before?

(before? k x)

Returns true if k is ranked before x.

bytes-lexicoder

Lexicoder for passing through raw byte arrays.

create

(create data)

Construct a new key value containing the given byte data, which should either be a byte array or a sequence of byte values.

decode

(decode coder data)(decode coder data offset len)

Decodes the given key byte data and returns a value.

encode

(encode coder value)

Encodes the given value and returns persistent key bytes.

float-lexicoder

Lexicoder for double-precision floating point values.

get-bytes

(get-bytes k)

Return a copy of the raw bytes inside a key.

hex

(hex k)

Return a hexadecimal string encoding the bytes in the key.

instant-lexicoder

Lexicoder for instants in time.

integer-lexicoder

Lexicoder for long integer values.

key?

(key? x)

Predicate which returns true if x is a key value.

Lexicoder

protocol

Simple codec for transforming values into keys that have specific ordering semantics.

members

decode*

(decode* coder data offset len)

Decode a key value from a section of a byte array.

encode*

(encode* coder value)

Encode the key value as a byte array.

lexicoder-config

(lexicoder-config coder)

Return a configuration value representing this lexicoder.

lexicoder

multimethod

Construct a lexicoder from a configuration data structure. The structure should be either a keyword or a vector with the first element a keyword providing the dispatch value.

max

(max x)(max x y)(max x y & more)

Returns the greatest of the given keys.

min

(min x)(min x y)(min x y & more)

Returns the least of the given keys.

parse

(parse s)

Parse a key from a hexadecimal string.

reverse-lexicoder

(reverse-lexicoder coder)

Wraps the given lexicoder to reverse the ordering of keys encoded with it.

sequence-lexicoder

(sequence-lexicoder element-coder)

Constructs a lexicoder for homogeneous sequences of elements which will be coded with the given lexicoder.

string-lexicoder

Lexicoder for UTF-8 character strings.

string-lexicoder*

(string-lexicoder* charset)

Constructs a new string lexicoder with the given charset.

tuple-lexicoder

(tuple-lexicoder & coders)

Constructs a lexicoder for a fixed-size tuple of values which will be coded with the given lexicoders, in order.