dets example importing data

1k views Asked by At

got a problem with dets:to_ets/2

Could somebody point me to an example online? Ive looked at the man pages but I couldnt see any example usage. Couldn't find anything on google..

My problem seems to be with the actual dets:to_ets() function itself, not the creating of the dets. I have tested that on it's own and it's fine.

2

There are 2 answers

0
Arkady On BEST ANSWER

You should create ETS table before use to_ets/2 function on it. The existing objects of the Ets table are kept unless overwritten. Do you have any {error, Reason} tuples in the result?

0
butter71 On

a quick example of dets:to_ets/2.

1> dets:open_file(d, [{file, "/tmp/d"}, {type, set}]).
{ok,d}
2> dets:insert(d, {a, 1}).
ok
3> dets:insert(d, {b, 2}).
ok
4> ets:new(e, [named_table, set]).
e
5> dets:to_ets(d, e).
e
6> ets:tab2list(e).
[{b,2},{a,1}]