Bedrock (bedrock v0.6.0)

View Source

Core types and utilities for Bedrock, a distributed key-value store.

This module defines the fundamental types used throughout the Bedrock system, including keys, values, versions, and time-related constructs for MVCC transaction processing.

Summary

Functions

The end-of-keyspace sentinel value.

Creates a key range from a minimum inclusive key to a maximum exclusive key.

Types

epoch()

@type epoch() :: non_neg_integer()

interval()

@type interval() :: {time_unit(), non_neg_integer()}

interval_in_ms()

@type interval_in_ms() :: :infinity | non_neg_integer()

interval_in_us()

@type interval_in_us() :: :infinity | non_neg_integer()

key()

@type key() :: binary()

key_range()

@type key_range() :: {min_inclusive :: key(), max_exclusive :: key()}

key_value()

@type key_value() :: {key(), value()}

lock_token()

@type lock_token() :: binary()

mutation()

@type mutation() ::
  {:set, key(), value()}
  | {:clear, key()}
  | {:clear_range, key(), key()}
  | {:atomic, :add, key(), value()}
  | {:atomic, :min, key(), value()}
  | {:atomic, :max, key(), value()}
  | {:atomic, :bit_and, key(), value()}
  | {:atomic, :bit_or, key(), value()}
  | {:atomic, :bit_xor, key(), value()}
  | {:atomic, :byte_min, key(), value()}
  | {:atomic, :byte_max, key(), value()}
  | {:atomic, :append_if_fits, key(), value()}
  | {:atomic, :compare_and_clear, key(), value()}

quorum()

@type quorum() :: pos_integer()

range_tag()

@type range_tag() :: non_neg_integer()

service()

@type service() :: :coordination | :log | :materializer

service_id()

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

time_unit()

@type time_unit() :: Bedrock.Internal.Time.Interval.unit()

timeout_in_ms()

@type timeout_in_ms() :: :infinity | non_neg_integer()

timestamp_in_ms()

@type timestamp_in_ms() :: integer()

transaction()

@type transaction() :: binary()

transaction_map()

@type transaction_map() :: %{
  optional(:mutations) => [mutation()] | nil,
  optional(:write_conflicts) => [key_range()] | nil,
  optional(:read_conflicts) => {version(), [key_range()]} | nil,
  optional(:commit_version) => version() | nil,
  optional(:shard_index) => [{non_neg_integer(), non_neg_integer()}] | nil
}

value()

@type value() :: binary()

version()

@type version() :: Bedrock.DataPlane.Version.t()

version_vector()

@type version_vector() :: {available_after :: version(), last_inclusive :: version()}

Functions

end_of_keyspace()

@spec end_of_keyspace() :: key()

The end-of-keyspace sentinel value.

This binary value is lexicographically greater than any valid key and is used to represent unbounded key ranges. For ergonomics, the atom :end is also accepted in the public API and is automatically converted to this sentinel.

key_range(min_key, max_key_exclusive)

@spec key_range(key(), key() | :end) :: key_range()

Creates a key range from a minimum inclusive key to a maximum exclusive key.

For convenience, the atom :end is accepted as max_key_exclusive to represent an unbounded range, and is automatically converted to the end-of-keyspace sentinel.

Parameters

  • min_key: The minimum key value (inclusive).
  • max_key_exclusive: The maximum key value (exclusive), or :end for unbounded.

Returns

  • A tuple representing the key range.

Examples

iex> Bedrock.key_range("a", "z")
{"a", "z"}

iex> Bedrock.key_range("a", :end)
{"a", <<0xFF, 0xFF>>}