Ferricstore.Store.BlobRef (ferricstore v0.4.3)

Copy Markdown View Source

Fixed-size side-channel reference for large-value blob storage.

Version 1 refs are legacy content-addressed files. Version 2 refs point at a payload range in a shard append segment and carry a checksum so materialized reads and apply-time validation can still prove byte integrity.

Summary

Functions

Decodes a Bitcask value when it is exactly a blob ref.

Encodes a ref as the exact fixed binary stored in Bitcask.

Returns the fixed encoded byte size stored in Bitcask for new refs.

Returns true when a persisted value size can hold an encoded blob ref.

Builds a content-addressed ref from payload bytes.

Builds an append-segment ref from payload bytes and its segment location.

Returns the canonical blob file path for a ref.

Returns true when value is an encoded blob ref.

Returns the shard-local relative blob path for a ref.

Returns the canonical append-segment filename for a segment id.

Returns true when a BlobRef struct has a supported shape.

Verifies that payload bytes match a ref's checksum and size.

Types

t()

@type t() :: %Ferricstore.Store.BlobRef{
  checksum: <<_::256>>,
  offset: non_neg_integer() | nil,
  segment_id: non_neg_integer() | nil,
  size: non_neg_integer(),
  version: 1 | 2
}

Functions

decode(arg1)

@spec decode(binary()) :: {:ok, t()} | :error

Decodes a Bitcask value when it is exactly a blob ref.

encode!(arg1)

@spec encode!(t()) :: binary()

Encodes a ref as the exact fixed binary stored in Bitcask.

encoded_size()

@spec encoded_size() :: pos_integer()

Returns the fixed encoded byte size stored in Bitcask for new refs.

encoded_size?(size)

@spec encoded_size?(term()) :: boolean()

Returns true when a persisted value size can hold an encoded blob ref.

from_payload(payload)

@spec from_payload(binary()) :: t()

Builds a content-addressed ref from payload bytes.

from_segment(payload, segment_id, offset)

@spec from_segment(binary(), non_neg_integer(), non_neg_integer()) :: t()

Builds an append-segment ref from payload bytes and its segment location.

path(data_dir, shard_index, ref)

@spec path(binary(), non_neg_integer(), t()) :: binary()

Returns the canonical blob file path for a ref.

ref?(value)

@spec ref?(term()) :: boolean()

Returns true when value is an encoded blob ref.

relative_path(blob_ref)

@spec relative_path(t()) :: binary()

Returns the shard-local relative blob path for a ref.

segment_filename(segment_id)

@spec segment_filename(non_neg_integer()) :: binary()

Returns the canonical append-segment filename for a segment id.

valid?(arg1)

@spec valid?(term()) :: boolean()

Returns true when a BlobRef struct has a supported shape.

verify_payload?(arg1, payload)

@spec verify_payload?(t(), binary()) :: boolean()

Verifies that payload bytes match a ref's checksum and size.