diff --git a/doc/index.html b/doc/index.html deleted file mode 100644 index aee6928..0000000 --- a/doc/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - -
-Behaviours: gen_server, mnesia_backend_type.
- -rocksdb storage backend for Mnesia.
- - This module implements a mnesia backend callback plugin. - It's specifically documented to try to explain the workings of - backend plugins. - -alias() = atom()
- - -data_tab() = atom()
- - -error() = {error, any()}
- - -index_info() = {index_pos(), index_type()}
- - -index_pos() = integer() | {atom()}
- - -index_tab() = {data_tab(), index, index_info()}
- - -index_type() = ordered
- - -retainer_name() = any()
- - -retainer_tab() = {data_tab(), retainer, retainer_name()}
- - -table() = data_tab() | index_tab() | retainer_tab()
- - -table_type() = set | ordered_set | bag
- - -add_aliases(Aliases) -> any()
--
check_definition(Alias, Tab, Nodes, Props) -> any()
--
close_table(Alias, Tab) -> any()
--
code_change(FromVsn, St, Extra) -> any()
--
create_schema(Nodes) -> any()
--
create_schema(Nodes, Aliases) -> any()
--
create_table(Alias, Tab, Props) -> any()
--
decode_key(Key) -> any()
--
decode_key(Key, Metadata) -> any()
--
decode_val(Val) -> any()
--
decode_val(Val, Key, Metadata) -> any()
--
default_alias() -> any()
--
delete(Alias, Tab, Key) -> any()
--
delete_table(Alias, Tab) -> any()
--
encode_key(Key) -> any()
--
encode_key(Key, Metadata) -> any()
--
encode_val(Val) -> any()
--
encode_val(Val, Metadata) -> any()
--
first(Alias, Tab) -> any()
--
fixtable(Alias, Tab, Bool) -> any()
--
handle_call(M, From, St) -> any()
--
handle_cast(X1, St) -> any()
--
handle_info(EXIT, St) -> any()
--
index_is_consistent(Alias, X2, Bool) -> any()
--
info(Alias, Tab, Item) -> any()
--
init(X1) -> any()
--
init_backend() -> any()
--
Called by mnesia_schema in order to intialize the backend
- -This is called when the backend is registered with the first alias, or ...
- -See OTP issue #425 (16 Feb 2021). This callback is supposed to be called -before first use of the backend, but unfortunately, it is only called at -mnesia startup and when a backend module is registered MORE THAN ONCE. -This means we need to handle this function being called multiple times.
- -The bug has been fixed as of OTP 24.0-rc3
- -If processes need to be started, this can be done using
- mnesia_ext_sup:start_proc(Name, Mod, F, Args [, Opts])
-where Opts are parameters for the supervised child:
restart
(default: transient
)
- * shutdown
(default: 120000
)
- * type
(default: worker
)
- * modules
(default: [Mod]
)
-
-insert(Alias, Tab, Obj) -> any()
--
is_index_consistent(Alias, X2) -> any()
--
ix_listvals(Tab, Pos, Obj) -> any()
--
ix_prefixes(Tab, Pos, Obj) -> any()
--
last(Alias, Tab) -> any()
--
load_table(Alias, Tab, LoadReason, Props) -> any()
--
lookup(Alias, Tab, Key) -> any()
--
match_delete(Alias, Tab, Pat) -> any()
--
next(Alias, Tab, Key) -> any()
--
prev(Alias, Tab, Key) -> any()
--
real_suffixes() -> any()
--
receive_data(Data, Alias, Tab, Sender, State) -> any()
--
receive_done(Alias, Tab, Sender, State) -> any()
--
receiver_first_message(Pid, Msg, Alias, Tab) -> any()
--
register() -> {ok, alias()} | {error, term()}
-
Equivalent to register(rocksdb_copies).
- - -Convenience function for registering a mnesia_rocksdb backend plugin
- - The function used to register a plugin ismnesia_schema:add_backend_type(Alias, Module)
- where Module
implements a backend_type behavior. Alias
is an atom, and is used
- in the same way as ram_copies
etc. The default alias is rocksdb_copies
.
-
-remove_aliases(Aliases) -> any()
--
repair_continuation(Cont, Ms) -> any()
--
select(Cont) -> any()
--
select(Alias, Tab, Ms) -> any()
--
select(Alias, IxTab, Ms, Limit) -> any()
--
semantics(Alias, X2) -> any()
--
sender_handle_info(Msg, Alias, Tab, ReceiverPid, Cont) -> any()
--
sender_init(Alias, Tab, RemoteStorage, Pid) -> any()
--
show_table(Tab) -> any()
--
A debug function that shows the rocksdb table content
- -show_table(Tab, Limit) -> any()
--
slot(Alias, Tab, Pos) -> any()
--
start_proc(Alias, Tab, Type, ProcName, Props, RdbOpts) -> any()
--
sync_close_table(Alias, Tab) -> any()
--
terminate(Reason, St) -> any()
--
tmp_suffixes() -> any()
--
update_counter(Alias, Tab, C, Val) -> any()
--
validate_key(Alias, Tab, RecName, Arity, Type, Key) -> any()
--
validate_record(Alias, Tab, RecName, Arity, Type, Obj) -> any()
--
Generated by EDoc
- - diff --git a/doc/mnesia_rocksdb_admin.html b/doc/mnesia_rocksdb_admin.html deleted file mode 100644 index 82dd924..0000000 --- a/doc/mnesia_rocksdb_admin.html +++ /dev/null @@ -1,294 +0,0 @@ - - - - -Behaviours: gen_server.
- -alias() = atom()
- - -backend() = #{db_ref := db_ref(), cf_info := #{table() := cf()}}
- - -cf() = mrdb:db_ref()
- - -db_ref() = rocksdb:db_handle()
- - -gen_server_noreply() = {noreply, st()} | {stop, reason(), st()}
- - -gen_server_reply() = {reply, reply(), st()} | {stop, reason(), reply(), st()}
- - -properties() = [{atom(), any()}]
- - -reason() = any()
- - -reply() = any()
- - -req() = {create_table, table(), properties()} | {delete_table, table()} | {load_table, table(), properties()} | {related_resources, table()} | {get_ref, table()} | {add_aliases, [alias()]} | {write_table_property, tabname(), tuple()} | {remove_aliases, [alias()]} | {migrate, [{tabname(), map()}], rpt()} | {prep_close, table()} | {close_table, table()} | {clear_table, table() | cf()}
- - -rpt() = undefined | map()
- - -st() = #st{backends = #{alias() => backend()}, standalone = #{{alias(), table()} := cf()}, default_opts = [{atom(), term()}]}
- - -table() = tabname() | {admin, alias()} | {tabname(), index, any()} | {tabname(), retainer, any()}
- - -tabname() = atom()
- - -add_aliases(Aliases) -> any()
--
clear_table(Name) -> any()
--
close_table(Alias, Name) -> any()
--
code_change(FromVsn, St, Extra) -> any()
--
create_table(Alias, Name, Props) -> any()
--
ensure_started() -> ok
-
get_cached_env(Key, Default) -> any()
--
get_ref(Name) -> any()
--
get_ref(Name, Default) -> any()
--
handle_call(Req::{alias(), req()}, From::any(), St::st()) -> gen_server_reply()
-
handle_cast(Msg::any(), St::st()) -> gen_server_noreply()
-
handle_info(Msg::any(), St::st()) -> gen_server_noreply()
-
init(X1) -> any()
--
load_table(Alias, Name, Props) -> any()
--
meta() -> any()
--
migrate_standalone(Alias, Tabs) -> any()
--
migrate_standalone(Alias, Tabs, Rpt0) -> any()
--
prep_close(Alias, Tab) -> any()
--
read_info(TRec) -> any()
--
read_info(Alias, Tab) -> any()
--
read_info(Alias, Tab, K, Default) -> any()
--
related_resources(Alias, Name) -> any()
--
remove_aliases(Aliases) -> any()
--
request_ref(Alias, Name) -> any()
--
set_and_cache_env(Key, Value) -> any()
--
start_link() -> any()
--
terminate(X1, St) -> any()
--
write_info(Alias, Tab, K, V) -> any()
--
write_table_property(Alias, Tab, Prop) -> any()
--
Generated by EDoc
- - diff --git a/doc/mnesia_rocksdb_app.html b/doc/mnesia_rocksdb_app.html deleted file mode 100644 index bd763b9..0000000 --- a/doc/mnesia_rocksdb_app.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - -Behaviours: application.
- -start/2 | |
stop/1 |
start(StartType, StartArgs) -> any()
--
stop(State) -> any()
--
Generated by EDoc
- - diff --git a/doc/mnesia_rocksdb_lib.html b/doc/mnesia_rocksdb_lib.html deleted file mode 100644 index 5f6a873..0000000 --- a/doc/mnesia_rocksdb_lib.html +++ /dev/null @@ -1,181 +0,0 @@ - - - - -check_encoding(Encoding, Attributes) -> any()
--
create_mountpoint(Tab) -> any()
--
data_mountpoint(Tab) -> any()
--
decode(Val, X2) -> any()
--
decode_key(CodedKey::binary()) -> any()
-
decode_key(CodedKey, Enc) -> any()
--
decode_val(CodedVal::binary()) -> any()
-
decode_val(CodedVal, K, Ref) -> any()
--
default_encoding(X1, Type, As) -> any()
--
delete(Ref, K, Opts) -> any()
--
encode(Value, X2) -> any()
--
encode_key(Key::any()) -> binary()
-
encode_key(Key, X2) -> any()
--
encode_val(Val::any()) -> binary()
-
encode_val(Val, Enc) -> any()
--
keypos(Tab) -> any()
--
open_rocksdb(MPd, RdbOpts, CFs) -> any()
--
put(Ref, K, V, Opts) -> any()
--
tabname(Tab) -> any()
--
valid_key_type(X1, Key) -> any()
--
valid_obj_type(X1, Obj) -> any()
--
write(X1, L, Opts) -> any()
--
Generated by EDoc
- - diff --git a/doc/mnesia_rocksdb_params.html b/doc/mnesia_rocksdb_params.html deleted file mode 100644 index 087b8ae..0000000 --- a/doc/mnesia_rocksdb_params.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - -Behaviours: gen_server.
- -code_change/3 | |
delete/1 | |
handle_call/3 | |
handle_cast/2 | |
handle_info/2 | |
init/1 | |
lookup/2 | |
start_link/0 | |
store/2 | |
terminate/2 |
code_change(X1, S, X3) -> any()
--
delete(Tab) -> any()
--
handle_call(X1, X2, S) -> any()
--
handle_cast(X1, S) -> any()
--
handle_info(X1, S) -> any()
--
init(X1) -> any()
--
lookup(Tab, Default) -> any()
--
start_link() -> any()
--
store(Tab, Params) -> any()
--
terminate(X1, X2) -> any()
--
Generated by EDoc
- - diff --git a/doc/mnesia_rocksdb_sup.html b/doc/mnesia_rocksdb_sup.html deleted file mode 100644 index 4a4d957..0000000 --- a/doc/mnesia_rocksdb_sup.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - -Behaviours: supervisor.
- -init/1 | |
start_link/0 |
init(X1) -> any()
--
start_link() -> any()
--
Generated by EDoc
- - diff --git a/doc/mnesia_rocksdb_tuning.html b/doc/mnesia_rocksdb_tuning.html deleted file mode 100644 index 1f31903..0000000 --- a/doc/mnesia_rocksdb_tuning.html +++ /dev/null @@ -1,151 +0,0 @@ - - - - -cache(X1) -> any()
--
calc_sizes() -> any()
--
calc_sizes(D) -> any()
--
count_rdb_tabs() -> any()
--
count_rdb_tabs(Db) -> any()
--
default(X1) -> any()
--
describe_env() -> any()
--
get_avail_ram() -> any()
--
get_maxfiles() -> any()
--
get_maxfiles(X1) -> any()
--
ideal_max_files() -> any()
--
ideal_max_files(D) -> any()
--
max_files(X1) -> any()
--
rdb_indexes() -> any()
--
rdb_indexes(Db) -> any()
--
rdb_tabs() -> any()
--
rdb_tabs(Db) -> any()
--
write_buffer(X1) -> any()
--
Generated by EDoc
- - diff --git a/doc/modules-frame.html b/doc/modules-frame.html deleted file mode 100644 index bebffb0..0000000 --- a/doc/modules-frame.html +++ /dev/null @@ -1,24 +0,0 @@ - - - -Mid-level access API for Mnesia-managed rocksdb tables
- -This module implements access functions for the mnesia_rocksdb -backend plugin. The functions are designed to also support -direct access to rocksdb with little overhead. Such direct -access will maintain existing indexes, but not support -replication.
- -Each table has a metadata structure stored as a persistent -term for fast access. The structure of the metadata is as -follows:
- -#{ name := <Logical table name> - , db_ref := <Rocksdb database Ref> - , cf_handle := <Rocksdb column family handle> - , activity := Ongoing batch or transaction, if any (map()) - , attr_pos := #{AttrName := Pos} - , mode := <Set to 'mnesia' for mnesia access flows> - , properties := <Mnesia table props in map format> - , type := column_family | standalone - }- -
Helper functions like as_batch(Ref, fun(R) -> ... end)
and
- with_iterator(Ref, fun(I) -> ... end)
add some extra
- convenience on top of the rocksdb
API.
mrdb
updates will
- not be replicated.
-activity() = tx_activity() | batch_activity()
- - -activity_type() = mrdb_activity_type() | mnesia_activity_type()
- - -admin_tab() = {admin, alias()}
- - -alias() = atom()
- - -attr_pos() = #{atom() := pos()}
- - -batch_activity() = #{type := batch, handle := batch_handle()}
- - -batch_handle() = rocksdb:batch_handle()
- - -cf_handle() = rocksdb:cf_handle()
- - -db_handle() = rocksdb:db_handle()
- - -db_ref() = #{name => table(), alias => atom(), vsn => non_neg_integer(), db_ref := db_handle(), cf_handle := cf_handle(), semantics := semantics(), encoding := encoding(), attr_pos := attr_pos(), type := column_family | standalone, status := open | closed | pre_existing, properties := properties(), mode => mnesia, ix_vals_f => fun((tuple()) -> [any()]), activity => activity(), term() => term()}
- - -encoding() = raw | sext | term | {key_encoding(), val_encoding()}
- - -error() = {error, any()}
- - -index() = {tab_name(), index, any()}
- - -index_position() = atom() | pos()
- - -inner() = non_neg_integer()
- - -iterator_action() = first | last | next | prev | binary() | {seek, binary()} | {seek_for_prev, binary()}
- - -itr_handle() = rocksdb:itr_handle()
- - -key() = any()
- - -key_encoding() = raw | sext | term
- - -mnesia_activity_type() = transaction | sync_transaction | async_dirty | sync_dirty
- - -mrdb_activity_type() = tx | {tx, tx_options()} | batch
- - -mrdb_iterator() = #mrdb_iter{i = itr_handle(), ref = db_ref()}
- - -obj() = tuple()
- - -outer() = non_neg_integer()
- - -pos() = non_neg_integer()
- - -properties() = #{record_name := atom(), attributes := [atom()], index := [{pos(), bag | ordered}]}
- - -read_options() = [{verify_checksums, boolean()} | {fill_cache, boolean()} | {iterate_upper_bound, binary()} | {iterate_lower_bound, binary()} | {tailing, boolean()} | {total_order_seek, boolean()} | {prefix_same_as_start, boolean()} | {snapshot, snapshot_handle()}]
- - -ref_or_tab() = table() | db_ref()
- - -retainer() = {tab_name(), retainer, any()}
- - -retries() = outer() | {inner(), outer()}
- - -semantics() = bag | set
- - -snapshot_handle() = rocksdb:snapshot_handle()
- - -tab_name() = atom()
- - -table() = atom() | admin_tab() | index() | retainer()
- - -tx_activity() = #{type := tx, handle := tx_handle(), attempt := undefined | retries()}
- - -tx_handle() = rocksdb:transaction_handle()
- - -tx_options() = #{retries => retries(), no_snapshot => boolean()}
- - -val_encoding() = {value | object, term | raw} | raw
- - -write_options() = [{sync, boolean()} | {disable_wal, boolean()} | {ignore_missing_column_families, boolean()} | {no_slowdown, boolean()} | {low_pri, boolean()}]
- - -abort(Reason) -> any()
--
Aborts an ongoing activity/2
activity(Type::activity_type(), Alias::alias(), F::fun(() -> Res)) -> Res
-
Run an activity (similar to //mnesia/mnesia:activity/2
).
transaction
- An optimistic rocksdb
transaction{tx, TxOpts}
- A rocksdb
transaction with sligth modificationsbatch
- A rocksdb
batch operationBy default, transactions are combined with a snapshot with 1 retry.
- The snapshot ensures that writes from concurrent transactions don't leak into the transaction context.
- A transaction will be retried if it detects that the commit set conflicts with recent changes.
- A mutex is used to ensure that only one of potentially conflicting mrdb
transactions is run at a time.
-The re-run transaction may still fail, if new transactions, or non-transaction writes interfere with
-the commit set. It will then be re-run again, until the retry count is exhausted.
For finer-grained retries, it's possible to set retries => {Inner, Outer}
. Setting the retries to a
- single number, Retries
, is analogous to {0, Retries}`. Each outer retry requests a
mutex lock' by
- waiting in a FIFO queue. Once it receives the lock, it will try the activity once + as many retries
- as specified by Inner
. If these fail, the activity again goes to the FIFO queue (ending up last
- in line) if there are outer retries remaining. When all retries are exhaused, the activity aborts
- with retry_limit
. Note that transactions, being optimistic, do not request a lock on the first
-attempt, but only on outer retries (the first retry is always an outer retry).
Valid TxOpts
are #{no_snapshot => boolean(), retries => retries()}
.
tx | transaction | sync_transaction
are synonyms, and
- batch | async_dirty | sync_dirty
are synonyms.
-
-alias_of(Tab::ref_or_tab()) -> alias()
-
Returns the alias of a given table or table reference.
- -as_batch(Tab::ref_or_tab(), F::fun((db_ref()) -> Res)) -> Res
-
Creates a rocksdb
batch context and executes the fun F
in it.
as_batch(Tab, F, Opts) -> any()
--
as as_batch/2
, but with the ability to pass Opts
to rocksdb:write_batch/2
batch_write(Tab, L) -> any()
--
batch_write(Tab, L, Opts) -> any()
--
clear_table(Tab) -> any()
--
current_context() -> any()
--
delete(Tab::ref_or_tab(), Key::key()) -> ok
-
delete(Tab::ref_or_tab(), Key::key(), Opts::write_options()) -> ok
-
delete_object(Tab, Obj) -> any()
--
delete_object(Tab, Obj, Opts) -> any()
--
ensure_ref(R::ref_or_tab()) -> db_ref()
-
ensure_ref(Ref, R) -> any()
--
first(Tab::ref_or_tab()) -> key() | '$end_of_table'
-
first(Tab::ref_or_tab(), Opts::read_options()) -> key() | '$end_of_table'
-
fold(Tab, Fun, Acc) -> any()
--
fold(Tab, Fun, Acc, MatchSpec) -> any()
--
fold(Tab, Fun, Acc, MatchSpec, Limit) -> any()
--
get_batch(X1) -> any()
--
index_read(Tab, Val, Ix) -> any()
--
insert(Tab::ref_or_tab(), Obj::obj()) -> ok
-
insert(Tab::ref_or_tab(), Obj0::obj(), Opts::write_options()) -> ok
-
iterator(Tab::ref_or_tab()) -> {ok, mrdb_iterator()} | {error, term()}
-
iterator(Tab::ref_or_tab(), Opts::read_options()) -> {ok, mrdb_iterator()} | {error, term()}
-
iterator_close(Mrdb_iter::mrdb_iterator()) -> ok
-
iterator_move(Mrdb_iter::mrdb_iterator(), Dir::iterator_action()) -> {ok, tuple()} | {error, any()}
-
last(Tab::ref_or_tab()) -> key() | '$end_of_table'
-
last(Tab::ref_or_tab(), Opts::read_options()) -> key() | '$end_of_table'
-
match_delete(Tab, Pat) -> any()
--
new_tx(Tab::ref_or_tab(), Opts::write_options()) -> db_ref()
-
next(Tab::ref_or_tab(), K::key()) -> key() | '$end_of_table'
-
next(Tab::ref_or_tab(), K::key(), Opts::read_options()) -> key() | '$end_of_table'
-
prev(Tab::ref_or_tab(), K::key()) -> key() | '$end_of_table'
-
prev(Tab::ref_or_tab(), K::key(), Opts::read_options()) -> key() | '$end_of_table'
-
rdb_delete(R, K) -> any()
--
rdb_delete(R, K, Opts) -> any()
--
rdb_fold(Tab, Fun, Acc, Prefix) -> any()
--
rdb_fold(Tab, Fun, Acc, Prefix, Limit) -> any()
--
rdb_get(R, K) -> any()
--
rdb_get(R, K, Opts) -> any()
--
rdb_iterator(R) -> any()
--
rdb_iterator(R, Opts) -> any()
--
rdb_iterator_move(I, Dir) -> any()
--
rdb_put(R, K, V) -> any()
--
rdb_put(R, K, V, Opts) -> any()
--
read(Tab, Key) -> any()
--
read(Tab, Key, Opts) -> any()
--
read_info(Tab) -> any()
--
read_info(Tab, K) -> any()
--
release_snapshot(SHandle::snapshot_handle()) -> ok | error()
-
release a snapshot created by snapshot/1
.
select(Cont) -> any()
--
select(Tab, Pat) -> any()
--
select(Tab, Pat, Limit) -> any()
--
snapshot(Name::alias() | ref_or_tab()) -> {ok, snapshot_handle()} | error()
-
Create a snapshot of the database instance associated with the -table reference, table name or alias.
- - Snapshots provide consistent read-only views over the entire state of the key-value store. - -tx_commit(TxH::tx_handle() | db_ref()) -> ok
-
tx_ref(Tab::ref_or_tab() | db_ref() | db_ref(), TxH::tx_handle()) -> db_ref()
-
update_counter(Tab, C, Val) -> any()
--
update_counter(Tab, C, Val, Opts) -> any()
--
with_iterator(Tab::ref_or_tab(), Fun::fun((mrdb_iterator()) -> Res)) -> Res
-
with_iterator(Tab::ref_or_tab(), Fun::fun((mrdb_iterator()) -> Res), Opts::read_options()) -> Res
-
with_rdb_iterator(Tab::ref_or_tab(), Fun::fun((itr_handle()) -> Res)) -> Res
-
with_rdb_iterator(Tab::ref_or_tab(), Fun::fun((itr_handle()) -> Res), Opts::read_options()) -> Res
-
write_info(Tab, K, V) -> any()
--
Generated by EDoc
- - diff --git a/doc/mrdb_index.html b/doc/mrdb_index.html deleted file mode 100644 index 7603753..0000000 --- a/doc/mrdb_index.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - -index_value() = any()
- - -iterator_action() = mrdb:iterator_action()
- - -ix_iterator() = #mrdb_ix_iter{i = mrdb:iterator(), type = set | bag, sub = mrdb:ref() | pid()}
- - -object() = tuple()
- - -iterator/2 | |
iterator_close/1 | |
iterator_move/2 | |
with_iterator/3 |
iterator(Tab::mrdb:ref_or_tab(), IxPos::mrdb:index_position()) -> {ok, ix_iterator()} | {error, term()}
-
iterator_close(Mrdb_ix_iter::ix_iterator()) -> ok
-
iterator_move(Mrdb_ix_iter::ix_iterator(), Dir::iterator_action()) -> {ok, index_value(), object()} | {error, term()}
-
with_iterator(Tab::mrdb:ref_or_tab(), IxPos::mrdb:index_position(), Fun::fun((ix_iterator()) -> Res)) -> Res
-
Generated by EDoc
- - diff --git a/doc/mrdb_mutex.html b/doc/mrdb_mutex.html deleted file mode 100644 index cb6e597..0000000 --- a/doc/mrdb_mutex.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - -do/2 |
do(Rsrc, F) -> any()
--
Generated by EDoc
- - diff --git a/doc/mrdb_mutex_serializer.html b/doc/mrdb_mutex_serializer.html deleted file mode 100644 index 8e07aa4..0000000 --- a/doc/mrdb_mutex_serializer.html +++ /dev/null @@ -1,88 +0,0 @@ - - - - -code_change/3 | |
done/2 | |
handle_call/3 | |
handle_cast/2 | |
handle_info/2 | |
init/1 | |
start_link/0 | |
terminate/2 | |
wait/1 |
code_change(FromVsn, St, Extra) -> any()
--
done(Rsrc, Ref) -> any()
--
handle_call(X1, From, St) -> any()
--
handle_cast(X1, St) -> any()
--
handle_info(X1, St) -> any()
--
init(X1) -> any()
--
start_link() -> any()
--
terminate(X1, X2) -> any()
--
wait(Rsrc) -> any()
--
Generated by EDoc
- - diff --git a/doc/mrdb_select.html b/doc/mrdb_select.html deleted file mode 100644 index 9acf856..0000000 --- a/doc/mrdb_select.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - -continuation_info/2 | |
fold/5 | |
rdb_fold/5 | |
select/1 | |
select/3 | |
select/4 |
continuation_info(Item, C) -> any()
--
fold(Ref, Fun, Acc, MS, Limit) -> any()
--
rdb_fold(Ref, Fun, Acc, Prefix, Limit) -> any()
--
select(Cont) -> any()
--
select(Ref, MS, Limit) -> any()
--
select(Ref, MS, AccKeys, Limit) -> any()
--
Generated by EDoc
- - diff --git a/doc/mrdb_stats.html b/doc/mrdb_stats.html deleted file mode 100644 index b4220fd..0000000 --- a/doc/mrdb_stats.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - -Statistics API for the mnesia_rocksdb plugin
- - Some counters are maintained for each active alias. Currently, the following - counters are supported: - * inner_retries - * outer_retries - -alias() = mnesia_rocksdb:alias()
- - -counter() = atom()
- - -counters() = #{counter() := integer()}
- - -db_ref() = mrdb:db_ref()
- - -increment() = integer()
- - -get/1 | Fetches all known counters for Alias , in the form of a map,
- #{Counter => Value} . |
get/2 | Fetches the integer value of the known counter Ctr for Alias . |
incr/3 | Increment Ctr counter for Alias` with increment `N . |
new/0 |
get(Alias::alias() | db_ref()) -> counters()
-
Fetches all known counters for Alias
, in the form of a map,
- #{Counter => Value}
.
Fetches the integer value of the known counter Ctr
for Alias
.
incr(Alias::alias() | db_ref(), Ctr::counter(), N::increment()) -> ok
-
Increment Ctr
counter for Alias` with increment `N
.
db_ref()
map,
- corresponding to mrdb:get_ref({admin, Alias})
.
-
-new() -> any()
--
Generated by EDoc
- - diff --git a/doc/overview-summary.html b/doc/overview-summary.html deleted file mode 100644 index 328774c..0000000 --- a/doc/overview-summary.html +++ /dev/null @@ -1,254 +0,0 @@ - - - - -Copyright © 2013-21 Klarna AB
-Authors: Ulf Wiger (ulf@wiger.net).
- - -The Mnesia DBMS, part of Erlang/OTP, supports 'backend plugins', making
-it possible to utilize more capable key-value stores than the dets
-module (limited to 2 GB per table). Unfortunately, this support is
-undocumented. Below, some informal documentation for the plugin system
-is provided.
Call mnesia_rocksdb:register()
immediately after
-starting mnesia.
Put {rocksdb_copies, [node()]}
into the table definitions of
-tables you want to be in RocksDB.
RocksDB tables support efficient selects on prefix keys.
- -The backend uses the sext
module (see
-https://github.com/uwiger/sext) for mapping between Erlang terms and the
-binary data stored in the tables. This provides two useful properties:
{x, '_'}
is a prefix for keys {x, a}
,
- {x, b}
and so on.This means that a prefix key identifies the start of the sequence of -entries whose keys match the prefix. The backend uses this to optimize -selects on prefix keys.
- -### Customization
- -RocksDB supports a number of customization options. These can be specified
-by providing a {Key, Value}
list named rocksdb_opts
under user_properties
,
-for example:
mnesia:create_table(foo, [{rocksdb_copies, [node()]}, - ... - {user_properties, - [{rocksdb_opts, [{max_open_files, 1024}]}] - }])- -
Consult the RocksDB documentation -for information on configuration parameters. Also see the section below on handling write errors.
- -The default configuration for tables inmnesia_rocksdb
is:
-default_open_opts() -> - [ {create_if_missing, true} - , {cache_size, - list_to_integer(get_env_default("ROCKSDB_CACHE_SIZE", "32212254"))} - , {block_size, 1024} - , {max_open_files, 100} - , {write_buffer_size, - list_to_integer(get_env_default( - "ROCKSDB_WRITE_BUFFER_SIZE", "4194304"))} - , {compression, - list_to_atom(get_env_default("ROCKSDB_COMPRESSION", "true"))} - , {use_bloomfilter, true} - ].- -
It is also possible, for larger databases, to produce a tuning parameter file.
-This is experimental, and mostly copied from mnesia_leveldb
. Consult the
-source code in mnesia_rocksdb_tuning.erl
and mnesia_rocksdb_params.erl
.
-Contributions are welcome.
Avoid placing bag
tables in RocksDB. Although they work, each write
-requires additional reads, causing substantial runtime overheads. There
-are better ways to represent and process bag data (see above about
-prefix keys).
The mnesia:table_info(T, size)
call always returns zero for RocksDB
-tables. RocksDB itself does not track the number of elements in a table, and
-although it is possible to make the mnesia_rocksdb
backend maintain a size
-counter, it incurs a high runtime overhead for writes and deletes since it
-forces them to first do a read to check the existence of the key. If you
-depend on having an up to date size count at all times, you need to maintain
-it yourself. If you only need the size occasionally, you may traverse the
-table to count the elements.
Mnesia was initially designed to be a RAM-only DBMS, and Erlang's
-ets
tables were developed for this purpose. In order to support
-persistence, e.g. for configuration data, a disk-based version of ets
-(called dets
) was created. The dets
API mimicks the ets
API,
-and dets
is quite convenient and fast for (nowadays) small datasets.
-However, using a 32-bit bucket system, it is limited to 2GB of data.
-It also doesn't support ordered sets. When used in Mnesia, dets-based
-tables are called disc_only_copies
.
To circumvent these limitations, another table type, called disc_copies
-was added. This is a combination of ets
and disk_log
, where Mnesia
-periodically snapshots the ets
data to a log file on disk, and meanwhile
-maintains a log of updates, which can be applied at startup. These tables
-are quite performant (especially on read access), but all data is kept in
-RAM, which can become a serious limitation.
A backend plugin system was proposed by Ulf Wiger in 2016, and further -developed with Klarna's support, to finally become included in OTP 19. -Klarna uses a LevelDb backend, but Aeternity, in 2017, instead chose -to implement a Rocksdb backend plugin.
- -As backend plugins were added on a long-since legacy-stable Mnesia,
-they had to conform to the existing code structure. For this reason,
-the plugin callbacks hook into the already present low-level access
-API in the mnesia_lib
module. As a consequence, backend plugins have
-the same access semantics and granularity as ets
and dets
. This
-isn't much of a disadvantage for key-value stores like LevelDb and RocksDB,
-but a more serious issue is that the update part of this API is called
-on after the point of no return. That is, Mnesia does not expect
-these updates to fail, and has no recourse if they do. As an aside,
-this could also happen if a disc_only_copies
table exceeds the 2 GB
-limit (mnesia will not check it, and dets
will not complain, but simply
-drop the update.)
When adding support for backend plugins, index plugins were also added. Unfortunately, they remain undocumented.
- -An index plugin can be added in one of two ways:
- -{index_plugins, [{Name, Module, Function}]}
options.mnesia_schema:add_index_plugin(Name, Module, Function)
Name
must be an atom wrapped as a 1-tuple, e.g. {words}
.
The plugin callback is called as Module:Function(Table, Pos, Obj)
, where Pos=={words}
in
-our example. It returns a list of index terms.
Example
- -Given the following index plugin implementation:
- --module(words). --export([words_f/3]). - -words_f(_,_,Obj) when is_tuple(Obj) -> - words_(tuple_to_list(Obj)). - -words_(Str) when is_binary(Str) -> - string:lexemes(Str, [$\s, $\n, [$\r,$\n]]); -words_(L) when is_list(L) -> - lists:flatmap(fun words_/1, L); -words_(_) -> - [].- -
We can register the plugin and use it in table definitions:
- -Eshell V12.1.3 (abort with ^G) -1> mnesia:start(). -ok -2> mnesia_schema:add_index_plugin({words}, words, words_f). -{atomic,ok} -3> mnesia:create_table(i, [{index, [{words}]}]). -{atomic,ok}- -
Note that in this case, we had neither a backend plugin, nor even a persistent schema. -Index plugins can be used with all table types. The registered indexing function (arity 3) must exist -as an exported function along the node's code path.
- -To see what happens when we insert an object, we can turn on call trace.
- -4> dbg:tracer(). -{ok,<0.108.0>} -5> dbg:tp(words, x). -{ok,[{matched,nonode@nohost,3},{saved,x}]} -6> dbg:p(all,[c]). -{ok,[{matched,nonode@nohost,60}]} -7> mnesia:dirty_write({i,<<"one two">>, [<<"three">>, <<"four">>]}). -(<0.84.0>) call words:words_f(i,{words},{i,<<"one two">>,[<<"three">>,<<"four">>]}) -(<0.84.0>) returned from words:words_f/3 -> [<<"one">>,<<"two">>,<<"three">>, - <<"four">>] -(<0.84.0>) call words:words_f(i,{words},{i,<<"one two">>,[<<"three">>,<<"four">>]}) -(<0.84.0>) returned from words:words_f/3 -> [<<"one">>,<<"two">>,<<"three">>, - <<"four">>] -ok -8> dbg:ctp('_'), dbg:stop(). -ok -9> mnesia:dirty_index_read(i, <<"one">>, {words}). -[{i,<<"one two">>,[<<"three">>,<<"four">>]}]- -
(The fact that the indexing function is called twice, seems like a performance bug.)
- -We can observe that the indexing callback is able to operate on the whole object. -It needs to be side-effect free and efficient, since it will be called at least once for each update -(if an old object exists in the table, the indexing function will be called on it too, before it is -replaced by the new object.)
- -Generated by EDoc
- -