Bedrock.Internal.TransactionBuilder.LayoutIndex (bedrock v0.6.0)
View SourcePre-computed index for efficient Transaction System Layout lookups.
This module builds a gb_tree index from the static TSL configuration by segmenting the keyspace into non-overlapping ranges. Each segment shows exactly which PIDs are responsible for that portion of the keyspace, enabling O(log n) lookups instead of O(n) linear scans through all storage teams.
Segmented Keyspace Example
Given overlapping storage teams:
- a-f → [pid1]
- d-m → [pid2]
- h-p → [pid3]
The index creates non-overlapping segments:
- {a, d} → [pid1]
- {d, f} → [pid1, pid2]
- {f, h} → [pid2]
- {h, m} → [pid2, pid3]
- {m, p} → [pid3]
Summary
Functions
Builds a segmented index from a Transaction System Layout.
Finds the next segment after the one containing the given key.
Finds the previous segment before the one containing the given key.
Looks up storage servers for a single key using recursive tree traversal.
Looks up storage servers for a key range.
Types
Functions
@spec build_index(Bedrock.ControlPlane.Config.TransactionSystemLayout.t()) :: t()
Builds a segmented index from a Transaction System Layout.
Finds the next segment after the one containing the given key.
This is useful for cross-shard KeySelector resolution when we need to continue processing in the next shard.
@spec get_previous_segment(t(), binary()) :: {:ok, {{binary(), binary()}, [pid()]}} | :start_of_keyspace
Finds the previous segment before the one containing the given key.
This is useful for cross-shard KeySelector resolution when we need to continue processing in the previous shard.
Looks up storage servers for a single key using recursive tree traversal.
Returns a {key_range, [pid]} tuple for the segment containing the key.
The end key will be the binary sentinel <<0xFF, 0xFF>> for unbounded ranges.
Raises if no segment is found. This is an O(log n) operation.
Looks up storage servers for a key range.
Returns a list of {key_range, [pid]} tuples for all segments that overlap
with the specified range. Each segment shows exactly which PIDs cover
that portion of the keyspace. End keys will be the binary sentinel <<0xFF, 0xFF>>
for unbounded ranges.