[Proposal] Add Registry.select/3 to support :ets streams across partitions

38 views
Skip to first unread message

Scott Southworth

unread,
Sep 30, 2020, 2:38:47 PM9/30/20
to elixir-lang-core
Hi, this is my first Elixir suggestion!

For using Registry as an in-memory database that's tied to many actor processes, it would be nice to be able to stream selections to perform batch operations without loading large amounts of data into memory all at once.

I propose adding a Registry.select/3 that would look like:

`select(registry(), spec(), limit :: pos_integer()) :: Stream.t()`

The limit argument would provide an `:ets` select limit (as this would affect the granularity of our memory consumption). The implementation would return a stream that could return data across the underlying partitions transparently.  

Thanks,
Scott Southworth




José Valim

unread,
Oct 1, 2020, 5:12:26 AM10/1/20
to elixir-l...@googlegroups.com
Hi Scott,

Thanks for the proposal.

We already have a function that returns what you want as a list, called Registry.match/3, so I would suggest to stay with a similar name. The other thing to have in mind is that the stream would only be useful if you have more than one partition, so for all other cases, we can't even return a stream. So I see two options:

1. Introduce Registry.stream_match/2 which may return a stream - and therefore may be awkward

2. Introduce a stream: true option to Registry.match which may return a stream if applicable - behaving like an optimization in a way

Thoughts?

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/5aac28b9-2809-49f9-80b4-bae6de7d9df3n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages