Liking cljdoc? Tell your friends :D

xitdb.util.sorted-key

Order-preserving, reversible key codec for on-disk sorted maps/sets.

Unlike hash maps (which SHA-1-hash their keys), sorted collections store the real key bytes so they can be recovered on read and compared by the engine's unsigned lexicographic byte comparison (Arrays.compareUnsigned). The codec must therefore be:

  1. reversible - decode-key (encode-key k) == k
  2. order-preserving - sign(compareUnsigned (encode a) (encode b)) == sign(compare a b) for any two keys.

Every encoding carries a leading 1-byte type tag. The tag both identifies the type on decode and establishes a total order across types, so heterogeneous keys never throw.

Supported key types: string, keyword, boolean, char, long, double, UUID, Instant and Date. Strings encode as their UTF-8 bytes (already code-point ordered); keywords use a flag + namespace + name layout so they sort like Clojure's default comparator (see keyword->bytes); numeric/temporal/UUID keys use order-preserving big-endian encodings.

Order-preserving, reversible key codec for on-disk sorted maps/sets.

Unlike hash maps (which SHA-1-hash their keys), sorted collections store the
real key bytes so they can be recovered on read and compared by the engine's
unsigned lexicographic byte comparison (`Arrays.compareUnsigned`). The codec
must therefore be:

  1. reversible  - `decode-key (encode-key k)` == k
  2. order-preserving - `sign(compareUnsigned (encode a) (encode b))`
                        == `sign(compare a b)` for any two keys.

Every encoding carries a leading 1-byte type tag. The tag both identifies the
type on decode and establishes a total order across types, so heterogeneous
keys never throw.

Supported key types: string, keyword, boolean, char, long, double, UUID,
Instant and Date. Strings encode as their UTF-8 bytes (already code-point
ordered); keywords use a flag + namespace + name layout so they sort like
Clojure's default comparator (see `keyword->bytes`); numeric/temporal/UUID
keys use order-preserving big-endian encodings.
raw docstring

decode-keyclj

(decode-key ba)

Decodes a byte array produced by encode-key back to the Clojure key.

Decodes a byte array produced by `encode-key` back to the Clojure key.
sourceraw docstring

encode-keyclj

(encode-key k)

Encodes Clojure key k to an order-preserving, reversible byte array.

Encodes Clojure key `k` to an order-preserving, reversible byte array.
sourceraw docstring

key-comparatorclj

A java.util.Comparator consistent with the engine's natural ordering: compares two keys by Arrays.compareUnsigned over their encoded bytes. Use this (not clojure.core/compare) so subseq/rsubseq bound checks agree with on-disk order across all supported types, including heterogeneous keys.

A `java.util.Comparator` consistent with the engine's natural ordering:
compares two keys by `Arrays.compareUnsigned` over their encoded bytes. Use
this (not `clojure.core/compare`) so `subseq`/`rsubseq` bound checks agree with
on-disk order across all supported types, including heterogeneous keys.
sourceraw docstring

kw-has-nsclj

source

kw-no-nsclj

source

num-doubleclj

source

num-longclj

source

tag-booleanclj

source

tag-charclj

source

tag-dateclj

source

tag-instantclj

source

tag-keywordclj

source

tag-numberclj

source

tag-stringclj

source

tag-uuidclj

source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close