barrel_design_index (barrel_design v0.1.0)
View SourceRow layout and reads of a view index.
In the derived store of a database, with V the view's 8-byte id and G a 32-bit generation:
r V G Key DocId Orda row; its value is{Value, ExpiresAt}. Key and DocId use barrel_design_key's encoding, Ord is the emission ordinal, so a document can emit the same key twice;b V G DocIdthe document's current rows and revision;e V G DocIdthe error of the document's last map, if any;s Vthe view state: generations, definitions, checkpoints.
The indexer replaces a document's rows, its reverse entry, its error and the state's checkpoint in one write batch.
Summary
Functions
Raw key bounds [Lower, Upper) for the selection options: key, key_prefix, start_key/end_key with inclusive_end (default true), and bounds (already encoded).
Operations replacing one document's contributions. Old is its reverse entry (or none); Result is the map's outcome for the current revision (skip when the document is gone or not selected).
Key ranges holding a generation's rows, reverse entries and errors.
Every view state the store holds, running or not.
Read rows or grouped totals of the published generation G under Snap, the snapshot the caller read the view state with. reduce totals with the view's reducer, grouped by the first group_level key components (exact for whole keys); limit rows or groups per call; max_scan rows folded per call, expired ones included.
Reverse entry keys for a batch of document ids.
Key ranges holding every generation of a view: its rows, reverse entries and errors, whatever its persisted state says.
Functions
Raw key bounds [Lower, Upper) for the selection options: key, key_prefix, start_key/end_key with inclusive_end (default true), and bounds (already encoded).
-spec doc_ops(binary(), non_neg_integer(), binary(), {binary(), non_neg_integer()}, not_found | {ok, binary()} | {error, term()}, {ok, [term()]} | {error, term()} | skip) -> list().
Operations replacing one document's contributions. Old is its reverse entry (or none); Result is the map's outcome for the current revision (skip when the document is gone or not selected).
-spec generation_ranges(binary(), non_neg_integer()) -> [{binary(), binary()}].
Key ranges holding a generation's rows, reverse entries and errors.
-spec persisted_states(barrel_design_store:store()) -> [{binary(), map()}].
Every view state the store holds, running or not.
-spec query(barrel_design_store:store(), rocksdb:snapshot_handle(), binary(), non_neg_integer(), map(), map()) -> {ok, [map()], map()} | {error, term()}.
Read rows or grouped totals of the published generation G under Snap, the snapshot the caller read the view state with. reduce totals with the view's reducer, grouped by the first group_level key components (exact for whole keys); limit rows or groups per call; max_scan rows folded per call, expired ones included.
position resumes a read at a position an earlier page returned, and now fixes the instant expiry is judged at. The meta carries start, the position of this page's first row, next, the position after it when more may follow, and now.
-spec read_state(barrel_design_store:store(), binary()) -> {ok, map()} | not_found.
-spec read_state(barrel_design_store:store(), binary(), rocksdb:snapshot_handle()) -> {ok, map()} | not_found.
-spec reverse_keys(binary(), non_neg_integer(), [binary()]) -> [binary()].
Reverse entry keys for a batch of document ids.
Key ranges holding every generation of a view: its rows, reverse entries and errors, whatever its persisted state says.