Hynek,<div>Yes you are right, if the table is big full scan is not a good idea.<div><br><div class="gmail_quote">2012/2/9 ori brost <span dir="ltr"><<a href="mailto:oribrost@gmail.com">oribrost@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The question is whether there is any way that I can avoid the<br>
"erlang-to-c call" cost and do these 4 lookups (i.e. with one ets call<br>
do lookup for all 4).<br>
<div class="HOEnZb"><div class="h5"><br>
On Thu, Feb 9, 2012 at 1:00 PM, Hynek Vychodil <<a href="mailto:hynek@gooddata.com">hynek@gooddata.com</a>> wrote:<br>
> This code will cause table full scan which usually will be far slower than just<br>
> [ V || K <- ["A","B","C","D"], V <- ets:lookup(Tid, K) ]<br>
> except very small tables full scan will not be good idea.<br>
><br>
> On Thu, Feb 9, 2012 at 11:49 AM, Ahmed Omar <<a href="mailto:spawn.think@gmail.com">spawn.think@gmail.com</a>> wrote:<br>
>> ets:select(Tid, [{{'$1','$2'},[{'==','$1',X}],['$_']}|| X<-<br>
>> ["A","B","C","D"]]).<br>
>><br>
>><br>
>> On Thu, Feb 9, 2012 at 11:11 AM, dmitry kolesnikov <<a href="mailto:dmkolesnikov@gmail.com">dmkolesnikov@gmail.com</a>><br>
>> wrote:<br>
>>><br>
>>> You could try<br>
>>> ets:select or qlc interface.<br>
>>><br>
>>> It table is not big enough then qlc and custom fold function would work:<br>
>>><br>
>>> Q=qlc:q([ X || X <- ets:table(mytab)]),<br>
>>> qlc:fold(FoldFun, [], Q)<br>
>>><br>
>>> Best Regards,<br>
>>> Dmitry >-|-|-*><br>
>>><br>
>>><br>
>>> On 9.2.2012, at 11.40, ori brost <<a href="mailto:oribrost@gmail.com">oribrost@gmail.com</a>> wrote:<br>
>>><br>
>>> > Is there any way in ets to fetch values for several keys in 1 call?<br>
>>> > i.e. something like<br>
>>> ><br>
>>> > ets:multi_fetch(Tid, ["A","B","C","D"]) % will fetch all entries with<br>
>>> > keys A, B, C, D<br>
>>> > _______________________________________________<br>
>>> > erlang-questions mailing list<br>
>>> > <a href="mailto:erlang-questions@erlang.org">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>
>>> _______________________________________________<br>
>>> erlang-questions mailing list<br>
>>> <a href="mailto:erlang-questions@erlang.org">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>
>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> erlang-questions mailing list<br>
>> <a href="mailto:erlang-questions@erlang.org">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>
>><br>
><br>
><br>
><br>
> --<br>
> Hynek Vychodil<br>
> BI consultant<br>
><br>
> GoodData<br>
> náměstí 28. října 1104/17, 602 00, Brno - Černá Pole<br>
> Office:   <a href="tel:%2B420%20530%2050%207704" value="+420530507704">+420 530 50 7704</a><br>
> E-mail:  <a href="mailto:hynek@gooddata.com">hynek@gooddata.com</a><br>
> Web:     <a href="http://www.gooddata.com" target="_blank">www.gooddata.com</a><br>
</div></div></blockquote></div><br></div></div>