View Source Indexed (Indexed v0.0.1)
Tools for creating an index module.
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 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 the indexes.
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.
Get the ETS options to be used for any and all tables.
Get an entity by id from the index.
Get an index data structure by key.
Get 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 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.
@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: %{optional(atom()) => Indexed.Entity.t()}, index_ref: :ets.tid() }
:entities
- Map of entity name keys toIndexed.Entity.t/0
:index_ref
- ETS table reference for the indexes.
@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 ets_opts() :: keyword()
Get the ETS options to be used for any and all tables.
Get an entity by id from the index.
Get an index data structure by key.
Get an index data structure.
@spec get_records(t(), atom(), prefilter(), order_hint() | nil) :: [record()] | nil
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() | nil
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 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.