diff --git a/rebar.config b/rebar.config index 5bd294c..e480c14 100644 --- a/rebar.config +++ b/rebar.config @@ -26,7 +26,10 @@ , {meck, "0.9.2"} , {trace_runner, {git, "https://github.com/uwiger/trace_runner.git", {ref, "2e56677"}}} - ]} + ]}, + {dialyzer, [{plt_apps, all_deps}, + {base_plt_apps, [erts, kernel, stdlib, mnesia, runtime_tools, eunit, + proper, trace_runner, common_test]}]} ]}, {edown, %% Use as `rebar3 as edown do edoc` diff --git a/src/mnesia_rocksdb_admin.erl b/src/mnesia_rocksdb_admin.erl index 3e5b481..dda1e16 100644 --- a/src/mnesia_rocksdb_admin.erl +++ b/src/mnesia_rocksdb_admin.erl @@ -78,7 +78,7 @@ | {add_aliases, [alias()]} | {write_table_property, tabname(), tuple()} | {remove_aliases, [alias()]} - | {migrate, [{tabname(), map()}], rpt()} + | {migrate, [tabname() | {tabname(), map()}], rpt()} | {prep_close, table()} | {close_table, table()} | {clear_table, table() | cf() }. @@ -272,9 +272,16 @@ delete_info_(Ref, Tab, K) -> write_table_property(Alias, Tab, Prop) when is_tuple(Prop), size(Prop) >= 1 -> call(Alias, {write_table_property, Tab, Prop}). +-spec migrate_standalone(alias(), Tabs) -> Res when + Tabs :: [tabname() | {tabname(),map()}], + Res :: [{tabname(), {ok,any()} | {error, any()}}]. migrate_standalone(Alias, Tabs) -> migrate_standalone(Alias, Tabs, undefined). +-spec migrate_standalone(alias(), Tabs, Rpt) -> Res when + Tabs :: [tabname() | {tabname(),map()}], + Rpt :: 'undefined' | pid() | atom(), + Res :: [{tabname(), {ok,any()} | {error, any()}}]. migrate_standalone(Alias, Tabs, Rpt0) -> Rpt = case Rpt0 of undefined -> undefined; diff --git a/src/mrdb.erl b/src/mrdb.erl index b6b186d..8dc1977 100644 --- a/src/mrdb.erl +++ b/src/mrdb.erl @@ -132,14 +132,15 @@ | sync_dirty. -type tx_options() :: #{ retries => retries() - , no_snapshot => boolean() }. + , no_snapshot => boolean() + , mnesia_compatible => boolean() }. -type mrdb_activity_type() :: tx | {tx, tx_options()} | batch. -type activity_type() :: mrdb_activity_type() | mnesia_activity_type(). -type key() :: any(). -type obj() :: tuple(). --type index_position() :: atom() | pos(). +-type index_position() :: atom() | pos() | plugin_ix_pos(). -type db_handle() :: rocksdb:db_handle(). -type cf_handle() :: rocksdb:cf_handle(). @@ -155,10 +156,14 @@ -type activity() :: tx_activity() | batch_activity(). -type pos() :: non_neg_integer(). +-type plugin_ix_pos() :: {atom()}. +-type propkey() :: any(). +-type propvalue() :: any(). -type properties() :: #{ record_name := atom() , attributes := [atom()] , index := [{pos(), bag | ordered}] + , user_properties => #{propkey() => propvalue()} }. -type semantics() :: bag | set. -type key_encoding() :: 'raw' | 'sext' | 'term'. diff --git a/test/basho_bench_driver_mnesia_rocksdb.erl b/test/basho_bench_driver_mnesia_rocksdb.erl deleted file mode 100644 index a3cf3db..0000000 --- a/test/basho_bench_driver_mnesia_rocksdb.erl +++ /dev/null @@ -1,64 +0,0 @@ -%% ------------------------------------------------------------------- -%% -%% basho_bench: Benchmarking Suite -%% -%% Copyright (c) 2009-2010 Basho Techonologies -%% -%% 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(basho_bench_driver_mnesia_rocksdb). - --export([new/1, - run/4]). - --include("mnesia_rocksdb_basho_bench.hrl"). - -%% ==================================================================== -%% API -%% ==================================================================== - -new(_Id) -> - Type = basho_bench_config:get(backend, ram_copies), - Tab = basho_bench_config:get(mnesia_table, t), - ok = bootstrap_mnesia(Tab, Type), - {ok, Tab}. - -bootstrap_mnesia(Tab, Type) -> - ok = mnesia:create_schema([node()], - [{backend_types, - [{rocksdb_copies, mnesia_rocksdb}]}]), - ok = mnesia:start(), - {atomic,ok} = mnesia:create_table(Tab, [{Type, [node()]}]), - mnesia:wait_for_tables([Tab], 10000). - -run(get, KeyGen, _ValueGen, State) -> - Tab = State, - Key = KeyGen(), - case mnesia:dirty_read({Tab, Key}) of - [] -> - {ok, State}; - [{_, Key, _}] -> - {ok, State} - end; -run(put, KeyGen, ValueGen, State) -> - Tab = State, - ok = mnesia:dirty_write({Tab, KeyGen(), ValueGen()}), - {ok, State}; -run(delete, KeyGen, _ValueGen, State) -> - Tab = State, - ok = mnesia:dirty_delete({Tab, KeyGen()}), - {ok, State}. diff --git a/test/mnesia_rocksdb_SUITE.erl b/test/mnesia_rocksdb_SUITE.erl index 5f84404..da3e337 100644 --- a/test/mnesia_rocksdb_SUITE.erl +++ b/test/mnesia_rocksdb_SUITE.erl @@ -216,6 +216,7 @@ mrdb_transactions_(Config) -> delete_tabs(Created), ok. +-dialyzer(no_return). mrdb_abort_reasons(_Config) -> Prev = mnesia_rocksdb_admin:set_and_cache_env(mnesia_compatible_aborts, true), X = some_value, diff --git a/test/mnesia_rocksdb_basho_bench.hrl b/test/mnesia_rocksdb_basho_bench.hrl deleted file mode 100644 index bb06af3..0000000 --- a/test/mnesia_rocksdb_basho_bench.hrl +++ /dev/null @@ -1,15 +0,0 @@ - --define(FAIL_MSG(Str, Args), ?ERROR(Str, Args), basho_bench_app:halt_or_kill()). --define(STD_ERR(Str, Args), io:format(standard_error, Str, Args)). - --define(CONSOLE(Str, Args), lager:info(Str, Args)). - --define(DEBUG(Str, Args), lager:debug(Str, Args)). --define(INFO(Str, Args), lager:info(Str, Args)). --define(WARN(Str, Args), lager:warning(Str, Args)). --define(ERROR(Str, Args), lager:error(Str, Args)). - --define(FMT(Str, Args), lists:flatten(io_lib:format(Str, Args))). - --define(VAL_GEN_BLOB_CFG, value_generator_blob_file). --define(VAL_GEN_SRC_SIZE, value_generator_source_size). diff --git a/test/mnesia_rocksdb_bench_disc_only.config b/test/mnesia_rocksdb_bench_disc_only.config deleted file mode 100644 index 187bdd0..0000000 --- a/test/mnesia_rocksdb_bench_disc_only.config +++ /dev/null @@ -1,18 +0,0 @@ -{mode, max}. - -{duration, 10}. - -{concurrent, 1}. - -{driver, basho_bench_driver_mnesia_rocksdb}. - -{key_generator, {int_to_bin,{uniform_int, 5000000}}}. - -{value_generator, {fixed_bin, 10000}}. - -{operations, [{get, 2}, {put, 2}, {delete, 1}]}. - -{code_paths, []}. - -{mnesia_table, doc}. -{backend, disc_only_copies}. diff --git a/test/mnesia_rocksdb_bench_rocksdb_copies.config b/test/mnesia_rocksdb_bench_rocksdb_copies.config deleted file mode 100644 index c0bd928..0000000 --- a/test/mnesia_rocksdb_bench_rocksdb_copies.config +++ /dev/null @@ -1,19 +0,0 @@ -{mode, max}. - -{duration, 10}. - -{concurrent, 1}. - -{driver, basho_bench_driver_mnesia_rocksdb}. - -{key_generator, {int_to_bin,{uniform_int, 5000000}}}. - -{value_generator, {fixed_bin, 10000}}. - -{operations, [{get, 2}, {put, 2}, {delete, 1}]}. - -{code_paths, ["/Users/uwiger/git/rocksdb", - "/Users/uwiger/git/mnesia_rocksdb"]}. - -{mnesia_table, rdb}. -{backend, rocksdb_copies}. diff --git a/test/mnesia_rocksdb_conv_bigtab.erl b/test/mnesia_rocksdb_conv_bigtab.erl index c70ea9a..da932ab 100644 --- a/test/mnesia_rocksdb_conv_bigtab.erl +++ b/test/mnesia_rocksdb_conv_bigtab.erl @@ -22,6 +22,7 @@ -record(t, {k, i, v}). +-dialyzer({nowarn_function, run/1}). run(Sz) -> mnesia:stop(), init(), diff --git a/test/mnesia_rocksdb_fallback.erl b/test/mnesia_rocksdb_fallback.erl index 11bb116..71b0b7e 100644 --- a/test/mnesia_rocksdb_fallback.erl +++ b/test/mnesia_rocksdb_fallback.erl @@ -79,20 +79,20 @@ cleanup() -> os:cmd("rm *.BUP"). mods(0) -> - []; -mods(1) -> - [ - {l, mnesia_rocksdb}, - {g, rocksdb} - ]; -mods(2) -> - [ - %% {l, mnesia_monitor}, - {g, mnesia_rocksdb}, - {l, mnesia_bup}, - {g, mnesia_lib}, - {g, mnesia_schema}, - %% {g, mnesia_loader}, - {g, mnesia_index}, - {l, mnesia_tm} - ]. + []. +%% mods(1) -> +%% [ +%% {l, mnesia_rocksdb}, +%% {g, rocksdb} +%% ]; +%% mods(2) -> +%% [ +%% %% {l, mnesia_monitor}, +%% {g, mnesia_rocksdb}, +%% {l, mnesia_bup}, +%% {g, mnesia_lib}, +%% {g, mnesia_schema}, +%% %% {g, mnesia_loader}, +%% {g, mnesia_index}, +%% {l, mnesia_tm} +%% ]. diff --git a/test/mnesia_rocksdb_indexes_SUITE.erl b/test/mnesia_rocksdb_indexes_SUITE.erl index 94f275d..b524dc8 100644 --- a/test/mnesia_rocksdb_indexes_SUITE.erl +++ b/test/mnesia_rocksdb_indexes_SUITE.erl @@ -152,8 +152,8 @@ end_per_testcase(_, _) -> %% ====================================================================== cfg([Tab, Type, IxType], Config) -> - [{my_config, #{tab => Tab, type => Type, ixtype => IxType}} | Config]; -cfg(Cfg, Config) when is_map(Cfg) -> [{my_config, Cfg} | Config]. + [{my_config, #{tab => Tab, type => Type, ixtype => IxType}} | Config]. +%% cfg(Cfg, Config) when is_map(Cfg) -> [{my_config, Cfg} | Config]. cfg(Config) -> ?config(my_config, Config). diff --git a/test/mnesia_rocksdb_proper_semantics_test.erl b/test/mnesia_rocksdb_proper_semantics_test.erl index c1bf58c..8cf0ced 100644 --- a/test/mnesia_rocksdb_proper_semantics_test.erl +++ b/test/mnesia_rocksdb_proper_semantics_test.erl @@ -48,14 +48,18 @@ -record(st, {}). -define(KEYS, [a,b,c]). +-dialyzer({no_return, [basic_test_/0, test/1, prop_seq/0]}). + basic_test_() -> {timeout, 60000, [fun() -> test(100) end]}. +-dialyzer({no_opaque, test/1}). test(N) -> setup_mnesia(), true = proper:quickcheck(?MODULE:prop_seq(), N), ok. +-dialyzer({no_opaque, prop_seq/0}). prop_seq() -> ?FORALL(Cmds, proper_statem:commands(?MODULE), begin diff --git a/test/mnesia_rocksdb_xform.erl b/test/mnesia_rocksdb_xform.erl index 85c6508..957de75 100644 --- a/test/mnesia_rocksdb_xform.erl +++ b/test/mnesia_rocksdb_xform.erl @@ -260,10 +260,10 @@ plain_transform1(Fun, [F|Fs]) when is_atom(element(1,F)) -> continue -> [list_to_tuple(plain_transform1(Fun, tuple_to_list(F))) | plain_transform1(Fun, Fs)]; - {done, NewF} -> - [NewF | Fs]; - {error, Reason} -> - io:format("Error: ~p (~p)~n", [F,Reason]); + %% {done, NewF} -> + %% [NewF | Fs]; + %% {error, Reason} -> + %% io:format("Error: ~p (~p)~n", [F,Reason]); NewF when is_tuple(NewF) -> [NewF | plain_transform1(Fun, Fs)] end; diff --git a/test/mrdb_fold_SUITE.erl b/test/mrdb_fold_SUITE.erl index f5f1546..778038b 100644 --- a/test/mrdb_fold_SUITE.erl +++ b/test/mrdb_fold_SUITE.erl @@ -90,7 +90,7 @@ mk_tab(G) -> end. tab_name(fold ) -> r; -tab_name(select ) -> r; +%% tab_name(select ) -> r; tab_name(rdb_fold) -> t. create_tab(T) ->