summaryrefslogtreecommitdiffstats
path: root/include/util/record.h
diff options
context:
space:
mode:
authorDouglas Rumbaugh <dbr4@psu.edu>2023-05-08 12:59:46 -0400
committerDouglas Rumbaugh <dbr4@psu.edu>2023-05-08 12:59:46 -0400
commitfdf5ef27fec1368a33801a98bbc5ed3556476979 (patch)
tree7ecd9477fed6495d05a44343e19bfb6480785c7a /include/util/record.h
parent2380dd4d73cd6a179567e06e1aa4871ad44ccce3 (diff)
downloaddynamic-extension-fdf5ef27fec1368a33801a98bbc5ed3556476979.tar.gz
Began porting source files over from other repository
Diffstat (limited to 'include/util/record.h')
-rw-r--r--include/util/record.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/include/util/record.h b/include/util/record.h
new file mode 100644
index 0000000..0ba0f97
--- /dev/null
+++ b/include/util/record.h
@@ -0,0 +1,65 @@
+/*
+ * include/util/record.h
+ *
+ * Copyright (C) 2023 Douglas Rumbaugh <drumbaugh@psu.edu>
+ * Dong Xie <dongx@psu.edu>
+ *
+ * All rights reserved. Published under the Modified BSD License.
+ *
+ */
+#pragma once
+
+#include <cstring>
+
+#include "util/base.h"
+
+namespace de {
+
+typedef uint32_t hdr_t;
+typedef uint64_t key_t;
+typedef uint32_t value_t;
+typedef uint64_t weight_t;
+
+struct record_t {
+ key_t key;
+ value_t value;
+ hdr_t header;
+ weight_t weight;
+
+ inline bool match(key_t k, value_t v, bool is_tombstone) const {
+ return (key == k) && (value == v) && ((header & 1) == is_tombstone);
+ }
+
+ inline void set_delete_status() {
+ header |= 2;
+ }
+
+ inline bool get_delete_status() const {
+ return header & 2;
+ }
+
+ inline bool is_tombstone() const {
+ return header & 1;
+ }
+
+ inline int match(const record_t* other) const {
+ return key == other->key && value == other->value;
+ }
+
+ inline bool operator<(const record_t& other) const {
+ return key < other.key || (key == other.key && value < other.value);
+ }
+
+ inline bool lt(const key_t& k, const value_t& v) const {
+ return key < k || (key == k && value < v);
+ }
+};
+
+static_assert(sizeof(record_t) == 24, "Record is not 24 bytes long.");
+
+static bool memtable_record_cmp(const record_t& a, const record_t& b) {
+ return (a.key < b.key) || (a.key == b.key && a.value < b.value)
+ || (a.key == b.key && a.value == b.value && a.header < b.header);
+}
+
+}