From 5b1960ccbdda1a99ccd22638bb4721ee5c4c3331 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Mon, 8 May 2023 13:30:20 -0400 Subject: 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. --- include/util/Cursor.h | 14 ++++----- include/util/Record.h | 65 ++++++++++++++++++++++++++++++++++++++++++ include/util/internal_record.h | 2 +- include/util/record.h | 65 ------------------------------------------ 4 files changed, 73 insertions(+), 73 deletions(-) create mode 100644 include/util/Record.h delete mode 100644 include/util/record.h (limited to 'include') diff --git a/include/util/Cursor.h b/include/util/Cursor.h index 3f5f20f..2879830 100644 --- a/include/util/Cursor.h +++ b/include/util/Cursor.h @@ -10,13 +10,13 @@ #pragma once #include "util/base.h" -#include "util/record.h" +#include "util/Record.h" #include "io/PagedFile.h" namespace de { struct Cursor { - record_t *ptr; - const record_t *end; + Record *ptr; + const Record *end; size_t cur_rec_idx; size_t rec_cnt; @@ -45,8 +45,8 @@ inline static bool advance_cursor(Cursor *cur, PagedFileIterator *iter = nullptr if (cur->ptr >= cur->end) { if (iter && iter->next()) { - cur->ptr = (record_t*)iter->get_item(); - cur->end = cur->ptr + (PAGE_SIZE / sizeof(record_t)); + cur->ptr = (Record*)iter->get_item(); + cur->end = cur->ptr + (PAGE_SIZE / sizeof(Record)); return true; } @@ -63,12 +63,12 @@ inline static bool advance_cursor(Cursor *cur, PagedFileIterator *iter = nullptr * largest is processed. */ inline static Cursor *get_next(std::vector &cursors, Cursor *current=&g_empty_cursor) { - const record_t *min_rec = nullptr; + const Record *min_rec = nullptr; Cursor *result = &g_empty_cursor; for (size_t i=0; i< cursors.size(); i++) { if (cursors[i] == g_empty_cursor) continue; - const record_t *rec = (&cursors[i] == current) ? cursors[i].ptr + 1 : cursors[i].ptr; + const Record *rec = (&cursors[i] == current) ? cursors[i].ptr + 1 : cursors[i].ptr; if (rec >= cursors[i].end) continue; if (min_rec == nullptr) { 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 + * Dong Xie + * + * All rights reserved. Published under the Modified BSD License. + * + */ +#pragma once + +#include + +#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); +} + +} diff --git a/include/util/internal_record.h b/include/util/internal_record.h index d898b8b..003cddb 100644 --- a/include/util/internal_record.h +++ b/include/util/internal_record.h @@ -9,7 +9,7 @@ #pragma once #pragma once -#include "util/record.h" +#include "util/Record.h" #include "util/types.h" /* diff --git a/include/util/record.h b/include/util/record.h deleted file mode 100644 index 0ba0f97..0000000 --- a/include/util/record.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * include/util/record.h - * - * Copyright (C) 2023 Douglas Rumbaugh - * Dong Xie - * - * All rights reserved. Published under the Modified BSD License. - * - */ -#pragma once - -#include - -#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); -} - -} -- cgit v1.2.3