dict or ets for key-value storage

79 views
Skip to first unread message
Message has been deleted

qiu

unread,
Nov 25, 2010, 11:23:11 AM11/25/10
to Erlang Programming
Hi,

In what situation should I choose dict over etc and vice verse ? Too
bad that the book does not cover this topic and as I google it I do
not find a satisfied answer (except that using ets will copy the
data).

http://www.erlang.org/faq/libraries.html says "In practice, Erlang
programs use lists (either natively or via dict) for data structures
involving up to a few hundred elements and use ETS (the Erlang Term
Store) or mnesia for anything larger. ETS uses hashing to allow near
constant-time access to almost arbitrarily large amounts of data. ".
It does not talk about the usage of dict here too. And "Erlang
programs use lists (either natively or via dict)", what does this mean
exactly ("use lists via dict") ?

Another question about dict is that each time I store a new key-value
into a dict, I will get a new dict. So after I set up my dict (with a
lot of dict:store) I will get many temporary dict I won't use at all.
As I always need to setup my dict first, those temporary dicts are
only created to be garbage collected later. That seems awkward. So
what is the design logic of here?

Thanks!
Reply all
Reply to author
Forward
0 new messages