Add mrdb:ms/2 for match spec production #9

Merged
uwiger merged 1 commits from uw-mrdb-ms into master 2025-10-11 02:22:27 +09:00
Owner

From the doc:

Produce a match specification for select(), supporting map-based match patterns

Using record syntax in match patterns tends to conflict with type checking. This
function offers an alternative approach, drawing on the fact that mnesia_rocksdb
keeps the record name and attribute names readily available as persistent terms.

When using the map-based representation, the match pattern is built by matching
attribute names to map elements; any attribute not found in the map gets set to '_'.
Thus, [{#balance{key = {Acct,'$1'},_='_'},[{'>=','$1',Height}],['$_']}] can be
created as ms(balance,[{#{key => {Acct,'$1'}},[{'>=','$1',Height}],['$_']}]).

This has the advantage over ms_transform that it can handle bound variables
in the match pattern. The function works on all mnesia table types.

From the doc: > Produce a match specification for `select()`, supporting map-based match patterns > > Using record syntax in match patterns tends to conflict with type checking. This > function offers an alternative approach, drawing on the fact that mnesia_rocksdb > keeps the record name and attribute names readily available as persistent terms. > > When using the map-based representation, the match pattern is built by matching > attribute names to map elements; any attribute not found in the map gets set to `'_'`. > Thus, `[{#balance{key = {Acct,'$1'},_='_'},[{'>=','$1',Height}],['$_']}]` can be > created as `ms(balance,[{#{key => {Acct,'$1'}},[{'>=','$1',Height}],['$_']}])`. > > This has the advantage over `ms_transform` that it can handle bound variables > in the match pattern. The function works on all mnesia table types.
uwiger added 1 commit 2025-10-10 21:05:17 +09:00
uwiger requested review from dimitar.p.ivanov 2025-10-10 21:05:18 +09:00
uwiger requested review from hans_sv 2025-10-10 21:05:18 +09:00
uwiger requested review from spivee 2025-10-10 21:05:18 +09:00
uwiger requested review from zxq9 2025-10-10 21:05:19 +09:00
Author
Owner

Not generating new edown yet, as some incompatibility seems to have snuck in between edown and later edoc versions.

Not generating new `edown` yet, as some incompatibility seems to have snuck in between `edown` and later `edoc` versions.
uwiger merged commit 6246f3f2e1 into master 2025-10-11 02:22:27 +09:00
uwiger deleted branch uw-mrdb-ms 2025-10-11 02:22:47 +09:00
Sign in to join this conversation.
No Milestone
No project
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: QPQ-AG/mnesia_rocksdb#9
No description provided.