mnesia bound keys

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

mnesia bound keys

Karlo Kuna
i was wondering what exactly "key is bound" means in context of mnesia

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: mnesia bound keys

Mikael Pettersson-5
Presumably you're referring to mnesia:match_object/1 or /3.  It means that the key position of the pattern is a ground value and not a variable.

On Tue, Oct 31, 2017 at 7:24 PM, Karlo Kuna <[hidden email]> wrote:
i was wondering what exactly "key is bound" means in context of mnesia

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: mnesia bound keys

Karlo Kuna
i still don't fully grasp the concept. short example would be greatly appreciated.

On Tue, Oct 31, 2017 at 8:15 PM, Mikael Pettersson <[hidden email]> wrote:
Presumably you're referring to mnesia:match_object/1 or /3.  It means that the key position of the pattern is a ground value and not a variable.

On Tue, Oct 31, 2017 at 7:24 PM, Karlo Kuna <[hidden email]> wrote:
i was wondering what exactly "key is bound" means in context of mnesia

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions




_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: mnesia bound keys

Mikael Pettersson-5
Consider a key-value store.  You might have records

-record(kv, {key, val}).

which would be stored as 3-tuples

{kv, Key, Val}

in a mnesia table kv.  A call

mnesia:match_object({kv, 42, '_'})

has a pattern where the key position is bound to an actual value (42) but the value position is unbound ('_' is the wildcard which matches anything).  This call would then find all records in the kv table having key 42.  On the other hand, a call

mnesia:match_object({kv, '_', foo})

has a pattern where the key position is unbound but the value position is bound to the value foo.  This call would then find all records in the kv table having value foo.

The significance of the key is that it's the _index_ for the table, meaning that any access to the table that supplies the key can quickly locate where the relevant records are stored.  Accesses that do not supply the key generally have to enumerate all records and inspect them to see which ones match the pattern.  This means that accesses with a key are much quicker than those without.


On Tue, Oct 31, 2017 at 10:48 PM, Karlo Kuna <[hidden email]> wrote:
i still don't fully grasp the concept. short example would be greatly appreciated.

On Tue, Oct 31, 2017 at 8:15 PM, Mikael Pettersson <[hidden email]> wrote:
Presumably you're referring to mnesia:match_object/1 or /3.  It means that the key position of the pattern is a ground value and not a variable.

On Tue, Oct 31, 2017 at 7:24 PM, Karlo Kuna <[hidden email]> wrote:
i was wondering what exactly "key is bound" means in context of mnesia

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions





_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions