View Source Indexed (Indexed v0.3.4)
Tools for creating an index.
Link to this section Summary
Types
A function which takes a record and returns a value which will be evaluated for truthiness. If true, the value will be included in the result set.
The value of a record's :id
field - usually a UUID or integer.
A lookup index allows quickly finding record ids by their field values. These are leveraged with with the "get_by" functions.
A value to prefix ETS table names.
A parameter to indicate a sort field and optionally direction.
Specifies a discrete data set of an entity, pre-partitioned into a group.
A tuple indicates a field name and value which must match, a string
indicates a view fingerprint, and nil
means the full data set.
A record map being cached & indexed. :id
key is required.
:entities
- Map of entity name keys toIndexed.Entity.t/0
:index_ref
- ETS table reference for all indexed data.
Reference to a table. If an atom, then a namespace is in use.
Map held in ETS - tracks all views and their created timestamps.
Functions
Get the name of the first indexed field for an entity. Good order_hint default.
Delete all ETS tables associated with the given index.
Get the ETS options to be used for any and all tables.
Get a record by id from the index.
Gets the list of name
records having value
under field
.
Gets the list of name
record ids having value
under field
.
Gets an index data structure by key. Returns default if cache doesn't exist.
Gets a list of record ids.
Gets an index data structure.
Get a list of all cached records of a certain type.
For the given data set, get a list (sorted ascending) of unique values for
field_name
under entity_name
. Returns nil
if no data is found.
For the given prefilter
, get a map where keys are unique values for
field_name
under entity_name
and vals are occurrence counts. Returns
nil
if no data is found.
Get a particular view struct (view metadata) by its fingerprint.
Get a map of fingerprints to view structs (view metadata).
Cache key for a given entity, field and direction.
Cache key for a lookup map of the given entity's records:
%{"Some Field Value" => [123, 456]}
Gets an ETS table reference or name for an entity name.
Default with no entity_name
is indexes table ref.
Build an ETS table name from its namespace and entity_name.
Cache key holding unique values for a given entity and field.
Cache key holding unique values & counts for a given entity and field.
Cache key holding views/0
for a certain entity.
Link to this section Types
A function which takes a record and returns a value which will be evaluated for truthiness. If true, the value will be included in the result set.
@type id() :: any()
The value of a record's :id
field - usually a UUID or integer.
A lookup index allows quickly finding record ids by their field values. These are leveraged with with the "get_by" functions.
@type namespace() :: atom()
A value to prefix ETS table names.
@type order_hint() :: atom() | {direction :: :asc | :desc, field_name :: atom()} | [{:asc | :desc, atom()}]
A parameter to indicate a sort field and optionally direction.
Specifies a discrete data set of an entity, pre-partitioned into a group.
A tuple indicates a field name and value which must match, a string
indicates a view fingerprint, and nil
means the full data set.
@type record() :: map()
A record map being cached & indexed. :id
key is required.
@type t() :: %Indexed{ entities: %{required(atom()) => Indexed.Entity.t()}, index_ref: table_ref() }
:entities
- Map of entity name keys toIndexed.Entity.t/0
:index_ref
- ETS table reference for all indexed data.
Reference to a table. If an atom, then a namespace is in use.
@type views() :: %{required(String.t()) => DateTime.t()}
Map held in ETS - tracks all views and their created timestamps.
Link to this section Functions
Get the name of the first indexed field for an entity. Good order_hint default.
@spec delete_tables(t()) :: :ok
Delete all ETS tables associated with the given index.
Get the ETS options to be used for any and all tables.
Get a record by id from the index.
Gets the list of name
records having value
under field
.
Gets the list of name
record ids having value
under field
.
Gets an index data structure by key. Returns default if cache doesn't exist.
@spec get_index(t(), atom(), prefilter(), order_hint() | nil) :: list()
Gets a list of record ids.
Gets an index data structure.
@spec get_records(t(), atom(), prefilter(), order_hint() | nil) :: [record()]
Get a list of all cached records of a certain type.
prefilter
- 2-element tuple (prefilter/0
) indicating which
sub-section of the data should be queried. Default is nil
- no prefilter.
For the given data set, get a list (sorted ascending) of unique values for
field_name
under entity_name
. Returns nil
if no data is found.
@spec get_uniques_map(t(), atom(), prefilter(), atom()) :: Indexed.UniquesBundle.counts_map()
For the given prefilter
, get a map where keys are unique values for
field_name
under entity_name
and vals are occurrence counts. Returns
nil
if no data is found.
@spec get_view(t(), atom(), Indexed.View.fingerprint()) :: Indexed.View.t() | nil
Get a particular view struct (view metadata) by its fingerprint.
@spec get_views(t(), atom()) :: %{ required(Indexed.View.fingerprint()) => Indexed.View.t() }
Get a map of fingerprints to view structs (view metadata).
@spec index_key(atom(), prefilter(), order_hint()) :: String.t()
Cache key for a given entity, field and direction.
Cache key for a lookup map of the given entity's records:
%{"Some Field Value" => [123, 456]}
Gets an ETS table reference or name for an entity name.
Default with no entity_name
is indexes table ref.
Build an ETS table name from its namespace and entity_name.
Cache key holding unique values for a given entity and field.
Cache key holding unique values & counts for a given entity and field.
Cache key holding views/0
for a certain entity.