gproc seems to use an ordered_set ETS table and then an ets:select() to match against the keys it needs.  I did some basic tests with a 5 million row ETS ordered set table and ets:foldl still seems to come out faster.<div>
<br></div><div>Not sure if my simple test script is bogus or what but the results were consistent.</div><div><br></div><div><a href="https://gist.github.com/2582918">https://gist.github.com/2582918</a></div><div><br></div>
<div>-AD<br><br><div class="gmail_quote">On Wed, May 2, 2012 at 3:14 PM, Dmitry Kolesnikov <span dir="ltr"><<a href="mailto:dmkolesnikov@gmail.com" target="_blank">dmkolesnikov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div>I've been looking into similar problem. I would not advice to partition ets by event type. You would not gain anything... a single ets should work. You are right that foldl over large table might be expensive:</div>
<div><br></div><div>* with ordered_set ets and ets:next / ets:prev you might implement efficient "fold" through particular event type only.</div><div><br></div><div>* with bag you can use select to retrieve a subset of keys according to match spec.</div>
<div><br></div><div>You could look either gproc or <a href="https://github.com/fogfish/pts" target="_blank">https://github.com/fogfish/pts</a> they might suite your needs.</div><span class="HOEnZb"><font color="#888888"><div>
<br></div><div>Dmitry</div><div><br></div><div><br></div><div> </div><div><br></div><div><br></div><div><br></div><br></font></span><div><div><div class="h5"><div>On May 2, 2012, at 7:54 PM, Bob Ippolito wrote:</div><br></div>
</div><blockquote type="cite"><div><div class="h5">You could look at how gproc does it, or just use gproc. <span></span><br><br>On Wednesday, May 2, 2012, AD  wrote:<br><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Hello,<div>
<br></div><div> I have a problem where i need to map event_ids to connection objects (for use in websockets to broadcast an event).  I am trying to determine the most efficient way to map 1 event_id to possibly several thousand connection objects.  Ultimately I would need to find every connection object mapped to an ID and then send an event to each connection object.  Is using an ETS bag and then using ets:foldl() to loop through the most optimal ?  I was thinking of breaking down each event_type into a separate ETS table and then storing the event_id for that event_type in the respective ETS table with the connection object.</div>


<div><br></div><div> Thoughts welcome.</div><div><br></div><div>Thanks</div><div>-AD</div>
</blockquote></div></div>
_______________________________________________<div class="im"><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/listinfo/erlang-questions</a><br>
</div></blockquote></div><br></div></blockquote></div><br></div>