Argus.Symbols (Panoptes v0.13.0)

Copy Markdown View Source

Interned fact symbols: every string a fact row carries, mapped once to a small integer.

A raw fact row is a list of short binaries — a few hundred bytes of heap for under a hundred bytes of text, copied in full whenever the row crosses a process or an ETS table, and re-parsed by every consumer that wants the Argus.InstrId inside an instruction ID. Interned rows are tuples of ids: a few words each, and an ID's parse is cached on the table and done once.

The table is owned by whoever holds the rows. Ids are only meaningful next to the table that minted them, so a consumer that persists rows persists the table with them — Argus.Symbols.Store is the behaviour such a consumer implements over its own storage; Argus.Symbols.ETS is the default for a single run.

Summary

Functions

Releases the parse cache, and the store when it is the default ETS one. The tables also die with the process that created the table, so this is for a long-lived owner that is done with a run.

The Argus.InstrId an instruction-ID symbol parses to, parsed once per id and cached on the table. :error for a symbol that is not an instruction ID.

The id for binary, minting one on first sight.

A table over the default ETS store.

A table over store, a Argus.Symbols.Store, with its state.

The binary behind id. Raises for an id this table never minted.

Types

id()

@type id() :: pos_integer()

t()

@type t() :: %Argus.Symbols{parsed: :ets.tid(), state: term(), store: module()}

Functions

destroy(symbols)

@spec destroy(t()) :: :ok

Releases the parse cache, and the store when it is the default ETS one. The tables also die with the process that created the table, so this is for a long-lived owner that is done with a run.

instr_id(symbols, id)

@spec instr_id(t(), id()) :: {:ok, Argus.InstrId.t()} | :error

The Argus.InstrId an instruction-ID symbol parses to, parsed once per id and cached on the table. :error for a symbol that is not an instruction ID.

intern(symbols, binary)

@spec intern(t(), binary()) :: id()

The id for binary, minting one on first sight.

new()

@spec new() :: t()

A table over the default ETS store.

new(store, state)

@spec new(module(), term()) :: t()

A table over store, a Argus.Symbols.Store, with its state.

resolve(symbols, id)

@spec resolve(t(), id()) :: binary()

The binary behind id. Raises for an id this table never minted.