Bedrock.SystemKeys.ShardMetadata (bedrock v0.5.2)

View Source

FlatBuffer schema for shard metadata.

The shard tag is encoded in the key path (\xff/system/shards/{tag}), not in this value. Genealogy fields (parents, children) will be added later when implementing splits.

Fields

  • start_key - Start of key range (inclusive)
  • end_key - End of key range (exclusive)
  • born_at - Version when shard was created
  • ended_at - Version when shard was split/merged (0 = active)

Example

# Encode
binary = ShardMetadata.to_binary(%{
  start_key: "",
  end_key: "m",
  born_at: 100,
  ended_at: 0
})

# Decode
{:ok, metadata} = ShardMetadata.read(binary)

Summary

Functions

active?(binary)

@spec active?(binary()) :: boolean()

Checks if the shard is still active (not split/merged)

fetch(buffer, path)

fetch!(buffer, path)

get(buffer, path, default \\ nil)

new(start_key, end_key, born_at)

@spec new(start_key :: binary(), end_key :: binary(), born_at :: non_neg_integer()) ::
  binary()

Creates a new shard metadata binary

read(buffer)

read!(buffer)

schema()

to_binary(map)

to_iolist(map)