|
Hi
I'm trying to do something that will effectively work as 2 indexes in ets. I'm writing a proxy for connections so my connection list is {IdForSide1, IdForSide2, OtherStuff}. I'd like to find that tuple by any of ids quickly... is there a way to do it with only one tuple, or should I split it to 3 tables {IdForSide1, ConnectionRef}, {IdForSide2, ConnectionRef}, {ConnectionRef, OtherStuff} ? That seems like rather heavy solution, or maybe not... I don't have that much experience with ets. Thanks for any ideas. _______________________________________________ erlang-questions mailing list [hidden email] http://www.erlang.org/mailman/listinfo/erlang-questions |
|
You can use for example this:
{{IdForSide1, IdForSide2}, OtherStuff} On Sat, Apr 12, 2008 at 4:57 PM, Stanisław Pitucha <[hidden email]> wrote: Hi -- --Hynek (Pichi) Vychodil _______________________________________________ erlang-questions mailing list [hidden email] http://www.erlang.org/mailman/listinfo/erlang-questions |
|
In reply to this post by Stanisław Pitucha
On 12 Apr 2008, at 15:57, Stanisław Pitucha wrote: > Hi > I'm trying to do something that will effectively work as 2 indexes in > ets. I'm writing a proxy for connections so my connection list is > {IdForSide1, IdForSide2, OtherStuff}. I'd like to find that tuple by > any of ids quickly... is there a way to do it with only one tuple, or > should I split it to 3 tables {IdForSide1, ConnectionRef}, > {IdForSide2, ConnectionRef}, {ConnectionRef, OtherStuff} ? > That seems like rather heavy solution, or maybe not... I don't have > that much experience with ets. You are correct. There is no way to have multiple indexes within a single ets table. I would probably split it into 2 tables: {Id1, {Id2, Stuff}} {Id2, Id1} If there is some bias towards the number of lookups for Id1 or Id2 then I would make that one the one with a direct lookup to Stuff. The extra entry for Id2 in the first table would be to support deletions from either Id. Sean _______________________________________________ erlang-questions mailing list [hidden email] http://www.erlang.org/mailman/listinfo/erlang-questions |
| Powered by Nabble | Edit this page |
