[erlang-questions] flat representation with erlang term order

Sean Hinde sean.hinde@REDACTED
Fri May 30 19:30:03 CEST 2008


On 30 May 2008, at 17:57, Paul Mineiro wrote:

> 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.[1]  so the easy way is out.
>
>
>  * 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.

There is a C function erl_compare_ext/2 available in the erl_interface  
application. You will need to ensure that everything is in the right  
format, but once you achieve that, this is probably what you want :-)

Sean




More information about the erlang-questions mailing list