In the case when index is of type {_}, index is returned as is
instead of putting it into a tuple {Ix, ordered}.
An example
Given the following index plugin implementation:
-module(key6).
-record(cgh, {key, val}).
-export([k6/3
, add_index/0
, create_table/0
, tst_bad_type/0
]).
k6(_, _, #cgh{key = {Name, K8, _Cid, _Vn}}) ->
[list_to_binary([atom_to_binary(Name),
list_to_binary(lists:sublist(K8, 6))])].
add_index() ->
mnesia_schema:add_index_plugin({k6}, key6, k6).
create_table() ->
mnesia:create_table(cgh,
[{attributes, record_info(fields, cgh)},
{type, ordered_set},
{index, [{k6}]},
{rocksdb_copies, [node()]},
{local_content, true}]).
tst_bad_type() ->
E1 = #cgh{key = {n1, "u1vgrjkh",{ecgi,238,6,213020,50},3}, val = ok},
mnesia:dirty_write(E1),
Index1 = list_to_binary([atom_to_binary(n1),
list_to_binary(lists:sublist("u1vgrjkh", 6))]),
mrdb:index_read(cgh, Index1, {k6}).
-- testing --
Eshell V14.2.2 (press Ctrl+G to abort, type help(). for help)
(rock@bang)2> mnesia:create_schema([node()]).
ok
(rock@bang)3> mnesia:start().
ok
(rock@bang)4> mnesia_rocksdb:register().
{ok,rocksdb_copies}
(rock@bang)5> l(key6).
{module,key6}
(rock@bang)6> key6:add_index().
{atomic,ok}
(rock@bang)7> key6:create_table().
{atomic,ok}
(rock@bang)8> key6:tst_bad_type().
** exception exit: {aborted,{bad_type,{cgh,index,{k6}}}}
in function mnesia:abort/1 (mnesia.erl, line 362)
in call from mrdb:ensure_ref/1 (~/projects/erlang/github/mnesia_rocksdb/src/mrdb.erl, line 609)
in call from mrdb:index_read_/3 (~/projects/erlang/github/mnesia_rocksdb/src/mrdb.erl, line 945)
-- after patch --
(rock@bang)9> c(mrdb).
Recompiling ~/projects/erlang/github/mnesia_rocksdb/src/mrdb.erl
{ok,mrdb}
(rock@bang)10> key6:tst_bad_type().
[{cgh,{n1,"u1vgrjkh",{ecgi,238,6,213020,50},3},ok}]
(rock@bang)11>
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