summaryrefslogtreecommitdiffstats
path: root/include/framework/interface/Record.h
diff options
context:
space:
mode:
authorDouglas B. Rumbaugh <dbr4@psu.edu>2024-05-14 16:31:05 -0400
committerGitHub <noreply@github.com>2024-05-14 16:31:05 -0400
commit47916da2ba5ed5bee2dda3cbcc58d39e1e931bfc (patch)
treeee5613ce182b2c9caa228d3abeb65dc27fef2db3 /include/framework/interface/Record.h
parent4a834497d5f82c817d634925250158d85ca825c2 (diff)
parent8643fe194dec05b4e3f3ea31e162ac0b2b00e162 (diff)
downloaddynamic-extension-47916da2ba5ed5bee2dda3cbcc58d39e1e931bfc.tar.gz
Merge pull request #4 from dbrumbaugh/master
Updates for VLDB revision
Diffstat (limited to 'include/framework/interface/Record.h')
-rw-r--r--include/framework/interface/Record.h49
1 files changed, 45 insertions, 4 deletions
diff --git a/include/framework/interface/Record.h b/include/framework/interface/Record.h
index 5b9f307..19ccadd 100644
--- a/include/framework/interface/Record.h
+++ b/include/framework/interface/Record.h
@@ -47,13 +47,18 @@ concept AlexInterface = KVPInterface<R> && requires(R r) {
};
template<typename R>
-concept WrappedInterface = RecordInterface<R> && requires(R r, R s, bool b) {
+concept WrappedInterface = RecordInterface<R> && requires(R r, R s, bool b, int i) {
{r.header} -> std::convertible_to<uint32_t>;
r.rec;
{r.set_delete()};
{r.is_deleted()} -> std::convertible_to<bool>;
{r.set_tombstone(b)};
{r.is_tombstone()} -> std::convertible_to<bool>;
+ {r.set_timestamp(i)};
+ {r.get_timestamp()} -> std::convertible_to<uint32_t>;
+ {r.clear_timestamp()};
+ {r.is_visible()} -> std::convertible_to<bool>;
+ {r.set_visible()};
{r < s} -> std::convertible_to<bool>;
{r == s} ->std::convertible_to<bool>;
};
@@ -71,9 +76,29 @@ struct Wrapped {
return header & 2;
}
+ inline void set_visible() {
+ header |= 4;
+ }
+
+ inline bool is_visible() const {
+ return header & 4;
+ }
+
+ inline void set_timestamp(int ts) {
+ header |= (ts << 3);
+ }
+
+ inline int get_timestamp() const {
+ return header >> 3;
+ }
+
+ inline void clear_timestamp() {
+ header &= 7;
+ }
+
inline void set_tombstone(bool val=true) {
if (val) {
- header |= val;
+ header |= 1;
} else {
header &= 0;
}
@@ -97,9 +122,8 @@ template <typename K, typename V>
struct Record {
K key;
V value;
- uint32_t header = 0;
- inline bool operator<(const Record& other) const {
+ inline bool operator<(const Record& other) const {
return key < other.key || (key == other.key && value < other.value);
}
@@ -108,6 +132,23 @@ struct Record {
}
};
+template<typename V>
+struct Record<const char*, V> {
+ const char* key;
+ V value;
+ size_t len;
+
+ inline bool operator<(const Record& other) const {
+ size_t n = std::min(len, other.len) + 1;
+ return strncmp(key, other.key, n) < 0;
+ }
+
+ inline bool operator==(const Record& other) const {
+ size_t n = std::min(len, other.len) + 1;
+ return strncmp(key, other.key, n) == 0;
+ }
+};
+
template <typename K, typename V, typename W>
struct WeightedRecord {
K key;