barrel_design_store (barrel_design v0.1.0)

View Source

The derived store of one source database instance: a RocksDB directory under barrel_design's data_dir, opened with the source's storage environment so an encrypted database gets encrypted rows.

Summary

Functions

Bytes the store's files take on disk.

Remove the instance directories of Db other than Keep: only those whose marker names this database and their own instance. Anything else under the database's directory stays and is logged. The database's directory goes too once it is empty.

Fold [Lower, Upper) in key order, optionally under a snapshot. Fun(Key, Value, Acc) -> {ok, Acc} | {stop, Acc}.

Create the instance directory if needed and mark it as the store of Db at Instance. A directory from before markers existed is the current instance's (its name is the live instance id) and is marked.

Types

store/0

-type store() :: #{ref := rocksdb:db_handle(), env := term(), dir := string()}.

Functions

bytes(_)

-spec bytes(store()) -> non_neg_integer().

Bytes the store's files take on disk.

clean_db_dir(Db, Keep)

-spec clean_db_dir(binary(), binary() | none) -> ok.

Remove the instance directories of Db other than Keep: only those whose marker names this database and their own instance. Anything else under the database's directory stays and is logged. The database's directory goes too once it is empty.

close(_)

-spec close(store()) -> ok.

db_dir(Db)

-spec db_dir(binary()) -> string().

db_name(Hex)

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

delete_range(_, Lower, Upper)

-spec delete_range(store(), binary(), binary()) -> ok | {error, term()}.

fold(_, Lower, Upper, Fun, Acc0, Snapshot)

-spec fold(store(), binary(), binary(), fun(), term(), rocksdb:snapshot_handle() | undefined) -> term().

Fold [Lower, Upper) in key order, optionally under a snapshot. Fun(Key, Value, Acc) -> {ok, Acc} | {stop, Acc}.

get(_, Key)

-spec get(store(), binary()) -> {ok, binary()} | not_found | {error, term()}.

get(_, Key, Snapshot)

-spec get(store(), binary(), rocksdb:snapshot_handle()) -> {ok, binary()} | not_found | {error, term()}.

instance_dir(Db, Instance)

-spec instance_dir(binary(), binary()) -> string().

mark(Db, Instance)

-spec mark(binary(), binary()) -> ok.

Create the instance directory if needed and mark it as the store of Db at Instance. A directory from before markers existed is the current instance's (its name is the live instance id) and is marked.

multi_get(Store, Keys)

-spec multi_get(store(), [binary()]) -> [{ok, binary()} | not_found | {error, term()}].

open(Dir, Env)

-spec open(string(), default | term()) -> {ok, store()} | {error, term()}.

release(Snapshot)

-spec release(rocksdb:snapshot_handle()) -> ok.

root()

-spec root() -> string().

snapshot(_)

-spec snapshot(store()) -> {ok, rocksdb:snapshot_handle()} | {error, term()}.

write(Store, Ops)

-spec write(store(),
            [{put, binary(), binary()} | {delete, binary()} | {delete_range, binary(), binary()}]) ->
               ok | {error, term()}.