barrel_store_keys (barrel_docdb v1.1.1)

View Source

Key encoding for barrel_docdb storage

Provides functions to encode and decode keys for RocksDB storage. Keys are prefixed to enable efficient range scans.

Summary

Functions

Attachment data key

Prefix for document attachments

Change bucket key for time-bucketed change hints. BucketTs is typically erlang:system_time(second) div 60 (minute granularity). Value stores {min_hlc, max_hlc, count} for quick "has changes?" checks.

End marker for change bucket range scan.

Prefix for all change buckets in a database.

End marker for a channel feed range scan.

Key for a channel feed row at a change-sequence HLC. One row per doc per channel: rewrites delete the previous HLC key.

Start key for scanning one channel's feed.

Deleted documents count key

Documents count key

Last HLC timestamp key

General database metadata key

Database UID key

Extract {Channel, Hlc} from a channel feed key.

The doc id inside a TTL index key.

Extract doc_id from a doc_info key

Extract DocId from a doc_info key

Extract the encoded version from a version-chain key.

Extract the change HLC from a history key.

Decode binary to HLC timestamp

Extract HLC from a doc_hlc key

Decode an outbox key to extract tag and HLC.

Decode a path from binary.

Decode path_hlc key to extract topic and HLC. Returns {Topic, Hlc} tuple.

Decode a view key

Document body key for current revision (no revision in key). This enables direct body fetch without knowing the revision.

Document body key for a specific (non-current) revision. Used to store old revision bodies when updating a document.

Document current state key (stores {rev, deleted, hlc})

End marker for doc_current range scan

Prefix for all doc_current keys in a database

Document entity key for wide-column storage. Stores all document metadata as named columns: - rev: current revision ID - deleted: "true" or "false" - hlc: 12-byte encoded HLC timestamp - revtree: term_to_binary encoded revision tree

End marker for doc_entity range scan

Prefix for all doc_entity keys in a database

Doc TTL index row: sorted by expiry instant so the sweeper folds exactly the expired range.

Prefix of all TTL index rows of a database.

Exclusive upper bound covering every row expiring at or before NowMs (the doc id tail sorts above the bare instant, so bound at NowMs + 1).

Document HLC key (for changes feed with HLC ordering) HLC timestamps are 12 bytes (8 wall_time + 4 logical)

End marker for HLC range scan

Prefix for all HLC keys

Document info key (stores doc_info record)

End marker for doc_info range scan

Prefix for all doc_info keys in a database

Reverse index key: doc_id -> list of indexed paths. Used to remove old paths when updating a document.

Prefix for doc_paths keys.

Document revision key (stores document body)

Prefix for all revisions of a document

Document revision tree key (stores revtree as term_to_binary)

Key for one non-current version of a document. Key format: prefix | db_name | doc_id | ':' | version (storage encoding, HLC-first, so the chain scans in causal order).

End marker for a version chain scan.

Start key for scanning a document's version chain.

Extract bucket (first 2 bytes) from DocId. Short DocIds are padded with zeros.

Encode HLC timestamp to binary (big-endian for sort order) Uses barrel_hlc:encode/1 which produces 12 bytes

Encode a path for lexicographic ordering. Path components are encoded with length prefix and type tags. This ensures correct sort order across different types.

Encode topic for null-terminated storage. Topics are MQTT-style paths like "users/123/name"

Encode a view key for sorted storage Uses term_to_binary with ordered encoding to preserve Erlang term ordering

End marker for a history range scan.

Key for one history entry. The change-sequence HLC is issued locally and strictly increasing per database, so keys never collide and scan in write order.

Start key for scanning a database's history.

Convert HLC to time bucket number.

Local document key (not replicated) - legacy format in default CF

Local document key for local_cf (per-database) Key format: DbName + NUL separator + DocId

Prefix for all local docs in a database Use with local_fold to enumerate all local docs for a database.

End marker for the whole-database outbox range.

Start key for scanning ALL outbox entries of a database (every tag), for maintenance scans (timeline rewind).

End marker for an outbox tag range scan.

Outbox key for a tagged entry. Key format: prefix | db_name | tag (null-terminated) | hlc The tag is an opaque binary chosen by the producer (e.g. <<"embed">>); the HLC gives time-ordered scans per tag and exact-key acks.

Start key for scanning all outbox entries under a tag.

Parse a key to determine its type and extract components. Used by compaction filter to identify doc_entity keys.

Path bitmap key for bitmap index. Stores a bitmap of document positions matching a specific path+value.

Path-HLC key for indexing changes by topic path. Key format: prefix | db_name | topic (null-terminated) | hlc Topic is an MQTT-style path like "users/123/name"

End marker for path_hlc range scan. Use with path_hlc_prefix or path_hlc for bounded range scans.

Prefix for scanning path_hlc entries for a specific topic. Returns all changes under this topic since the beginning of time.

End key for wildcard topic prefix matching (# patterns). Use with path_hlc_wildcard_start for bounded range scans matching all topics that start with the given prefix.

Start key for wildcard topic prefix matching (# patterns). Unlike path_hlc_prefix, this does NOT include the null terminator, allowing the range to capture all topics that START with the prefix. Example: prefix "users" matches topics "users", "users/123", "users/abc/def", etc.

End marker for path index range scan.

Path index key for a document path. Key format: prefix | db_name | encoded_path | docid Path includes the value at the end: [field1, field2, value]

Prefix for scanning path index entries. Can be used with partial paths for prefix scans.

End marker for posting list range scan.

Posting list key for path index. Key format: prefix | db_name | encoded_path (NO DocId - DocIds are in value) Path includes the value at the end: [field1, field2, value]

Prefix for scanning posting list entries. Can be used with partial paths for prefix scans.

Path stats key for cardinality counter. Stores the count of documents matching a specific path+value.

End key for prefix changes range scan. Creates an upper bound key that's lexicographically after all bucket keys for this prefix.

Create prefix changes key for a specific bucket. Key format: PREFIX_CHANGES | db_name | prefix | 0x00 | bucket (4 bytes BE)

Start key for prefix changes range scan. Used to scan from a specific bucket onwards.

System (global) document key for local_cf Key format: "_system" + NUL separator + DocId

Prefix for all system docs Use with local_fold to enumerate all system docs.

Truncate a value to max 128 bytes for value-first index. Only applies to binary values; other types are unchanged.

End marker for value-first index range scan.

Value-first index key for iterable equality queries. Format: [value_prefix, path, DocId] enables prefix scan with early termination. Unlike value_posting_key which stores DocIds in a posting list, this stores one key per DocId allowing iteration without full deserialization.

Prefix for scanning value-first index by value and path. Use this to find all DocIds matching a specific (path, value) pair.

End marker for bucketed posting list range scan.

Bucketed posting list key for sorted iteration. Format: [value_prefix, path, bucket] where bucket is first 2 bytes of DocId. This splits posting lists by DocId prefix, enabling: - Sorted iteration (buckets are in lexicographic order) - Smaller chunks (faster decode per bucket) - Early termination in intersection

Prefix for scanning bucketed posting lists for a path+value. Use this to iterate all buckets in sorted order.

End marker for value-first posting list range scan.

Value-first posting list key for fast equality queries. Key format: prefix | db_name | value_prefix | encoded_path Value is truncated to 128 bytes max for efficient prefix scans. Path is the field path WITHOUT the value (e.g., [&lt;&lt;"type"&gt;&gt;] for type=user)

Prefix for scanning value-first posting lists by value. Use this to find all paths with a specific value.

View by docid key (tracks which index entries belong to each doc)

End marker for view by docid range scan

Prefix for view by docid entries

End marker for view index range scan

Prefix for view index entries

View metadata key

View indexed sequence key

Types

att_info/0

-type att_info() ::
          #{name := binary(),
            content_type := binary(),
            length := non_neg_integer(),
            digest := binary(),
            chunked => boolean(),
            chunk_size => pos_integer(),
            chunk_count => pos_integer()}.

change/0

-type change() :: map().

db_config/0

-type db_config() :: #{path => string(), store => module(), atom() => term()}.

db_name/0

-type db_name() :: binary().

db_ref/0

-type db_ref() :: pid() | atom().

doc/0

-type doc() :: #{binary() => term()}.

doc_info/0

-type doc_info() :: #{id := docid(), rev := revid(), deleted := boolean(), revtree := revtree()}.

docid/0

-type docid() :: binary().

endpoint/0

-type endpoint() :: db_name() | {node(), db_name()} | {module(), term()}.

rep_options/0

-type rep_options() ::
          #{continuous => boolean(),
            since => seq_string(),
            filter => fun((doc()) -> boolean()),
            atom() => term()}.

rev_info/0

-type rev_info() ::
          #{id := revid(),
            parent := revid() | undefined,
            deleted := boolean(),
            attachments => #{binary() => att_info()}}.

revid/0

-type revid() :: binary().

revtree/0

-type revtree() :: #{revid() => rev_info()}.

seq/0

-type seq() :: barrel_hlc:timestamp().

seq_string/0

-type seq_string() :: binary().

view_name/0

-type view_name() :: binary().

view_result/0

-type view_result() :: #{key := term(), value := term(), id := docid()}.

Functions

att_data(DbName, DocId, AttName)

-spec att_data(db_name(), docid(), binary()) -> binary().

Attachment data key

att_data_prefix(DbName, DocId)

-spec att_data_prefix(db_name(), docid()) -> binary().

Prefix for document attachments

change_bucket(DbName, BucketTs)

-spec change_bucket(db_name(), non_neg_integer()) -> binary().

Change bucket key for time-bucketed change hints. BucketTs is typically erlang:system_time(second) div 60 (minute granularity). Value stores {min_hlc, max_hlc, count} for quick "has changes?" checks.

change_bucket_end(DbName)

-spec change_bucket_end(db_name()) -> binary().

End marker for change bucket range scan.

change_bucket_prefix(DbName)

-spec change_bucket_prefix(db_name()) -> binary().

Prefix for all change buckets in a database.

channel_end(DbName, Channel)

-spec channel_end(db_name(), binary()) -> binary().

End marker for a channel feed range scan.

channel_key(DbName, Channel, Hlc)

-spec channel_key(db_name(), binary(), barrel_hlc:timestamp()) -> binary().

Key for a channel feed row at a change-sequence HLC. One row per doc per channel: rewrites delete the previous HLC key.

channel_prefix(DbName, Channel)

-spec channel_prefix(db_name(), binary()) -> binary().

Start key for scanning one channel's feed.

db_del_count(DbName)

-spec db_del_count(db_name()) -> binary().

Deleted documents count key

db_docs_count(DbName)

-spec db_docs_count(db_name()) -> binary().

Documents count key

db_last_hlc(DbName)

-spec db_last_hlc(db_name()) -> binary().

Last HLC timestamp key

db_meta(DbName, MetaKey)

-spec db_meta(db_name(), binary()) -> binary().

General database metadata key

db_uid(DbName)

-spec db_uid(db_name()) -> binary().

Database UID key

decode_channel_key(DbName, Key)

-spec decode_channel_key(db_name(), binary()) -> {binary(), barrel_hlc:timestamp()}.

Extract {Channel, Hlc} from a channel feed key.

decode_doc_expiry_key(DbName, Key)

-spec decode_doc_expiry_key(db_name(), binary()) -> {non_neg_integer(), binary()}.

The doc id inside a TTL index key.

decode_doc_id(DbName, Key)

-spec decode_doc_id(db_name(), binary()) -> docid().

Extract doc_id from a doc_info key

decode_doc_info_key(DbName, Key)

-spec decode_doc_info_key(db_name(), binary()) -> docid().

Extract DocId from a doc_info key

decode_doc_version_key(DbName, DocId, Key)

-spec decode_doc_version_key(db_name(), docid(), binary()) -> binary().

Extract the encoded version from a version-chain key.

decode_history_key(DbName, Key)

-spec decode_history_key(db_name(), binary()) -> barrel_hlc:timestamp().

Extract the change HLC from a history key.

decode_hlc(Bin)

-spec decode_hlc(binary()) -> barrel_hlc:timestamp().

Decode binary to HLC timestamp

decode_hlc_key(DbName, Key)

-spec decode_hlc_key(db_name(), binary()) -> barrel_hlc:timestamp().

Extract HLC from a doc_hlc key

decode_outbox_key(DbName, Key)

-spec decode_outbox_key(db_name(), binary()) -> {binary(), barrel_hlc:timestamp()}.

Decode an outbox key to extract tag and HLC.

decode_path(Bin)

-spec decode_path(binary()) -> [term()].

Decode a path from binary.

decode_path_hlc_key(DbName, Key)

-spec decode_path_hlc_key(db_name(), binary()) -> {binary(), barrel_hlc:timestamp()}.

Decode path_hlc key to extract topic and HLC. Returns {Topic, Hlc} tuple.

decode_view_key(Bin)

-spec decode_view_key(binary()) -> term().

Decode a view key

doc_body(DbName, DocId)

-spec doc_body(db_name(), docid()) -> binary().

Document body key for current revision (no revision in key). This enables direct body fetch without knowing the revision.

doc_body_rev(DbName, DocId, RevId)

-spec doc_body_rev(db_name(), docid(), revid()) -> binary().

Document body key for a specific (non-current) revision. Used to store old revision bodies when updating a document.

doc_current(DbName, DocId)

-spec doc_current(db_name(), docid()) -> binary().

Document current state key (stores {rev, deleted, hlc})

doc_current_end(DbName)

-spec doc_current_end(db_name()) -> binary().

End marker for doc_current range scan

doc_current_prefix(DbName)

-spec doc_current_prefix(db_name()) -> binary().

Prefix for all doc_current keys in a database

doc_entity(DbName, DocId)

-spec doc_entity(db_name(), docid()) -> binary().

Document entity key for wide-column storage. Stores all document metadata as named columns: - rev: current revision ID - deleted: "true" or "false" - hlc: 12-byte encoded HLC timestamp - revtree: term_to_binary encoded revision tree

doc_entity_end(DbName)

-spec doc_entity_end(db_name()) -> binary().

End marker for doc_entity range scan

doc_entity_prefix(DbName)

-spec doc_entity_prefix(db_name()) -> binary().

Prefix for all doc_entity keys in a database

doc_expiry(DbName, ExpiresMs, DocId)

-spec doc_expiry(db_name(), non_neg_integer(), binary()) -> binary().

Doc TTL index row: sorted by expiry instant so the sweeper folds exactly the expired range.

doc_expiry_prefix(DbName)

-spec doc_expiry_prefix(db_name()) -> binary().

Prefix of all TTL index rows of a database.

doc_expiry_upto(DbName, NowMs)

-spec doc_expiry_upto(db_name(), non_neg_integer()) -> binary().

Exclusive upper bound covering every row expiring at or before NowMs (the doc id tail sorts above the bare instant, so bound at NowMs + 1).

doc_hlc(DbName, HlcTS)

-spec doc_hlc(db_name(), barrel_hlc:timestamp()) -> binary().

Document HLC key (for changes feed with HLC ordering) HLC timestamps are 12 bytes (8 wall_time + 4 logical)

doc_hlc_end(DbName)

-spec doc_hlc_end(db_name()) -> binary().

End marker for HLC range scan

doc_hlc_prefix(DbName)

-spec doc_hlc_prefix(db_name()) -> binary().

Prefix for all HLC keys

doc_info(DbName, DocId)

-spec doc_info(db_name(), docid()) -> binary().

Document info key (stores doc_info record)

doc_info_end(DbName)

-spec doc_info_end(db_name()) -> binary().

End marker for doc_info range scan

doc_info_prefix(DbName)

-spec doc_info_prefix(db_name()) -> binary().

Prefix for all doc_info keys in a database

doc_paths_key(DbName, DocId)

-spec doc_paths_key(db_name(), docid()) -> binary().

Reverse index key: doc_id -> list of indexed paths. Used to remove old paths when updating a document.

doc_paths_prefix(DbName)

-spec doc_paths_prefix(db_name()) -> binary().

Prefix for doc_paths keys.

doc_rev(DbName, DocId, RevId)

-spec doc_rev(db_name(), docid(), revid()) -> binary().

Document revision key (stores document body)

doc_rev_prefix(DbName, DocId)

-spec doc_rev_prefix(db_name(), docid()) -> binary().

Prefix for all revisions of a document

doc_tree(DbName, DocId)

-spec doc_tree(db_name(), docid()) -> binary().

Document revision tree key (stores revtree as term_to_binary)

doc_version(DbName, DocId, VersionEnc)

-spec doc_version(db_name(), docid(), binary()) -> binary().

Key for one non-current version of a document. Key format: prefix | db_name | doc_id | ':' | version (storage encoding, HLC-first, so the chain scans in causal order).

doc_version_end(DbName, DocId)

-spec doc_version_end(db_name(), docid()) -> binary().

End marker for a version chain scan.

doc_version_prefix(DbName, DocId)

-spec doc_version_prefix(db_name(), docid()) -> binary().

Start key for scanning a document's version chain.

docid_bucket(DocId)

-spec docid_bucket(docid()) -> binary().

Extract bucket (first 2 bytes) from DocId. Short DocIds are padded with zeros.

encode_hlc(HlcTS)

-spec encode_hlc(barrel_hlc:timestamp()) -> binary().

Encode HLC timestamp to binary (big-endian for sort order) Uses barrel_hlc:encode/1 which produces 12 bytes

encode_path(Path)

-spec encode_path([term()]) -> binary().

Encode a path for lexicographic ordering. Path components are encoded with length prefix and type tags. This ensures correct sort order across different types.

encode_topic(Topic)

-spec encode_topic(binary()) -> binary().

Encode topic for null-terminated storage. Topics are MQTT-style paths like "users/123/name"

encode_view_key(Key)

-spec encode_view_key(term()) -> binary().

Encode a view key for sorted storage Uses term_to_binary with ordered encoding to preserve Erlang term ordering

history_end(DbName)

-spec history_end(db_name()) -> binary().

End marker for a history range scan.

history_key(DbName, HlcTS)

-spec history_key(db_name(), barrel_hlc:timestamp()) -> binary().

Key for one history entry. The change-sequence HLC is issued locally and strictly increasing per database, so keys never collide and scan in write order.

history_prefix(DbName)

-spec history_prefix(db_name()) -> binary().

Start key for scanning a database's history.

hlc_to_bucket(Hlc)

-spec hlc_to_bucket(barrel_hlc:timestamp()) -> non_neg_integer().

Convert HLC to time bucket number.

local_doc(DbName, DocId)

-spec local_doc(db_name(), docid()) -> binary().

Local document key (not replicated) - legacy format in default CF

local_doc_key(DbName, DocId)

-spec local_doc_key(db_name(), docid()) -> binary().

Local document key for local_cf (per-database) Key format: DbName + NUL separator + DocId

local_doc_prefix(DbName)

-spec local_doc_prefix(db_name()) -> binary().

Prefix for all local docs in a database Use with local_fold to enumerate all local docs for a database.

outbox_db_end(DbName)

-spec outbox_db_end(db_name()) -> binary().

End marker for the whole-database outbox range.

outbox_db_prefix(DbName)

-spec outbox_db_prefix(db_name()) -> binary().

Start key for scanning ALL outbox entries of a database (every tag), for maintenance scans (timeline rewind).

outbox_end(DbName, Tag)

-spec outbox_end(db_name(), binary()) -> binary().

End marker for an outbox tag range scan.

outbox_key(DbName, Tag, Hlc)

-spec outbox_key(db_name(), binary(), barrel_hlc:timestamp()) -> binary().

Outbox key for a tagged entry. Key format: prefix | db_name | tag (null-terminated) | hlc The tag is an opaque binary chosen by the producer (e.g. <<"embed">>); the HLC gives time-ordered scans per tag and exact-key acks.

outbox_prefix(DbName, Tag)

-spec outbox_prefix(db_name(), binary()) -> binary().

Start key for scanning all outbox entries under a tag.

parse_key(_)

-spec parse_key(binary()) ->
                   {doc_entity, DbName :: binary(), DocId :: binary()} |
                   {doc_body_rev, DbName :: binary(), DocId :: binary(), Rev :: binary()} |
                   other.

Parse a key to determine its type and extract components. Used by compaction filter to identify doc_entity keys.

path_bitmap_key(DbName, Path)

-spec path_bitmap_key(db_name(), [term()]) -> binary().

Path bitmap key for bitmap index. Stores a bitmap of document positions matching a specific path+value.

path_hlc(DbName, Topic, Hlc)

-spec path_hlc(db_name(), binary(), barrel_hlc:timestamp()) -> binary().

Path-HLC key for indexing changes by topic path. Key format: prefix | db_name | topic (null-terminated) | hlc Topic is an MQTT-style path like "users/123/name"

path_hlc_end(DbName, Topic)

-spec path_hlc_end(db_name(), binary()) -> binary().

End marker for path_hlc range scan. Use with path_hlc_prefix or path_hlc for bounded range scans.

path_hlc_prefix(DbName, Topic)

-spec path_hlc_prefix(db_name(), binary()) -> binary().

Prefix for scanning path_hlc entries for a specific topic. Returns all changes under this topic since the beginning of time.

path_hlc_wildcard_end(DbName, TopicPrefix)

-spec path_hlc_wildcard_end(db_name(), binary()) -> binary().

End key for wildcard topic prefix matching (# patterns). Use with path_hlc_wildcard_start for bounded range scans matching all topics that start with the given prefix.

path_hlc_wildcard_start(DbName, TopicPrefix)

-spec path_hlc_wildcard_start(db_name(), binary()) -> binary().

Start key for wildcard topic prefix matching (# patterns). Unlike path_hlc_prefix, this does NOT include the null terminator, allowing the range to capture all topics that START with the prefix. Example: prefix "users" matches topics "users", "users/123", "users/abc/def", etc.

path_index_end(DbName, Path)

-spec path_index_end(db_name(), [term()]) -> binary().

End marker for path index range scan.

path_index_key(DbName, Path, DocId)

-spec path_index_key(db_name(), [term()], docid()) -> binary().

Path index key for a document path. Key format: prefix | db_name | encoded_path | docid Path includes the value at the end: [field1, field2, value]

path_index_prefix(DbName, Path)

-spec path_index_prefix(db_name(), [term()]) -> binary().

Prefix for scanning path index entries. Can be used with partial paths for prefix scans.

path_posting_end(DbName, PathPrefix)

-spec path_posting_end(db_name(), [term()]) -> binary().

End marker for posting list range scan.

path_posting_key(DbName, Path)

-spec path_posting_key(db_name(), [term()]) -> binary().

Posting list key for path index. Key format: prefix | db_name | encoded_path (NO DocId - DocIds are in value) Path includes the value at the end: [field1, field2, value]

path_posting_prefix(DbName, PathPrefix)

-spec path_posting_prefix(db_name(), [term()]) -> binary().

Prefix for scanning posting list entries. Can be used with partial paths for prefix scans.

path_stats_key(DbName, Path)

-spec path_stats_key(db_name(), [term()]) -> binary().

Path stats key for cardinality counter. Stores the count of documents matching a specific path+value.

prefix_changes_end(DbName, Prefix, EndBucket)

-spec prefix_changes_end(db_name(), binary(), non_neg_integer()) -> binary().

End key for prefix changes range scan. Creates an upper bound key that's lexicographically after all bucket keys for this prefix.

prefix_changes_key(DbName, Prefix, Bucket)

-spec prefix_changes_key(db_name(), binary(), non_neg_integer()) -> binary().

Create prefix changes key for a specific bucket. Key format: PREFIX_CHANGES | db_name | prefix | 0x00 | bucket (4 bytes BE)

prefix_changes_start(DbName, Prefix, StartBucket)

-spec prefix_changes_start(db_name(), binary(), non_neg_integer()) -> binary().

Start key for prefix changes range scan. Used to scan from a specific bucket onwards.

system_doc_key(DocId)

-spec system_doc_key(docid()) -> binary().

System (global) document key for local_cf Key format: "_system" + NUL separator + DocId

system_doc_prefix()

-spec system_doc_prefix() -> binary().

Prefix for all system docs Use with local_fold to enumerate all system docs.

truncate_value(Bin)

-spec truncate_value(term()) -> term().

Truncate a value to max 128 bytes for value-first index. Only applies to binary values; other types are unchanged.

value_index_end(DbName, Value, Path)

-spec value_index_end(db_name(), term(), [term()]) -> binary().

End marker for value-first index range scan.

value_index_key(DbName, Value, Path, DocId)

-spec value_index_key(db_name(), term(), [term()], docid()) -> binary().

Value-first index key for iterable equality queries. Format: [value_prefix, path, DocId] enables prefix scan with early termination. Unlike value_posting_key which stores DocIds in a posting list, this stores one key per DocId allowing iteration without full deserialization.

value_index_prefix(DbName, Value, Path)

-spec value_index_prefix(db_name(), term(), [term()]) -> binary().

Prefix for scanning value-first index by value and path. Use this to find all DocIds matching a specific (path, value) pair.

value_posting_bucket_end(DbName, Value, Path)

-spec value_posting_bucket_end(db_name(), term(), [term()]) -> binary().

End marker for bucketed posting list range scan.

value_posting_bucket_key(DbName, Value, Path, DocId)

-spec value_posting_bucket_key(db_name(), term(), [term()], docid()) -> binary().

Bucketed posting list key for sorted iteration. Format: [value_prefix, path, bucket] where bucket is first 2 bytes of DocId. This splits posting lists by DocId prefix, enabling: - Sorted iteration (buckets are in lexicographic order) - Smaller chunks (faster decode per bucket) - Early termination in intersection

value_posting_bucket_prefix(DbName, Value, Path)

-spec value_posting_bucket_prefix(db_name(), term(), [term()]) -> binary().

Prefix for scanning bucketed posting lists for a path+value. Use this to iterate all buckets in sorted order.

value_posting_end(DbName, Value)

-spec value_posting_end(db_name(), term()) -> binary().

End marker for value-first posting list range scan.

value_posting_key(DbName, Value, Path)

-spec value_posting_key(db_name(), term(), [term()]) -> binary().

Value-first posting list key for fast equality queries. Key format: prefix | db_name | value_prefix | encoded_path Value is truncated to 128 bytes max for efficient prefix scans. Path is the field path WITHOUT the value (e.g., [&lt;&lt;"type"&gt;&gt;] for type=user)

value_posting_prefix(DbName, Value)

-spec value_posting_prefix(db_name(), term()) -> binary().

Prefix for scanning value-first posting lists by value. Use this to find all paths with a specific value.

view_by_docid(DbName, ViewId, DocId)

-spec view_by_docid(db_name(), binary(), docid()) -> binary().

View by docid key (tracks which index entries belong to each doc)

view_by_docid_end(DbName, ViewId, DocId)

-spec view_by_docid_end(db_name(), binary(), docid()) -> binary().

End marker for view by docid range scan

view_by_docid_prefix(DbName, ViewId, DocId)

-spec view_by_docid_prefix(db_name(), binary(), docid()) -> binary().

Prefix for view by docid entries

view_index(DbName, ViewId, IndexKey)

-spec view_index(db_name(), binary(), binary()) -> binary().

View index entry key

view_index_end(DbName, ViewId)

-spec view_index_end(db_name(), binary()) -> binary().

End marker for view index range scan

view_index_prefix(DbName, ViewId)

-spec view_index_prefix(db_name(), binary()) -> binary().

Prefix for view index entries

view_meta(DbName, ViewId)

-spec view_meta(db_name(), binary()) -> binary().

View metadata key

view_seq(DbName, ViewId)

-spec view_seq(db_name(), binary()) -> binary().

View indexed sequence key