The ETS store behind InfluxElixir.Client.Local: the one module that
knows the key layout.
One :ordered_set per instance, :public so async: true tests can
write from any process. Every mutation is a single insert or delete of
its own key, so concurrent writers — tests sharing a database,
BatchWriter flushes racing direct writes — never read-modify-write a
shared value and no write is lost:
{:database, name}=>true{:bucket, name}=>%{retention: seconds}{:token, id}=> the token map{:point, database, measurement, seq}=> the point —seqis a monotonic integer, so points scan in insertion order{:series_time, database, measurement, tags, timestamp}— one per point written; a second write of the same key adds{:duplicates, database, measurement}— reads merge that measurement's duplicate points (same tags and time) only when this marker exists{:column, database, measurement, column}=> the column's kind (iox::column_type::tagoriox::column_type::field::<type>), fixed by the first write that names the column
The store is policy-free: what a write may contain, which errors the
engine returns and how a query reads rows live in Client.Local and the
modules it delegates to.
Summary
Functions
Whether a bucket is registered.
The buckets as {name, meta}, sorted by name.
A column's registered kind, or nil — a read that registers nothing.
Every column in a database as {measurement, column, kind}, in that order.
Whether a database is registered.
The registered databases.
Removes a bucket; :error when it was not registered.
Deletes the points of a measurement that match? accepts, judged on the
merged points as the engine sees them; every stored object behind a
matching point is deleted by its own key, so a concurrent write is never
lost. Returns the number of (merged) points deleted.
Removes a token (a missing one is fine).
Deletes the store. Safe to call again: the table dies with its owner, and
an on_exit callback can run after that, so a missing table is :ok.
Drops a database with everything in it — points, schema, the
duplicate index — so a re-created database starts empty. :error when
it was not registered.
Whether any point was written to the measurement.
The database's measurements that hold points, first-written first.
Creates a store with databases registered.
The double's "now", in nanoseconds: used to stamp untimed points and for
SQL and Flux now(). System.os_time/1 and System.system_time/1 can
differ by microseconds (time warp), and a test stamps points with either;
taking the later of the two means a point written a moment ago is never
after now(), as it never is on a real server.
A measurement's points in insertion order, duplicates merged. InfluxDB — both versions, verified — treats points with the same tags and time as one point whose fields merge, the later write winning per field.
Every point in a database, duplicates merged.
Registers a bucket with its metadata (replacing any earlier one).
Registers a database (idempotent).
Stores a token under its id.
Registers a column's kind if it is new. The first writer fixes it
atomically (insert_new), so a concurrent writer never loses a column.
Returns :ok when the kind matches (or was just registered) and
{:conflict, existing} when the column already has another kind.
Stores a point as written, one insert of its own key. A point without a timestamp gets the server's time, as on the engine.
Whether the measurement has any column registered (the table exists).
A measurement's tag columns.
Types
@type point() :: InfluxElixir.Client.Local.LineProtocolParser.point()
A stored point.
@type t() :: :ets.table()
A store instance.
Functions
Whether a bucket is registered.
The buckets as {name, meta}, sorted by name.
A column's registered kind, or nil — a read that registers nothing.
Every column in a database as {measurement, column, kind}, in that order.
Whether a database is registered.
The registered databases.
Removes a bucket; :error when it was not registered.
Deletes the points of a measurement that match? accepts, judged on the
merged points as the engine sees them; every stored object behind a
matching point is deleted by its own key, so a concurrent write is never
lost. Returns the number of (merged) points deleted.
Removes a token (a missing one is fine).
@spec drop(t()) :: :ok
Deletes the store. Safe to call again: the table dies with its owner, and
an on_exit callback can run after that, so a missing table is :ok.
Drops a database with everything in it — points, schema, the
duplicate index — so a re-created database starts empty. :error when
it was not registered.
Whether any point was written to the measurement.
The database's measurements that hold points, first-written first.
@spec new(Enumerable.t()) :: t()
Creates a store with databases registered.
@spec now_ns() :: integer()
The double's "now", in nanoseconds: used to stamp untimed points and for
SQL and Flux now(). System.os_time/1 and System.system_time/1 can
differ by microseconds (time warp), and a test stamps points with either;
taking the later of the two means a point written a moment ago is never
after now(), as it never is on a real server.
A measurement's points in insertion order, duplicates merged. InfluxDB — both versions, verified — treats points with the same tags and time as one point whose fields merge, the later write winning per field.
Every point in a database, duplicates merged.
Registers a bucket with its metadata (replacing any earlier one).
Registers a database (idempotent).
Stores a token under its id.
Registers a column's kind if it is new. The first writer fixes it
atomically (insert_new), so a concurrent writer never loses a column.
Returns :ok when the kind matches (or was just registered) and
{:conflict, existing} when the column already has another kind.
Stores a point as written, one insert of its own key. A point without a timestamp gets the server's time, as on the engine.
Storing a measurement's points as one list meant every write read the list, prepended and wrote it back: concurrent writers overwrote each other (#15: 159 of 480 writes survived) and each insert copied the whole list. A plain insert is atomic and O(log n).
Whether the measurement has any column registered (the table exists).
A measurement's tag columns.