with Erlang ets, how can Match part of key?
for exmaple, ets:insert(time_tb,{ {un_known,{<<"knonw_1">>,<<"knonw_2">>} },[data]}).
the key was {un_known,{<<"knonw_1">>,<<"knonw_2">>}
How can I match from the table if I only knows {<<"knonw_1">>,<<"knonw_2">>}
is this possible?
If I understood correctly,no necessary use function match. You can do this with functions ets:select and est:fun2ms for simplify match specifications.
R=ets:fun2ms(fun(Data={{_,T},_}) when T =:= {<<"knonw_1">>,<<"knonw_2">>}->Data end).
ets:select(time_tb,R).
and get:
[{{un_known,{<<"knonw_1">>,<<"knonw_2">>}},[data]}]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.