I needed to store some structs/maps in ETS and wanted to use a query language that felt simple and approachable.
After looking at several alternatives, I noticed that all the wrappers around ETS match specifications were doing a bit too much for my taste. This is how EtsSelect came to life.
You can dump your maps/structs into an ETS table and select them using the following query syntax:
And I want to do a query to get all the values where the third element in the tuple key is "age", i.e. something like :ets.select(:my_table, match_spec) == ["100", "101"]. From what I can tell this isn’t currently possible to query via ets_select, is that right?
While it could be possible, it would change the original goal of the package. It seems you are storing arbitrary values for debugging in data_tracer, yet my use case is selecting based on field values in maps / structs.
Fair enough! All libraries need to define the scope that they want to tackle
Thank you for the kind words! I don’t have a plan to add a query language for data_tracer, the use case is mainly getting stored values out ordered by insertion and only for specific keys. For my usage of it I probably don’t even need to worry about efficient ETS lookups and could instead dump the whole table and filter it, but I wanted to take it as an opportunity to work with ETS in a more efficient manner.
Thank you for the contribution! I’ve merged the PR and released it as version 0.1.2
The reason matcha was even there was two fold: I wanted an excuse to try out Matcha, and I find match specs inscrutable to the point where I’m not super interested in learning them.
Yeah, the specs are really painful to read / write / understand. But… Just after having implemented he EtsSelect package, it was bearable to come up this those 2 match-specs. And having less dependencies is always nice
Thanks for merging the PR!
@dimitarvp Yeah, I’m quite familiar with the great, even outstanding quality of Elixir docs. I just dont need to lookup something, that is already working Only when things dont behave as expected, I dig deeper. So 100% agree with you on this one.
Thanks for chiming in and good night (its about midnight in EU)!