Skip to main content

MergeOperator

Trait MergeOperator 

Source
pub trait MergeOperator: Send + Sync {
    // Required method
    fn merge(
        &self,
        key: &Bytes,
        existing_value: Option<Bytes>,
        new_value: Bytes,
    ) -> Bytes;
}
Expand description

Trait for merging existing values with new values.

Merge operators must be associative: merge(merge(a, b), c) == merge(a, merge(b, c)). This ensures consistent merging behavior regardless of the order of operations.

Required Methods§

Source

fn merge( &self, key: &Bytes, existing_value: Option<Bytes>, new_value: Bytes, ) -> Bytes

Merges an existing value with a new value to produce a merged result.

§Arguments
  • key - The key associated with the values being merged
  • existing_value - The current value stored in the database (if any)
  • new_value - The new value to merge with the existing value
§Returns

The merged value.

Implementors§