From ff000799c3254f52e0beabbe9c62d10c3fc4178e Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Mon, 15 May 2023 16:48:56 -0400 Subject: Record format generalization Currently, tombstone counting is bugged. But the rest of it appears to be working. --- include/util/Cursor.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'include/util/Cursor.h') diff --git a/include/util/Cursor.h b/include/util/Cursor.h index 2339800..2609ae5 100644 --- a/include/util/Cursor.h +++ b/include/util/Cursor.h @@ -14,10 +14,10 @@ #include "io/PagedFile.h" namespace de { -template +template struct Cursor { - Record *ptr; - const Record *end; + R *ptr; + R *end; size_t cur_rec_idx; size_t rec_cnt; @@ -36,8 +36,8 @@ struct Cursor { * be updated to be equal to end, and false will be returned. Iterators will * not be closed. */ -template -inline static bool advance_cursor(Cursor &cur, PagedFileIterator *iter = nullptr) { +template +inline static bool advance_cursor(Cursor &cur, PagedFileIterator *iter = nullptr) { cur.ptr++; cur.cur_rec_idx++; @@ -45,8 +45,8 @@ inline static bool advance_cursor(Cursor &cur, PagedFileIterator *iter = if (cur.ptr >= cur.end) { if (iter && iter->next()) { - cur.ptr = (Record*)iter->get_item(); - cur.end = cur.ptr + (PAGE_SIZE / sizeof(Record)); + cur.ptr = (R*)iter->get_item(); + cur.end = cur.ptr + (PAGE_SIZE / sizeof(R)); return true; } @@ -62,14 +62,14 @@ inline static bool advance_cursor(Cursor &cur, PagedFileIterator *iter = * This allows for "peaking" at the next largest element after the current * largest is processed. */ -template -inline static Cursor *get_next(std::vector> &cursors, Cursor *current=nullptr) { - const Record *min_rec = nullptr; - Cursor *result = nullptr; +template +inline static Cursor *get_next(std::vector> &cursors, Cursor *current=nullptr) { + const R *min_rec = nullptr; + Cursor *result = nullptr; for (size_t i=0; i< cursors.size(); i++) { - if (cursors[i] == (Cursor) {0} ) continue; + if (cursors[i] == (Cursor) {0} ) continue; - const Record *rec = (&cursors[i] == current) ? cursors[i].ptr + 1 : cursors[i].ptr; + const R *rec = (&cursors[i] == current) ? cursors[i].ptr + 1 : cursors[i].ptr; if (rec >= cursors[i].end) continue; if (min_rec == nullptr) { -- cgit v1.2.3