Bedrock.DataPlane.Materializer.Olivine.Database (bedrock v0.6.0)
View SourceDatabase handle for Olivine storage, combining data and index databases.
Summary
Functions
Compacts the database files by building new files with sequential data layout.
Load durable version directly from storage. This is useful for background processes that may have a stale database struct.
Store a value in the lookaside buffer for the given version and key. This is used during transaction application for values within the window.
Returns a value loader function that captures only the minimal data needed for async value resolution tasks. Avoids copying the entire Database struct.
Types
@type locator() :: Bedrock.DataPlane.Materializer.Olivine.DataDatabase.locator()
Functions
@spec advance_durable_version( t(), version :: Bedrock.version(), previous_durable_version :: Bedrock.version(), data_size_in_bytes :: pos_integer(), collected_pages :: [ %{ required(Bedrock.DataPlane.Materializer.Olivine.Index.Page.id()) => {Bedrock.DataPlane.Materializer.Olivine.Index.Page.t(), Bedrock.DataPlane.Materializer.Olivine.Index.Page.id()} } ] ) :: {:ok, t(), metadata :: map()} | {:error, {:data_flush_failed, term()}} | {:error, {:index_flush_failed, term()}}
@spec close(t()) :: :ok
@spec compact( t(), complete_page_map :: %{ required(Bedrock.DataPlane.Materializer.Olivine.Index.Page.id()) => {Bedrock.DataPlane.Materializer.Olivine.Index.Page.t(), Bedrock.DataPlane.Materializer.Olivine.Index.Page.id()} }, writer_module :: module(), writer :: Bedrock.DataPlane.Materializer.Olivine.CompactionWriter.t() ) :: {:ok, Bedrock.DataPlane.Materializer.Olivine.CompactionWriter.result(), compacted_pages :: %{ required(Bedrock.DataPlane.Materializer.Olivine.Index.Page.id()) => {Bedrock.DataPlane.Materializer.Olivine.Index.Page.t(), Bedrock.DataPlane.Materializer.Olivine.Index.Page.id()} }, durable_version :: Bedrock.version()} | {:error, term()}
Compacts the database files by building new files with sequential data layout.
Accepts a writer module and writer state for pluggable output format. Returns the writer result, compacted pages, and durable version.
This is run in a background task and should not block normal operations.
@spec durable_version(t()) :: Bedrock.version()
@spec load_current_durable_version(t()) :: {:ok, Bedrock.version()} | {:error, :not_found}
Load durable version directly from storage. This is useful for background processes that may have a stale database struct.
@spec load_value(t(), locator()) :: {:ok, Bedrock.value()} | {:error, :not_found}
@spec many_value_loader(t()) :: ([locator()] -> {:ok, %{required(locator()) => Bedrock.value()}} | {:error, :not_found} | {:error, :shutting_down})
@spec open(otp_name :: atom(), file_path :: String.t(), opts :: keyword()) :: {:ok, t()} | {:error, :system_limit | :badarg | File.posix()}
@spec store_value( t(), key :: Bedrock.key(), version :: Bedrock.version(), value :: Bedrock.value() ) :: {:ok, locator(), database :: t()}
Store a value in the lookaside buffer for the given version and key. This is used during transaction application for values within the window.
@spec value_loader(t()) :: (locator() -> {:ok, Bedrock.value()} | {:error, :not_found} | {:error, :shutting_down})
Returns a value loader function that captures only the minimal data needed for async value resolution tasks. Avoids copying the entire Database struct.