
Expose low-level helpers, fix dialyzer warnings WIP column families and mrdb API Basic functionality in place started adding documentation remove doc/ from .gitignore add doc/* files recognize pre-existing tabs at startup wip: most of the functionality in place (not yet merge ops) wip: adding transaction support wip: add transaction test case (currently dumps core) First draft, mnesia plugin user guide Fix note formatting WIP working on indexing Index iterators, dialyzer, xref fixes open db with optimistic transactions Use rocksdb-1.7.0 Use seanhinde rocksdb patch, enable rollback Call the right transaction_get() function WIP add 'snap_tx' activity type tx restart using mrdb_mutex Fix test suite sync bugs WIP instrumented for debugging WIP working on migration test case Add migration test suite Migration works, subscribe to schema changes WIP fix batch handling Manage separate batches per db_ref Add mrdb:fold/3 Add some docs, erlang_ls config Use seanhinde's rocksdb vsn
76 lines
2.2 KiB
Erlang
76 lines
2.2 KiB
Erlang
%%----------------------------------------------------------------
|
|
%% Copyright (c) 2013-2016 Klarna AB
|
|
%%
|
|
%% This file is provided to you under the Apache License,
|
|
%% Version 2.0 (the "License"); you may not use this file
|
|
%% except in compliance with the License. You may obtain
|
|
%% a copy of the License at
|
|
%%
|
|
%% http://www.apache.org/licenses/LICENSE-2.0
|
|
%%
|
|
%% Unless required by applicable law or agreed to in writing,
|
|
%% software distributed under the License is distributed on an
|
|
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
%% KIND, either express or implied. See the License for the
|
|
%% specific language governing permissions and limitations
|
|
%% under the License.
|
|
%%----------------------------------------------------------------
|
|
|
|
-module(mnesia_rocksdb_tlib).
|
|
|
|
-export([start_mnesia/0,
|
|
start_mnesia/1,
|
|
restart_reset_mnesia/0,
|
|
create_table/1,
|
|
create_table/3,
|
|
trace/2]).
|
|
|
|
restart_reset_mnesia() ->
|
|
mnesia:stop(),
|
|
start_mnesia(reset).
|
|
|
|
start_mnesia() ->
|
|
start_mnesia(false).
|
|
|
|
start_mnesia(Mode) ->
|
|
if Mode==reset ->
|
|
DRes = mnesia:delete_schema([node()]),
|
|
ct:log("Delete schema: ~p", [DRes]),
|
|
CRes = mnesia:create_schema([node()],
|
|
[{backend_types,
|
|
[{rdb,mnesia_rocksdb}]}]),
|
|
ct:log("Create schema: ~p", [CRes]);
|
|
true -> ok
|
|
end,
|
|
SRes = mnesia:start(),
|
|
ct:log("Mnesia start: ~p", [SRes]),
|
|
true = lists:member(rdb, mnesia_schema:backend_types()),
|
|
SRes.
|
|
|
|
create_table(Backend) ->
|
|
create_table(Backend, [k,v], [v]).
|
|
|
|
create_table(Backend, Attrs, Indexes) ->
|
|
mnesia:create_table(t, [{index,Indexes}, {attributes,Attrs},
|
|
{Backend, [node()]}]).
|
|
|
|
trace(F, Ms) ->
|
|
dbg:tracer(),
|
|
[tp(M) || M <- Ms],
|
|
dbg:p(all,[c]),
|
|
try F()
|
|
after
|
|
[ctp(M) || M <- Ms],
|
|
dbg:stop()
|
|
end.
|
|
|
|
tp({l,M} ) -> dbg:tpl(M,x);
|
|
tp({g,M} ) -> dbg:tp(M,x);
|
|
tp({l,M,F}) -> dbg:tpl(M,F,x);
|
|
tp({g,M,F}) -> dbg:tp(M,F,x).
|
|
|
|
ctp({l,M} ) -> dbg:ctpl(M);
|
|
ctp({g,M} ) -> dbg:ctp(M);
|
|
ctp({l,M,F}) -> dbg:ctpl(M,F);
|
|
ctp({g,M,F}) -> dbg:ctp(M,F).
|