[erlang-questions] Issues with ets:match_delete

Code Wiget codewiget95@REDACTED
Fri Jul 13 17:01:59 CEST 2018


Here, it seems alive

(NODE13> ets:info(table_name).
[{read_concurrency,true},
 {write_concurrency,false},
 {compressed,false},
 {memory,422},
 {owner,<0.1064.0>},
 {heir,none},
 {name,cqerl_clusters},
 {size,2},
 {node,’NODE'},
 {named_table,true},
 {type,bag},
 {keypos,2},
 {protection,protected}]


On Jul 13, 2018, 7:24 AM -0400, Sverker Eriksson <sverker.eriksson@REDACTED>, wrote:
> Your ets:match_delete looks fine.
> Are you sure the table is still alive? Try ets:info(table_name).
>
> When you get an exception in the Erlang shell, the shell process will terminate and be restarted
> losing all process specific resources such as ets tables.
>
>
> /Sverker, Erlang/OTP
>
>
> On tor, 2018-07-12 at 16:35 -0400, Code Wiget wrote:
> > Hey everyone,
> >
> > Lets say you have an ets table with entries as shown below:
> >
> > {table_name, key, {A, [B]}.
> >
> > I am trying to delete all table entries matching A. I can create a match like so:
> >
> > ets:match(table_name, {'_', '_', {Node, '$1'}})
> >
> > and it returns the values for B. But when I run match_delete or select_delete, I get a badarg error…:
> >
> > > ets:match_delete(table_name, {'_', '_', {Node, '$1'}}).
> > > ** exception error: bad argument
> > >      in function  ets:select_delete/2
> > >         called as ets:select_delete(table_name,
> > >                                     [{{'_','_',{{{192,168,1,104},9042},'$1'}},[],[true]}])
> > >      in call from ets:match_delete/2 (ets.erl, line 726)
> > > (NODE)16> ets:select_delete(table_name, {'_', '_', {Node, '$1'}}).
> > > ** exception error: bad argument
> > >      in function  ets:select_delete/2
> > >         called as ets:select_delete(table_name,{'_','_',{{{192,168,1,104},9042},'$1'}})
> >
> > So I tried to match and object and delete it...
> >
> > > (NODE)17> ets:match_object(table_name, {'_', '_', {Node, '$1'}}).
> > > [{table_name,'$primary_cluster',
> > >                 Info…]
> > >
> > >
> > > (NODE)25> ets:delete_object(table_name, Info).
> > > ** exception error: bad argument
> > >      in function  ets:delete_object/2
> > >         called as ets:delete_object(table_name, …. )
> > >
> > I would like to avoid re-creating the table structure, as it is not from a project that I created and would take some time to fix all the code. How do I delete something from this table?
> >
> > Thanks!
> >
> >
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-questions
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180713/6b58eaa0/attachment.htm>


More information about the erlang-questions mailing list