]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rocksdb/include/rocksdb/merge_operator.h
import 14.2.4 nautilus point release
[ceph.git] / ceph / src / rocksdb / include / rocksdb / merge_operator.h
index b90f3d72f190ab4f6a99fc6318bbc4da3a4065ee..d8ddcc6a0977d61d6951252ad7dcff33d1f76ad5 100644 (file)
@@ -108,6 +108,23 @@ class MergeOperator {
     Slice& existing_operand;
   };
 
+  // This function applies a stack of merge operands in chrionological order
+  // on top of an existing value. There are two ways in which this method is
+  // being used:
+  // a) During Get() operation, it used to calculate the final value of a key
+  // b) During compaction, in order to collapse some operands with the based
+  //    value.
+  //
+  // Note: The name of the method is somewhat misleading, as both in the cases
+  // of Get() or compaction it may be called on a subset of operands:
+  // K:    0    +1    +2    +7    +4     +5      2     +1     +2
+  //                              ^
+  //                              |
+  //                          snapshot
+  // In the example above, Get(K) operation will call FullMerge with a base
+  // value of 2 and operands [+1, +2]. Compaction process might decide to
+  // collapse the beginning of the history up to the snapshot by performing
+  // full Merge with base value of 0 and operands [+1, +2, +7, +3].
   virtual bool FullMergeV2(const MergeOperationInput& merge_in,
                            MergeOperationOutput* merge_out) const;
 
@@ -182,11 +199,11 @@ class MergeOperator {
   //       consistent MergeOperator between DB opens.
   virtual const char* Name() const = 0;
 
-  // Determines whether the MergeOperator can be called with just a single
+  // Determines whether the PartialMerge can be called with just a single
   // merge operand.
-  // Override and return true for allowing a single operand. Both FullMergeV2
-  // and PartialMerge/PartialMergeMulti should be overridden and implemented
-  // correctly to handle a single operand.
+  // Override and return true for allowing a single operand. PartialMerge
+  // and PartialMergeMulti should be overridden and implemented
+  // correctly to properly handle a single operand.
   virtual bool AllowSingleOperand() const { return false; }
 
   // Allows to control when to invoke a full merge during Get.
@@ -222,13 +239,10 @@ class AssociativeMergeOperator : public MergeOperator {
   // 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.
-  virtual bool Merge(const Slice& key,
-                     const Slice* existing_value,
-                     const Slice& value,
-                     std::string* new_value,
+  virtual bool Merge(const Slice& key, const Slice* existing_value,
+                     const Slice& value, std::string* new_value,
                      Logger* logger) const = 0;
 
-
  private:
   // Default implementations of the MergeOperator functions
   bool FullMergeV2(const MergeOperationInput& merge_in,