Bedrock.DataPlane.Version (bedrock v0.5.2)

View Source

Version utilities for Bedrock's MVCC system. Versions are 8-byte big-endian unsigned integers.

Summary

Functions

Adds an integer offset to a version

Compares two versions

Calculates the integer difference between two versions (v1 - v2)

Checks if version is the first version (zero)

Creates a version from a binary representation

Creates a version from a non-negative integer

Increments a version by 1

Checks if first version is newer than second version

Checks if first version is older than second version

Generates a sequence of versions starting from base + 1, base + 2, ..., base + count

Subtracts an integer offset from a version

Converts a version to integer representation

Converts a version to string representation for display

Validates if value is a valid version binary

Creates a zero version (initial version)

Types

t()

@type t() :: binary()

Functions

add(arg, offset)

@spec add(t(), integer()) :: t()

Adds an integer offset to a version

compare(v1, v2)

@spec compare(t(), t()) :: :lt | :eq | :gt

Compares two versions

distance(arg1, arg2)

@spec distance(t(), t()) :: integer()

Calculates the integer difference between two versions (v1 - v2)

first?(version)

@spec first?(t()) :: boolean()

Checks if version is the first version (zero)

from_bytes(version)

@spec from_bytes(binary()) :: t()

Creates a version from a binary representation

from_integer(int)

@spec from_integer(non_neg_integer()) :: t()

Creates a version from a non-negative integer

increment(arg)

@spec increment(t()) :: t()

Increments a version by 1

is_version(value)

(macro)

newer?(version, last_version)

@spec newer?(t(), t()) :: boolean()

Checks if first version is newer than second version

older?(version, last_version)

@spec older?(t(), t()) :: boolean()

Checks if first version is older than second version

sequence(base_version, count)

@spec sequence(t(), pos_integer()) :: [t()]

Generates a sequence of versions starting from base + 1, base + 2, ..., base + count

subtract(version, offset)

@spec subtract(t(), integer()) :: t()

Subtracts an integer offset from a version

to_integer(arg)

@spec to_integer(t()) :: non_neg_integer()

Converts a version to integer representation

to_string(version)

@spec to_string(t() | nil) :: String.t()

Converts a version to string representation for display

valid?(arg1)

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

Validates if value is a valid version binary

zero()

@spec zero() :: t()

Creates a zero version (initial version)