Skip to main content

append_batch

Function append_batch 

Source
pub fn append_batch<S: Store>(
    prolly: &Prolly<S>,
    tree: &Tree,
    mutations: Vec<Mutation>,
) -> Result<Tree, Error>
Expand description

Apply mutations optimized for append-only workloads.

This function is optimized for the case where all mutations have keys greater than all existing keys in the tree (append-only pattern). It avoids the O(m × h) cost of find_path by directly building new leaves and appending them to the tree.

§Arguments

  • prolly - Reference to the Prolly tree manager
  • tree - The tree to modify
  • mutations - Vector of mutations to apply (should be Upserts with keys > all existing)

§Returns

  • Ok(Tree) - New tree with all mutations applied
  • Err(Error) - On storage or processing errors

§Performance

  • O(m) for building new leaves (vs O(m × h) for regular batch)
  • O(h) for updating the rightmost path
  • Best for sequential/append-only insert patterns

§Note

If mutations contain keys that overlap with existing data, this function falls back to the regular apply_batch for correctness.