Bedrock.DataPlane.Log.Shale.Segment (bedrock v0.5.2)

View Source

Represents a segment of the Shale transaction log.

Summary

Types

t()

@type t() :: %Bedrock.DataPlane.Log.Shale.Segment{
  min_version: Bedrock.version(),
  path: String.t(),
  transactions: nil | [Bedrock.DataPlane.Transaction.encoded()]
}

Functions

allocate_from_recycler(segment_recycler, path, version)

@spec allocate_from_recycler(
  Bedrock.DataPlane.Log.Shale.SegmentRecycler.server(),
  String.t(),
  Bedrock.version()
) :: {:ok, t()} | {:error, :allocation_failed}

allocate_from_recycler!(segment_recycler, path, version)

@spec allocate_from_recycler!(
  Bedrock.DataPlane.Log.Shale.SegmentRecycler.server(),
  String.t(),
  Bedrock.version()
) :: t()

decode_file_name(arg)

@spec decode_file_name(String.t()) :: pos_integer()

encode_file_name(n)

@spec encode_file_name(pos_integer()) :: String.t()

ensure_transactions_are_loaded(segment)

@spec ensure_transactions_are_loaded(t()) :: t()

file_prefix()

@spec file_prefix() :: String.t()

from_path(path_to_file)

@spec from_path(path_to_file :: String.t()) :: {:ok, t()} | {:error, :does_not_exist}

Create a new segment from the given file path. We stat the file to get the size, ensuring that it exists.

last_version(map)

@spec last_version(t()) :: Bedrock.version() | nil

oldest_version(map)

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

return_to_recycler(segment, segment_recycler)

@spec return_to_recycler(t(), Bedrock.DataPlane.Log.Shale.SegmentRecycler.server()) ::
  :ok

transactions(segment)

@spec transactions(t()) :: [Bedrock.DataPlane.Transaction.encoded()]