diff options
| author | Douglas Rumbaugh <dbr4@psu.edu> | 2023-05-08 13:30:20 -0400 |
|---|---|---|
| committer | Douglas Rumbaugh <dbr4@psu.edu> | 2023-05-08 13:30:20 -0400 |
| commit | 5b1960ccbdda1a99ccd22638bb4721ee5c4c3331 (patch) | |
| tree | 5cae945f9c3e2713f091dccfb93108d186639711 /include/util/Record.h | |
| parent | 4c2e16fee80d1f2370d37b67b06f0c09cfa8d66d (diff) | |
| download | dynamic-extension-5b1960ccbdda1a99ccd22638bb4721ee5c4c3331.tar.gz | |
Record.h: Renamed record_t to Record for POSIX compliance.
Required for compliance with POSIX B.2.12.
The other _t types, key_t, val_t, header_t, etc. will be revised later
when switching over to a templated version of this code.
Diffstat (limited to 'include/util/Record.h')
| -rw-r--r-- | include/util/Record.h | 65 |
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..7e64959 --- /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 { + 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* other) const { + return key == other->key && value == other->value; + } + + inline bool operator<(const Record& 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) == 24, "Record is not 24 bytes long."); + +static bool memtable_record_cmp(const Record& a, const Record& 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); +} + +} |