Vettore.Store behaviour (Vettore v0.3.2)

Copy Markdown View Source

Storage behaviour for Vettore collections.

Stores own records and metadata. Indexes and native accelerators are separate from this layer so ETS can remain the canonical source of collection state.

Summary

Types

config()

@type config() :: map()

id()

@type id() :: String.t()

state()

@type state() :: term()

Callbacks

alive?(state)

(optional)
@callback alive?(state()) :: boolean()

all(state)

@callback all(state()) :: {:ok, [Vettore.Embedding.t()]} | {:error, term()}

close(state)

(optional)
@callback close(state()) :: :ok | {:error, term()}

configure(state, config)

(optional)
@callback configure(state(), config()) :: :ok | {:error, term()}

count(state)

@callback count(state()) :: non_neg_integer()

delete(state, id)

@callback delete(state(), id()) :: :ok | {:error, term()}

fold(state, acc, function)

@callback fold(state(), acc, (Vettore.Embedding.t(), acc -> acc)) :: {:ok, acc}
when acc: term()

get(state, id)

@callback get(state(), id()) :: {:ok, Vettore.Embedding.t()} | {:error, term()}

load_snapshot(t)

@callback load_snapshot(Path.t()) :: {:ok, {state(), config()}} | {:error, term()}

new(config)

@callback new(config()) :: {:ok, state()} | {:error, term()}

put(state, t)

@callback put(state(), Vettore.Embedding.t()) :: :ok | {:error, term()}

put_many(state, list)

@callback put_many(state(), [Vettore.Embedding.t()]) :: :ok | {:error, term()}

snapshot(state, t)

@callback snapshot(state(), Path.t()) :: :ok | {:error, term()}