diff options
| author | Douglas Rumbaugh <dbr4@psu.edu> | 2023-05-29 14:30:08 -0400 |
|---|---|---|
| committer | Douglas Rumbaugh <dbr4@psu.edu> | 2023-05-29 14:30:08 -0400 |
| commit | e920fa57cf9c503e560055864e4de37912b239e1 (patch) | |
| tree | d0daba733c7af2b0b22f29d39de8f824ffa83472 /include/framework/RecordInterface.h | |
| parent | b00682429988f17152e7573ffeffa1cecfdd3d3a (diff) | |
| download | dynamic-extension-e920fa57cf9c503e560055864e4de37912b239e1.tar.gz | |
Adjusted the way that Wrapping records works to clean up interfaces
Diffstat (limited to 'include/framework/RecordInterface.h')
| -rw-r--r-- | include/framework/RecordInterface.h | 48 |
1 files changed, 11 insertions, 37 deletions
diff --git a/include/framework/RecordInterface.h b/include/framework/RecordInterface.h index c8e622f..70c8e01 100644 --- a/include/framework/RecordInterface.h +++ b/include/framework/RecordInterface.h @@ -26,9 +26,9 @@ concept RecordInterface = requires(R r, R s) { }; template<RecordInterface R> -struct WrappedRecord : R { - //R rec; +struct Wrapped { uint32_t header; + R rec; inline void set_delete() { header |= 2; @@ -49,8 +49,14 @@ struct WrappedRecord : R { inline bool is_tombstone() const { return header & 1; } + + inline bool operator<(const Wrapped& other) const { + return (rec.key < other.rec.key) || (rec.key == other.rec.key && rec.value < other.rec.value) + || (rec.key == other.rec.key && rec.value == other.rec.value && header < other.header); + } }; + template <typename R> concept WeightedRecordInterface = RecordInterface<R> && requires(R r) { {r.weight} -> std::convertible_to<double>; @@ -76,46 +82,14 @@ 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 && value == other.value; } - inline bool operator<(const WeightedRecord& other) const { + 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); -} - } |