Bedrock.DataPlane.Materializer.Olivine.IndexUpdate (bedrock v0.6.0)
View SourceTracks mutation state during index updates.
Mutation Processing
Mutations are distributed to pages based on key ranges:
- Key Distribution: Use
Tree.page_for_key/2to find target page - Batch Processing: Group operations by page_id for efficiency
- Page Operations: Apply all operations to a page at once
- Automatic Splitting: Split pages exceeding 256 keys
- Chain Maintenance: Update page chains when pages are added/removed
Process Flow
apply_set_mutation/5: Determines target page, stores value, queues operationapply_clear_mutation/3: Queues clear operation for existing keyapply_range_clear_mutation/4: Handles range clears across multiple pagesprocess_pending_operations/1: Applies all queued operationsfinish/1: Returns final index and page allocator state
Page 0 Protection
Page 0 is never deleted, only updated. When page 0 becomes empty, it remains in the index to preserve the leftmost chain entry point.
Summary
Functions
Applies mutations to this IndexUpdate, returning the updated IndexUpdate.
Finishes the IndexUpdate, returning the final Index, Database, IdAllocator, and key change counts.
Creates an IndexUpdate for mutation tracking from an Index, version, and id allocator. Statistics tracking is disabled by default for maximum performance.
Process all pending operations for each modified page using sorted merge.
Types
@type t() :: %Bedrock.DataPlane.Materializer.Olivine.IndexUpdate{ database: Bedrock.DataPlane.Materializer.Olivine.Database.t(), id_allocator: Bedrock.DataPlane.Materializer.Olivine.IdAllocator.t(), index: Bedrock.DataPlane.Materializer.Olivine.Index.t(), keys_added: non_neg_integer(), keys_changed: non_neg_integer(), keys_removed: non_neg_integer(), modified_page_ids: MapSet.t(Bedrock.DataPlane.Materializer.Olivine.Index.Page.id()), pending_operations: %{ required(Bedrock.DataPlane.Materializer.Olivine.Index.Page.id()) => %{ required(Bedrock.key()) => {:set, Bedrock.version()} | :clear } }, track_statistics: boolean(), version: Bedrock.version() }
Functions
@spec apply_mutations( t(), Enumerable.t(Bedrock.Internal.TransactionBuilder.Tx.mutation()) ) :: t()
Applies mutations to this IndexUpdate, returning the updated IndexUpdate.
@spec finish(t()) :: {Bedrock.DataPlane.Materializer.Olivine.Index.t(), Bedrock.DataPlane.Materializer.Olivine.Database.t(), Bedrock.DataPlane.Materializer.Olivine.IdAllocator.t(), %{ required(Bedrock.DataPlane.Materializer.Olivine.Index.Page.id()) => {Bedrock.DataPlane.Materializer.Olivine.Index.Page.t(), Bedrock.DataPlane.Materializer.Olivine.Index.Page.id()} }}
Finishes the IndexUpdate, returning the final Index, Database, IdAllocator, and key change counts.
@spec new( Bedrock.DataPlane.Materializer.Olivine.Index.t(), Bedrock.version(), Bedrock.DataPlane.Materializer.Olivine.IdAllocator.t(), Bedrock.DataPlane.Materializer.Olivine.Database.t() ) :: t()
Creates an IndexUpdate for mutation tracking from an Index, version, and id allocator. Statistics tracking is disabled by default for maximum performance.
Process all pending operations for each modified page using sorted merge.