[erlang-questions] small post about ordered_set and partially-bound keys
Andreas Schultz
andreas.schultz@REDACTED
Thu Dec 13 12:25:26 CET 2018
Max Lapshin <max.lapshin@REDACTED> schrieb am Do., 13. Dez. 2018 um
10:06 Uhr:
> Erlang ets with ordered_set mode has very cool feature: partially bound
> tuple primary key that allows to use ets as a good old binary tree.
>
> I haven't found any good explanations of how to use, so have written some
> draft of post:
>
> https://medium.com/@max.lapshin/how-we-adopted-partial-ordered-set-in-erlang-782f773349f4
>
You don't need to play tricks with ets:fun2ms/1. It is mostly a helper so
that you don't have to think to much about the structure of a match spec
yourself. But, you can still construct the same spec manually.
So, instead of:
ets:fun2ms(fun (#segment{utc={_,_,_}} = Segment) -> true end)
You can simply use:
[{#segment{utc = {'_','_','_'}, _ = '_'}, [], [true]}]
Or to use your sample:
match_spec_hour(Name, Hour, true) ->
[{#segment{utc = {Name,Hour,'_'}, _ = '_'}, [], [true]}];
match_spec_hour(Name, Hour, segment) ->
[{#segment{utc = {Name,Hour,'_'}, _ = '_'}, [], ['$_']}].
Regards
Andreas
>
> Would be glad for any feedback.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
--
--
Dipl.-Inform. Andreas Schultz
----------------------- enabling your networks ----------------------
Travelping GmbH Phone: +49-391-81 90 99 0
Roentgenstr. 13 Fax: +49-391-81 90 99 299
39108 Magdeburg Email: info@REDACTED
GERMANY Web: http://www.travelping.com
Company Registration: Amtsgericht Stendal Reg No.: HRB 10578
Geschaeftsfuehrer: Holger Winkelmann VAT ID No.: DE236673780
---------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20181213/7ce295ff/attachment.htm>
More information about the erlang-questions
mailing list