]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rocksdb/include/rocksdb/comparator.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / rocksdb / include / rocksdb / comparator.h
index 76981d1087eb6bb24ab861ec96d8020c4d2389b1..53a46ad33590412277b79d0a14ba465333979281 100644 (file)
@@ -42,6 +42,9 @@ class Comparator {
   //   < 0 iff "a" < "b",
   //   == 0 iff "a" == "b",
   //   > 0 iff "a" > "b"
+  // Note that Compare(a, b) also compares timestamp if timestamp size is
+  // non-zero. For the same user key with different timestamps, larger (newer)
+  // timestamp comes first.
   virtual int Compare(const Slice& a, const Slice& b) const = 0;
 
   // Compares two slices for equality. The following invariant should always
@@ -97,15 +100,27 @@ class Comparator {
 
   inline size_t timestamp_size() const { return timestamp_size_; }
 
-  virtual int CompareWithoutTimestamp(const Slice& a, const Slice& b) const {
-    return Compare(a, b);
+  int CompareWithoutTimestamp(const Slice& a, const Slice& b) const {
+    return CompareWithoutTimestamp(a, /*a_has_ts=*/true, b, /*b_has_ts=*/true);
   }
 
+  // For two events e1 and e2 whose timestamps are t1 and t2 respectively,
+  // Returns value:
+  // < 0  iff t1 < t2
+  // == 0 iff t1 == t2
+  // > 0  iff t1 > t2
+  // Note that an all-zero byte array will be the smallest (oldest) timestamp
+  // of the same length.
   virtual int CompareTimestamp(const Slice& /*ts1*/,
                                const Slice& /*ts2*/) const {
     return 0;
   }
 
+  virtual int CompareWithoutTimestamp(const Slice& a, bool /*a_has_ts*/,
+                                      const Slice& b, bool /*b_has_ts*/) const {
+    return Compare(a, b);
+  }
+
  private:
   size_t timestamp_size_;
 };