summaryrefslogtreecommitdiffstats
path: root/include/util
diff options
context:
space:
mode:
authorDouglas Rumbaugh <dbr4@psu.edu>2023-05-22 14:58:22 -0400
committerDouglas Rumbaugh <dbr4@psu.edu>2023-05-22 14:58:22 -0400
commit0cf160ee68d37be93665e665ef22ae6e211a157d (patch)
treebadaca4c5654e7abbe9291b18b08748aeeadc518 /include/util
parent08d6c84b9d69b500c964a8ff66e726e1f01f2095 (diff)
downloaddynamic-extension-0cf160ee68d37be93665e665ef22ae6e211a157d.tar.gz
More updates/restructuring
Diffstat (limited to 'include/util')
-rw-r--r--include/util/Cursor.h2
-rw-r--r--include/util/Record.h121
2 files changed, 1 insertions, 122 deletions
diff --git a/include/util/Cursor.h b/include/util/Cursor.h
index 2609ae5..815458c 100644
--- a/include/util/Cursor.h
+++ b/include/util/Cursor.h
@@ -10,7 +10,7 @@
#pragma once
#include "util/base.h"
-#include "util/Record.h"
+#include "framework/RecordInterface.h"
#include "io/PagedFile.h"
namespace de {
diff --git a/include/util/Record.h b/include/util/Record.h
deleted file mode 100644
index fc543ed..0000000
--- a/include/util/Record.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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 <concepts>
-
-#include "util/base.h"
-
-namespace de {
-
-template<typename R>
-concept RecordInterface = requires(R r, R s) {
- r.key;
- r.value;
-
- { r < s } ->std::convertible_to<bool>;
- { r == s } ->std::convertible_to<bool>;
-};
-
-template<RecordInterface R>
-struct WrappedRecord {
- R rec;
- uint32_t header;
-
- inline void set_delete() {
- header |= 2;
- }
-
- inline bool is_deleted() const {
- return header & 2;
- }
-
- inline void set_tombstone(bool val=true) {
- if (val) {
- header |= val;
- } else {
- header &= 0;
- }
- }
-
- inline bool is_tombstone() const {
- return header & 1;
- }
-};
-
-template <typename R>
-concept WeightedRecordInterface = RecordInterface<R> && requires(R r) {
- {r.weight} -> std::convertible_to<double>;
-};
-
-template <typename K, typename V>
-struct Record {
- K key;
- V value;
- uint32_t header = 0;
-
- inline bool operator<(const Record& other) const {
- return key < other.key || (key == other.key && value < other.value);
- }
-
- inline bool operator==(const Record& other) const {
- return key == other.key && value == other.value;
- }
-};
-
-template <typename K, typename V, typename W>
-struct WeightedRecord {
- K key;
- V value;
- W weight = 1;
- uint32_t header = 0;
-
- inline void set_delete() {
- header |= 2;
- }
-
- inline bool is_deleted() const {
- return header & 2;
- }
-
- inline void set_tombstone(bool val=true) {
- if (val) {
- header |= val;
- } else {
- header &= 0;
- }
- }
-
- inline bool is_tombstone() const {
- return header & 1;
- }
-
- inline int match(const WeightedRecord* other) const {
- return key == other->key && value == other->value;
- }
-
- inline bool operator<(const WeightedRecord& other) const {
- return key < other.key || (key == other.key && value < other.value);
- }
-
- inline bool operator==(const WeightedRecord& other) const {
- return key == other.key && value == other.value;
- }
-};
-
-
-template <RecordInterface R>
-static bool memtable_record_cmp(const R& a, const R& 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);
-}
-
-}