[erlang-questions] Store maps in ets/dets?
Jesper Louis Andersen
jesper.louis.andersen@REDACTED
Thu Apr 10 18:36:17 CEST 2014
On Thu, Apr 10, 2014 at 6:14 PM, Michael Loftis <mloftis@REDACTED> wrote:
> I think you might mean the opposite here....that maps is ephemeral and
> ETS is persistent (or can be persistent using DETS anyway)
>
Actually not. Two things to address though:
Max might have asked if you can store maps in ets:
5> ets:new(foo, [named_table]).
foo
6> ets:insert(foo, {#{a => 3, b => 4}}).
true
7> ets:match_object(foo, '_').
[{#{a => 3,b => 4}}]
8> ets:insert(foo, #{'not' => possible}).
** exception error: bad argument
in function ets:insert/2
called as ets:insert(foo,#{'not' => possible})
and the answer is that you can, but the topmost entry must be a tuple as
the example shows.
The other thing is about persistent vs ephemeral data structures.
http://en.wikipedia.org/wiki/Persistent_data_structure
Maps are persistent, but ETS in general is not. It is ephemeral according
to the wikipedia definition.
--
J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140410/e2b2c40d/attachment.htm>
More information about the erlang-questions
mailing list