Regarding the `next/2` behaviour for `ets`, `dets` and `mnesia` for non existing keys and `ordered_set` tables

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Sat Nov 28 12:39:02 CET 2020


On Fri, Nov 27, 2020 at 5:22 PM Ciprian Dorin Craciun <
ciprian.craciun@REDACTED> wrote:

> Looking at the `next/2` documentation for `ets`, it states that for
> `ordered_set` the function always returns the next key larger than the
> input, regardless if the input key exists or not.
>
> So I was wondering if this property also translates to the equivalent
> `next` function in `dets` and `mnesia` tables for `ordered_set` type?
>
>
I would definitely assume that for mnesia since it is more or less reliant
on ETS for the typical table configuration (i.e., anything but disc_only).
I would also assume the same for dets, though here it is a bit less a
given. I don't off-hand know of the dets implementation, but ETS uses an
ordered tree structure (with some quite clever locks on top to avoid lock
contention in the tree when multiple readers/writes interact with it). So
kind-of the only way to implement next/2 is the one where you walk the tree
to find the next element.

For tables of type set, bag, ... the safe_fixtable/2 call is important in
this area.

-- 
J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20201128/63b02f17/attachment.htm>


More information about the erlang-questions mailing list