Key iteration support for fragmented tables

Chandrashekhar Mullaparthi Chandrashekhar.Mullaparthi@REDACTED
Tue Nov 21 13:33:06 CET 2000


Hi,

I need mnesia:dirty_first and mnesia:dirty_next for fragmented tables. Right
now mnesia:first just looks in the first fragment and if that is empty
returns '$end_of_table'. The same with mnesia:dirty_next. This can be easily
extended to look in each fragment in case of a fragmented table - which I
have done - but I dont think it will make any sense in a table of type
ordered_set.

Any comments, anyone?? So as not to affect performance for dirty_first and
dirty_next on unfragmented tables, two separate functions frag_dirty_first
and frag_dirty_next can be written.

cheers,
Chandru

---------

dirty_first(Tab) when atom(Tab), Tab /= schema ->
    FP =  mnesia:table_info(Tab, frag_properties),
    Frags = case lists:keysearch(n_fragments, 1, FP) of
		{value, {n_fragments, Frags_1}} -> lists:seq(2, Frags_1);
		_ -> []
	    end,
    TNames = [Tab]++[ list_to_atom(lists:flatten(io_lib:format("~p_frag~p",
[Tab,X]))) || X <- Frags ],
    Fun = fun(X, '$end_of_table') -> dirty_rpc(X, mnesia_lib, db_first,
[X]);
	     (X, Acc) -> Acc
	  end,
    lists:foldl(Fun, '$end_of_table', TNames);
dirty_first(Tab) ->
    abort({bad_type, Tab}).

dirty_next(Tab, Key) when atom(Tab), Tab /= schema ->
    FP =  mnesia:table_info(Tab, frag_properties),
    Frags = case lists:keysearch(n_fragments, 1, FP) of
		{value, {n_fragments, Frags_1}} -> lists:seq(2, Frags_1);
		_ -> []
	    end,
    TNames = [Tab]++[ list_to_atom(lists:flatten(io_lib:format("~p_frag~p",
[Tab,X]))) || X <- Frags ],
    Fun = fun(X, '$end_of_table') -> dirty_rpc(X, mnesia_lib, db_next_key,
[X, Key]);
	     (X, Acc) -> Acc
	  end,
    lists:foldl(Fun, '$end_of_table', TNames);
dirty_next(Tab, Key) ->
    abort({bad_type, Tab}).



NOTICE AND DISCLAIMER:
This email (including attachments) is confidential.  If you have received
this email in error please notify the sender immediately and delete this
email from your system without copying or disseminating it or placing any
reliance upon its contents.  We cannot accept liability for any breaches of
confidence arising through use of email.  Any opinions expressed in this
email (including attachments) are those of the author and do not necessarily
reflect our opinions.  We will not accept responsibility for any commitments
made by our employees outside the scope of our business.  We do not warrant
the accuracy or completeness of such information.




More information about the erlang-questions mailing list