barrel_postings (barrel_docdb v1.1.1)
View SourcePostings Resource API for barrel_docdb
This module wraps the rocksdb postings_* resource API for efficient posting list operations. The resource API parses posting list binaries once and provides O(1) or O(log n) lookups for repeated access.
Key benefits: - Parse once, lookup many times (~0.1 us per lookup) - Native set operations (intersection, union, difference) - Pre-sorted keys in V2 format - Roaring64 bitmap for fast existence checks
Summary
Functions
Check if a key exists using the embedded roaring bitmap. O(1) hash-based lookup, may have rare false positives. Use contains/2 for exact checks when false positives are unacceptable.
Check if a key exists in the posting list (exact match). Uses O(log n) binary search on sorted keys.
Get the number of active keys in the posting list.
Compute difference (A - B) of two posting lists. Returns keys in A that are not in B.
Compute intersection of multiple posting lists. Efficiently processes smallest lists first. All list elements can be postings resources or binaries.
Compute intersection (AND) of two posting lists. Both arguments can be postings resources or binaries.
Get the cardinality of intersection without materializing the result. Uses roaring bitmap for fast computation.
Get all active keys in lexicographic (sorted) order. Keys are pre-sorted in V2 format, so this is O(n).
Parse a posting list binary into a resource for fast repeated lookups. The binary must be a valid V1 or V2 posting list format.
Convert a postings resource back to binary format.
Compute union (OR) of two posting lists. Both arguments can be postings resources or binaries.
Types
Functions
Check if a key exists using the embedded roaring bitmap. O(1) hash-based lookup, may have rare false positives. Use contains/2 for exact checks when false positives are unacceptable.
Check if a key exists in the posting list (exact match). Uses O(log n) binary search on sorted keys.
-spec count(postings()) -> non_neg_integer().
Get the number of active keys in the posting list.
-spec difference(postings() | binary(), postings() | binary()) -> {ok, postings()} | {error, term()}.
Compute difference (A - B) of two posting lists. Returns keys in A that are not in B.
Compute intersection of multiple posting lists. Efficiently processes smallest lists first. All list elements can be postings resources or binaries.
-spec intersection(postings() | binary(), postings() | binary()) -> {ok, postings()} | {error, term()}.
Compute intersection (AND) of two posting lists. Both arguments can be postings resources or binaries.
-spec intersection_count(postings() | binary(), postings() | binary()) -> non_neg_integer().
Get the cardinality of intersection without materializing the result. Uses roaring bitmap for fast computation.
Get all active keys in lexicographic (sorted) order. Keys are pre-sorted in V2 format, so this is O(n).
Parse a posting list binary into a resource for fast repeated lookups. The binary must be a valid V1 or V2 posting list format.
Convert a postings resource back to binary format.
Compute union (OR) of two posting lists. Both arguments can be postings resources or binaries.