Thanks.<br>Your answer make me understand than ets is more like a DB than like a dict.<br><br>So if my current matrix representation is something like:<br>{line key, dict-of-column-values}<br>a new implementation with ets should split the dict-of-column structure:
<br>{line key, column key 1, value}<br>{line key, column key 2, value}<br>...<br><br>Btw, it was not clear to me from the doc than select and lookup imply different efficiency results.<br><br>Thank you very much.<br><br><div>
<span class="gmail_quote">On 4/16/07, <b class="gmail_sendername">Ulf Wiger</b> <<a href="mailto:ulf@wiger.net">ulf@wiger.net</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
2007/4/16, Ludovic Coquelle <<a href="mailto:lcoquelle@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">lcoquelle@gmail.com</a>>:<div><span class="e" id="q_111f9126946daa9d_1"><div><span class="gmail_quote">
</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>In my application, I have to store a huge (but sparse) 2D matrix. I implemented that successfully using dict-of-dict kind of structure.<br><br>I was then thinking to use a ets-of-dict structure: each line is a dict (containing all colum values) and I store each line (a dict) as an entry of a ets structure.
<br>But I read in the doc introduction of ets that "In the current implementation, every object insert and
look-up operation results in one copy of the object.". Does this means that each access (even read) to an element of my matrix would imply a new dict copy?<br>
</blockquote></div><br></span></div>Yes. While ets outperforms all other alternatives for random access for sets<br>of small objects (at least sets of size > 20), it doesn't necessarily do so for<br>large objects.
<br><br>But if a dict-of-dict structure works, you might want to consider just using an
<br>ordset ets table. If you have a tuple as the key in an ordset table, ets:select(),<br>using a pattern where the first part of the key is bound, will be very efficient.<br><br>You can also create ets tables where the tuples stored have only one element -
<br>the key. Mnesia doesn't let you do that, but ets does.<br><br>BR,<br>Ulf W<br>
</blockquote></div><br>