[erlang-questions] flat representation with erlang term order
Fri May 30 18:57:31 CEST 2008
i'm trying to develop a disk based erlang term storage (dets replacement)
using tokyocabinet. i would like the b+tree to be sorted according to
erlang term order to make certain selects cheap.
i noticed that erlang:term_to_binary/1 does not preserve term order, i.e.,
comparing the resulting binaries with memcmp sometimes disagrees with
erlang term order. so the easy way is out.
* is there another flat representation of an erlang term available which
preserves erlang term order via memcmp?
* alternatively, is there a function i can call from a linked-in driver
to compare two binaries derived from erlang:term_to_binary/1 which
corresponds to erlang term order? tokyocabinet can use an arbitrary
comparison function (on bytes) so this could work.
other ideas would also be appreciated.
6> A = 16#10000000ff01.
7> B = 16#100000000002.
8> A < B.
9> BA = term_to_binary (A).
10> BB = term_to_binary (B).
11> BA < BB.
In an artificial world, only extremists live naturally.
-- Paul Graham
More information about the erlang-questions