barrel_doc_body_store (barrel_docdb v1.1.1)

View Source

Document body storage using body column family (BlobDB enabled)

Document bodies are stored in the "bodies" column family which has BlobDB enabled. This keeps the main LSM tree lean (only indexes and metadata) and provides efficient batch fetching with multi_get.

The store is accessed via persistent_term registry using the db name.

Summary

Functions

Get a specific revision body (archived, non-current revisions).

Get the current body for a document. Since current body is stored without revision in key, no rev needed.

Batch get specific revision bodies (for archived revisions). DocIdRevPairs is a list of {DocId, RevId} tuples.

Batch get current bodies for multiple documents. Much faster than multi_get_bodies since we don't need to know revisions. Uses short_range read profile by default.

Batch get current bodies with explicit read profile. Read profiles optimize I/O based on batch size: - point: Small batches (<50), cache friendly - short_range: Medium batches (50-200), auto readahead - long_scan: Large batches (>200), prefetch 2MB, avoid cache pollution

Batch get current bodies with snapshot for consistent reads. Uses short_range read profile by default.

Batch get current bodies with snapshot and explicit read profile. Use this for query execution to ensure consistent reads across batches.

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()}.

read_profile/0

-type read_profile() :: barrel_store_rocksdb:read_profile().

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().

snapshot/0

-type snapshot() :: barrel_store_rocksdb:snapshot().

view_name/0

-type view_name() :: binary().

view_result/0

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

Functions

get_body(DbName, DocId, RevId)

-spec get_body(db_name(), docid(), revid()) -> {ok, binary()} | not_found | {error, term()}.

Get a specific revision body (archived, non-current revisions).

get_current_body(DbName, DocId)

-spec get_current_body(db_name(), docid()) -> {ok, binary()} | not_found | {error, term()}.

Get the current body for a document. Since current body is stored without revision in key, no rev needed.

multi_get_bodies(DbName, DocIdRevPairs, Opts)

-spec multi_get_bodies(db_name(), [{docid(), revid()}], map()) ->
                          [{ok, binary()} | not_found | {error, term()}].

Batch get specific revision bodies (for archived revisions). DocIdRevPairs is a list of {DocId, RevId} tuples.

multi_get_current_bodies(DbName, DocIds)

-spec multi_get_current_bodies(db_name(), [docid()]) -> [{ok, binary()} | not_found | {error, term()}].

Batch get current bodies for multiple documents. Much faster than multi_get_bodies since we don't need to know revisions. Uses short_range read profile by default.

multi_get_current_bodies(DbName, DocIds, Profile)

-spec multi_get_current_bodies(db_name(), [docid()], read_profile()) ->
                                  [{ok, binary()} | not_found | {error, term()}].

Batch get current bodies with explicit read profile. Read profiles optimize I/O based on batch size: - point: Small batches (<50), cache friendly - short_range: Medium batches (50-200), auto readahead - long_scan: Large batches (>200), prefetch 2MB, avoid cache pollution

multi_get_current_bodies_with_snapshot(DbName, DocIds, Snapshot)

-spec multi_get_current_bodies_with_snapshot(db_name(), [docid()], snapshot()) ->
                                                [{ok, binary()} | not_found | {error, term()}].

Batch get current bodies with snapshot for consistent reads. Uses short_range read profile by default.

multi_get_current_bodies_with_snapshot(DbName, DocIds, Snapshot, Profile)

-spec multi_get_current_bodies_with_snapshot(db_name(), [docid()], snapshot(), read_profile()) ->
                                                [{ok, binary()} | not_found | {error, term()}].

Batch get current bodies with snapshot and explicit read profile. Use this for query execution to ensure consistent reads across batches.