[erlang-questions] ets with maps and/or select

Matthew Evans <>
Thu May 19 17:16:43 CEST 2016


Hi,
I want to create an ets table to store a large number of records (over 100,000). I then want to use ets:select/ets:match to search this table for records containing a specific value. The issue is that I do not know the position of this value in the record. For example take this record:
R1#my_record{key = 123, value1 = 77, value2 = 88}
R2#my_record{key = 321, value1 = 88, value2 = 77}
R3#my_record{key = 999, value1 = 12, value2 = 73}
I want to search the ets table to find any record containing value 77 (I could of course save these values in a list in each record, this is just an example).
I know I can do an ets:foldl for this purpose, but I was wondering if there is a more efficient way?
Could I for example save the values in a map, put the map in a record in the ets table and create a match_specification that I can use with an ets:select or ets:match?
The map may look like:
M = #{77 => ok, 88 => ok}.R4#my_record{key = 123, map = M}.
Thanks  		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160519/3b4e6992/attachment.html>


More information about the erlang-questions mailing list