Bedrock.DataPlane.Materializer.Olivine.Database (bedrock v0.5.3)

View Source

Database 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

Functions

advance_durable_version(arg, version, previous_durable_version, data_size_in_bytes, collected_pages)

@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()}}

close(arg)

@spec close(t()) :: :ok

compact(arg, complete_page_map, writer_module, writer)

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.

durable_version(arg)

@spec durable_version(t()) :: Bedrock.version()

info(arg, stat)

@spec info(t(), :n_keys | :utilization | :size_in_bytes | :key_ranges) ::
  any() | :undefined

load_current_durable_version(arg)

@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.

load_value(arg, locator)

@spec load_value(t(), locator()) :: {:ok, Bedrock.value()} | {:error, :not_found}

many_value_loader(arg)

@spec many_value_loader(t()) :: ([locator()] ->
                             {:ok, %{required(locator()) => Bedrock.value()}}
                             | {:error, :not_found}
                             | {:error, :shutting_down})

open(otp_name, file_path, opts \\ [])

@spec open(otp_name :: atom(), file_path :: String.t(), opts :: keyword()) ::
  {:ok, t()} | {:error, :system_limit | :badarg | File.posix()}

store_value(arg, key, version, value)

@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.

value_loader(arg)

@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.