[][src]Trait rocks::merge_operator::AssociativeMergeOperator

pub trait AssociativeMergeOperator {
    fn merge(
        &self,
        key: &[u8],
        existing_value: Option<&[u8]>,
        value: &[u8],
        logger: &Logger
    ) -> Option<Vec<u8>>; fn name(&self) -> &str { ... } }

AssociativeMergeOperator - for most simple semantics (always take two values, and merge them into one value, which is then put back into rocksdb); numeric addition and string concatenation are examples;

Required methods

fn merge(
    &self,
    key: &[u8],
    existing_value: Option<&[u8]>,
    value: &[u8],
    logger: &Logger
) -> Option<Vec<u8>>

Gives the client a way to express the read -> modify -> write semantics

Arguments

  • key - (IN) The key that's associated with this merge operation.
  • existing_value - (IN) null indicates the key does not exist before this op
  • value - (IN) the value to update/merge the existing_value with
  • new_value - (OUT) Client is responsible for filling the merge result here. The string that new_value is pointing to will be empty.
  • logger - (IN) Client could use this to log errors during merge.

Return true on success.

All values passed in will be client-specific values. So if this method returns false, it is because client specified bad data or there was internal corruption. The client should assume that this will be treated as an error by the library.

Loading content...

Provided methods

fn name(&self) -> &str

The name of the MergeOperator. Used to check for MergeOperator mismatches (i.e., a DB created with one MergeOperator is accessed using a different MergeOperator)

TODO: the name is currently not stored persistently and thus no checking is enforced. Client is responsible for providing consistent MergeOperator between DB opens.

Loading content...

Implementors

Loading content...