From 9876d74e503df64eb9e82e540ca41fcf593ebf64 Mon Sep 17 00:00:00 2001 From: "Douglas B. Rumbaugh" Date: Fri, 6 Dec 2024 16:54:05 -0500 Subject: Adjusted query result interfaces Now, the vector<> is part of the user-defined type, not required by the framework. This should allow for more flexibility in either using alternative containers, or for more sensible implementations of queries with single value results (like range count). --- include/query/rangequery.h | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'include/query/rangequery.h') diff --git a/include/query/rangequery.h b/include/query/rangequery.h index e7be39c..d9e7db8 100644 --- a/include/query/rangequery.h +++ b/include/query/rangequery.h @@ -38,8 +38,8 @@ public: Parameters global_parms; }; - typedef Wrapped LocalResultType; - typedef R ResultType; + typedef std::vector> LocalResultType; + typedef std::vector ResultType; constexpr static bool EARLY_ABORT = false; constexpr static bool SKIP_DELETE_FILTER = true; @@ -69,8 +69,8 @@ public: return; } - static std::vector local_query(S *shard, LocalQuery *query) { - std::vector result; + static LocalResultType local_query(S *shard, LocalQuery *query) { + LocalResultType result; /* * if the returned index is one past the end of the @@ -101,10 +101,9 @@ public: return result; } - static std::vector - local_query_buffer(LocalQueryBuffer *query) { + static LocalResultType local_query_buffer(LocalQueryBuffer *query) { - std::vector result; + LocalResultType result; for (size_t i = 0; i < query->buffer->get_record_count(); i++) { auto rec = query->buffer->get(i); if (rec->rec.key >= query->global_parms.lower_bound && @@ -116,26 +115,25 @@ public: return result; } - static void - combine(std::vector> const &local_results, - Parameters *parms, std::vector &output) { - std::vector> cursors; + static void combine(std::vector const &local_results, + Parameters *parms, ResultType &output) { + std::vector>> cursors; cursors.reserve(local_results.size()); - psudb::PriorityQueue pq(local_results.size()); + psudb::PriorityQueue> pq(local_results.size()); size_t total = 0; size_t tmp_n = local_results.size(); for (size_t i = 0; i < tmp_n; ++i) if (local_results[i].size() > 0) { auto base = local_results[i].data(); - cursors.emplace_back(Cursor{ + cursors.emplace_back(Cursor>{ base, base + local_results[i].size(), 0, local_results[i].size()}); assert(i == cursors.size() - 1); total += local_results[i].size(); pq.push(cursors[i].ptr, tmp_n - i - 1); } else { - cursors.emplace_back(Cursor{nullptr, nullptr, 0, 0}); + cursors.emplace_back(Cursor>{nullptr, nullptr, 0, 0}); } if (total == 0) { @@ -146,9 +144,8 @@ public: while (pq.size()) { auto now = pq.peek(); - auto next = pq.size() > 1 - ? pq.peek(1) - : psudb::queue_record{nullptr, 0}; + auto next = pq.size() > 1 ? pq.peek(1) + : psudb::queue_record>{nullptr, 0}; if (!now.data->is_tombstone() && next.data != nullptr && now.data->rec == next.data->rec && next.data->is_tombstone()) { @@ -156,9 +153,9 @@ public: pq.pop(); auto &cursor1 = cursors[tmp_n - now.version - 1]; auto &cursor2 = cursors[tmp_n - next.version - 1]; - if (advance_cursor(cursor1)) + if (advance_cursor>(cursor1)) pq.push(cursor1.ptr, now.version); - if (advance_cursor(cursor2)) + if (advance_cursor>(cursor2)) pq.push(cursor2.ptr, next.version); } else { auto &cursor = cursors[tmp_n - now.version - 1]; @@ -167,7 +164,7 @@ public: pq.pop(); - if (advance_cursor(cursor)) + if (advance_cursor>(cursor)) pq.push(cursor.ptr, now.version); } } @@ -175,7 +172,7 @@ public: return; } - static bool repeat(Parameters *parms, std::vector &output, + static bool repeat(Parameters *parms, ResultType &output, std::vector const &local_queries, LocalQueryBuffer *buffer_query) { return false; -- cgit v1.2.3