Proposal: ets:select_take?

Borja de Regil borja.deregil@REDACTED
Wed Jul 15 17:52:40 CEST 2020


Hi Fred,

> Would iterating over the list of objects with ets:delete_object/2 help?

That’s a good observation. It might work in most cases, since most often than not you’ll be iterating over objects anyway, but consider the following:

The issue is that for this to work, you need more information (ets:delete_object/2 needs the entire object, while ets:delete/2 needs the key). This is okay if you’re using ets:match_object (since it returns everything), or you return the key of the object while using match/select.

But you might only be interested in a specific field of the object, or are not interested in copying the key to the process (since reading from ETS will copy everything) if the key is large enough. In this case, you don’t have enough info to call delete_object/2 or delete/2. 

I realize now that this might be a more niche case than I though at first!

Cheers,
Borja



More information about the erlang-questions mailing list