<div dir="ltr">Larger binaries (refc binaries) in the Erlang VM are sent by reference and not copied when sent from one process to another (the threshold is 64 bytes, and they use a reference counting strategy). If you have a process that can de-dupe these binaries then you don't use hashes at all, you just store the binaries and know that they're shared. I'm not sure if an ets table (instead of a process) will suffice to do the de-duping, but you could do some experiments to figure that out.<div>
<br></div><div>If the attributes also have names (and there aren't too many possible names), then atoms are generally the right type for that.</div><div><br></div><div>See also: <a href="http://www.erlang.org/doc/efficiency_guide/binaryhandling.html">http://www.erlang.org/doc/efficiency_guide/binaryhandling.html</a><br>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 25, 2013 at 2:52 AM, Rick Payne <span dir="ltr"><<a href="mailto:rickp@rossfell.co.uk" target="_blank">rickp@rossfell.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I've been using erlang for some simple projects, and really enjoying it. However, when thinking about some of the things I'd like to do - I'm struggling a bit with hashing and how to handle that in a concurrent way in erlang. This is probably 101 stuff, sorry...<br>
<br>
Imagine we have a set of data streams giving us objects and attributes. Attributes can be a few kB but typically are less than 1kB. The objects are unique but some set of them share the attributes. Typically in C, I'm used to hashing the attributes and pointing at them from the objects. We hash to save memory and refcount so we know when we can delete from the hash. The good news is that the attributes are never updated in place, apart from the refcount.<br>
<br>
However, I'm struggling to get my head around how I'd do this in erlang efficiently. Any suggestions?<br>
<br>
Cheers,<br>
Rick<br>
<br>
______________________________<u></u>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a><br>
</blockquote></div><br></div>