View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Jiro Nishiguchi > RocksDB-0.02 > RocksDB::MergeOperator


Annotate this POD


View/Report Bugs
Source   Latest Release: RocksDB-0.04


RocksDB::MergeOperator - rocksdb::MergeOperator object


  use RocksDB;

  my $handler = MyMergeOperator->new;
  my $db = RocksDB->new('/path/to/db', {
      merge_operator => RocksDB::MergeOperator->new($handler),


RocksDB::MergeOperator is a utility class to make a rocksdb::MergeOperator object.


RocksDB::MergeOperator->new($handler :Object) :RocksDB::MergeOperator

Create and return a new RocksDB::MergeOperator object.

The $handler must respond to 'full_merge' and 'partial_merge'.

See 'HANDLER METHODS' section for more details.


$handler->full_merge($key :Str, $existing_value :Maybe[Str], $operand_list :ArrayRef[Str]) :Str

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

$key: The key that's associated with this merge operation. Client could multiplex the merge operator based on it if the key space is partitioned and different subspaces refer to different types of data which have different merge operation semantics

$existing_value: undef indicates that the key does not exist before this op

$operand_list: the sequence of merge operations to apply.

Client is responsible for returning the merge result here.

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

$handler->partial_merge($key :Str, $left_operand :Str, $right_operand :Str) :Str

This function performs merge($left_operand, $right_operand) when both the operands are themselves merge operation types that you would have passed to a $db->merge() call in the same order (i.e.: $db->merge($key,$left_op), followed by $db->merge($key,$right_op)).

PartialMerge should combine them into a single merge operation that is saved return value. Return value should be constructed such that a call to $db->merge($key, $new_value) would yield the same result as a call to $db->merge($key, $left_op) followed by $db->merge($key, $right_op).

If it is impossible or infeasible to combine the two operations, raise an error (die). The library will internally keep track of the operations, and apply them in the correct order once a base-value (a Put/Delete/End-of-Database) is seen.


RocksDB, RocksDB::AssociativeMergeOperator


Jiro Nishiguchi <>

syntax highlighting: