[Commits] 56846855b: TEST PATCH: Range Locking uses memcmp() comparator.

psergey sergey at mariadb.com
Mon Jun 14 22:25:55 EEST 2021


revision-id: 56846855b351a199d707e1b44c2d5f70e77d5535 (v5.8-3395-g56846855b)
parent(s): c0a4e59baa6e46f6e80d6ba049058b367c3a5c94
author: Sergei Petrunia
committer: Sergei Petrunia
timestamp: 2021-06-14 22:25:34 +0300
message:

TEST PATCH: Range Locking uses memcmp() comparator.

---
 .../lock/range/range_tree/lib/ft/comparator.h      | 26 ++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/utilities/transactions/lock/range/range_tree/lib/ft/comparator.h b/utilities/transactions/lock/range/range_tree/lib/ft/comparator.h
index 718efc623..d337eb566 100644
--- a/utilities/transactions/lock/range/range_tree/lib/ft/comparator.h
+++ b/utilities/transactions/lock/range/range_tree/lib/ft/comparator.h
@@ -68,6 +68,27 @@ int toku_builtin_compare_fun(const DBT *, const DBT *)
 
 namespace toku {
 
+inline int toku_keycompare2(const void *key1, size_t key1len, const void *key2,
+                    size_t key2len) {
+  size_t comparelen = key1len < key2len ? key1len : key2len;
+  int c = memcmp(key1, key2, comparelen);
+  if (__builtin_expect(c != 0, 1)) {
+    return c;
+  } else {
+    if (key1len < key2len) {
+      return -1;
+    } else if (key1len > key2len) {
+      return 1;
+    } else {
+      return 0;
+    }
+  }
+}
+
+inline int toku_builtin_compare_fun2(const DBT *a, const DBT *b) {
+  return toku_keycompare(a->data, a->size, b->data, b->size);
+}
+
 // a comparator object encapsulates the data necessary for
 // comparing two keys in a fractal tree. it further understands
 // that points may be positive or negative infinity.
@@ -115,6 +136,7 @@ class comparator {
     if (__builtin_expect(toku_dbt_is_infinite(a) || toku_dbt_is_infinite(b),
                          0)) {
       return toku_dbt_infinite_compare(a, b);
+#if 0
     } else if (_memcmp_magic != MEMCMP_MAGIC_NONE
                // If `a' has the memcmp magic..
                && dbt_has_memcmp_magic(a)
@@ -126,6 +148,10 @@ class comparator {
       // yikes, const sadness here
       return _cmp(_cmp_arg, a, b);
     }
+#endif
+    } else {
+      return toku_builtin_compare_fun2(a, b);
+    }
   }
 
  private:


More information about the commits mailing list