summaryrefslogtreecommitdiffstats
path: root/include/util/types.h
diff options
context:
space:
mode:
authorDouglas B. Rumbaugh <dbr4@psu.edu>2024-12-06 13:13:51 -0500
committerGitHub <noreply@github.com>2024-12-06 18:13:51 +0000
commit9fe305c7d28e993e55c55427f377ae7e3251ea4f (patch)
tree384b687f64b84eb81bde2becac8a5f24916b07b4 /include/util/types.h
parent47916da2ba5ed5bee2dda3cbcc58d39e1e931bfc (diff)
downloaddynamic-extension-9fe305c7d28e993e55c55427f377ae7e3251ea4f.tar.gz
Interface update (#5)
* Query Interface Adjustments/Refactoring Began the process of adjusting the query interface (and also the shard interface, to a lesser degree) to better accommodate the user. In particular the following changes have been made, 1. The number of necessary template arguments for the query type has been drastically reduced, while also removing the void pointers and manual delete functions from the interface. This was accomplished by requiring many of the sub-types associated with a query (parameters, etc.) to be nested inside the main query class, and by forcing the SHARD type to expose its associated record type. 2. User-defined query return types are now supported. Queries no longer are required to return strictly sets of records. Instead, the query now has LocalResultType and ResultType template parameters (which can be defaulted using a typedef in the Query type itself), allowing much more flexibility. Note that, at least for the short term, the LocalResultType must still expose the same is_deleted/is_tombstone interface as a Wrapped<R> used to, as this is currently needed for delete filtering. A better approach to this is, hopefully, forthcoming. 3. Updated the ISAMTree.h shard and rangequery.h query to use the new interfaces, and adjusted the associated unit tests as well. 4. Dropped the unnecessary "get_data()" function from the ShardInterface concept. 5. Dropped the need to specify a record type in the ShardInterface concept. This is now handled using a required Shard::RECORD member of the Shard class itself, which should expose the name of the record type. * Updates to framework to support new Query/Shard interfaces Pretty extensive adjustments to the framework, particularly to the templates themselves, along with some type-renaming work, to support the new query and shard interfaces. Adjusted the external query interface to take an rvalue reference, rather than a pointer, to the query parameters. * Removed framework-level delete filtering This was causing some issues with the new query interface, and should probably be reworked anyway, so I'm temporarily (TM) removing the feature. * Updated benchmarks + remaining code for new interface
Diffstat (limited to 'include/util/types.h')
-rw-r--r--include/util/types.h119
1 files changed, 57 insertions, 62 deletions
diff --git a/include/util/types.h b/include/util/types.h
index cf61412..b8a1343 100644
--- a/include/util/types.h
+++ b/include/util/types.h
@@ -1,7 +1,7 @@
/*
* include/util/types.h
*
- * Copyright (C) 2023 Douglas B. Rumbaugh <drumbaugh@psu.edu>
+ * Copyright (C) 2023-2024 Douglas B. Rumbaugh <drumbaugh@psu.edu>
*
* Distributed under the Modified BSD License.
*
@@ -17,10 +17,10 @@
*/
#pragma once
+#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <vector>
-#include <cassert>
namespace de {
@@ -30,14 +30,14 @@ typedef uint32_t PageNum;
/*
* Byte offset within a page. Also used for lengths of records, etc.,
* within the codebase. size_t isn't necessary, as the maximum offset
- * is only parm::PAGE_SIZE
+ * is only parm::PAGE_SIZE
*/
typedef uint16_t PageOffset;
/* A unique identifier for a frame within a buffer or cache */
typedef int32_t FrameId;
-/*
+/*
* A unique timestamp for use in MVCC concurrency control. Currently stored in
* record headers, but not used by anything.
*/
@@ -45,7 +45,7 @@ typedef uint32_t Timestamp;
const Timestamp TIMESTAMP_MIN = 0;
const Timestamp TIMESTAMP_MAX = UINT32_MAX;
-/*
+/*
* Invalid values for various IDs. Used throughout the code base to indicate
* uninitialized values and error conditions.
*/
@@ -60,90 +60,85 @@ const FrameId INVALID_FRID = -1;
* as a contiguous index space.
*/
struct ShardID {
- ssize_t level_idx;
- ssize_t shard_idx;
+ ssize_t level_idx;
+ ssize_t shard_idx;
- friend bool operator==(const ShardID &shid1, const ShardID &shid2) {
- return shid1.level_idx == shid2.level_idx && shid1.shard_idx == shid2.shard_idx;
- }
+ friend bool operator==(const ShardID &shid1, const ShardID &shid2) {
+ return shid1.level_idx == shid2.level_idx &&
+ shid1.shard_idx == shid2.shard_idx;
+ }
};
-/* A placeholder for an invalid shard--also used to indicate the mutable buffer */
+/*
+ * A placeholder for an invalid shard--also used to indicate the
+ * mutable buffer
+ */
const ShardID INVALID_SHID = {-1, -1};
typedef ssize_t level_index;
typedef struct ReconstructionTask {
- std::vector<level_index> sources;
- level_index target;
- size_t reccnt;
+ std::vector<level_index> sources;
+ level_index target;
+ size_t reccnt;
- void add_source(level_index source, size_t cnt) {
- sources.push_back(source);
- reccnt += cnt;
- }
+ void add_source(level_index source, size_t cnt) {
+ sources.push_back(source);
+ reccnt += cnt;
+ }
} ReconstructionTask;
class ReconstructionVector {
public:
- ReconstructionVector()
- : total_reccnt(0) {}
+ ReconstructionVector() : total_reccnt(0) {}
- ~ReconstructionVector() = default;
+ ~ReconstructionVector() = default;
- ReconstructionTask operator[](size_t idx) {
- return m_tasks[idx];
- }
+ ReconstructionTask operator[](size_t idx) { return m_tasks[idx]; }
- void add_reconstruction(level_index source, level_index target, size_t reccnt) {
- m_tasks.push_back({{source}, target, reccnt});
- total_reccnt += reccnt;
- }
+ void add_reconstruction(level_index source, level_index target,
+ size_t reccnt) {
+ m_tasks.push_back({{source}, target, reccnt});
+ total_reccnt += reccnt;
+ }
- void add_reconstruction(ReconstructionTask task) {
- m_tasks.push_back(task);
- }
+ void add_reconstruction(ReconstructionTask task) { m_tasks.push_back(task); }
- ReconstructionTask remove_reconstruction(size_t idx) {
- assert(idx < m_tasks.size());
- auto task = m_tasks[idx];
+ ReconstructionTask remove_reconstruction(size_t idx) {
+ assert(idx < m_tasks.size());
+ auto task = m_tasks[idx];
- m_tasks.erase(m_tasks.begin() + idx);
- total_reccnt -= task.reccnt;
+ m_tasks.erase(m_tasks.begin() + idx);
+ total_reccnt -= task.reccnt;
- return task;
- }
+ return task;
+ }
- ReconstructionTask remove_smallest_reconstruction() {
- size_t min_size = m_tasks[0].reccnt;
- size_t idx = 0;
- for (size_t i=1; i<m_tasks.size(); i++) {
- if (m_tasks[i].reccnt < min_size) {
- min_size = m_tasks[i].reccnt;
- idx = i;
- }
- }
-
- auto task = m_tasks[idx];
- m_tasks.erase(m_tasks.begin() + idx);
- total_reccnt -= task.reccnt;
-
- return task;
+ ReconstructionTask remove_smallest_reconstruction() {
+ size_t min_size = m_tasks[0].reccnt;
+ size_t idx = 0;
+ for (size_t i = 1; i < m_tasks.size(); i++) {
+ if (m_tasks[i].reccnt < min_size) {
+ min_size = m_tasks[i].reccnt;
+ idx = i;
+ }
}
- size_t get_total_reccnt() {
- return total_reccnt;
- }
+ auto task = m_tasks[idx];
+ m_tasks.erase(m_tasks.begin() + idx);
+ total_reccnt -= task.reccnt;
- size_t size() {
- return m_tasks.size();
- }
+ return task;
+ }
+
+ size_t get_total_reccnt() { return total_reccnt; }
+ size_t size() { return m_tasks.size(); }
private:
- std::vector<ReconstructionTask> m_tasks;
- size_t total_reccnt;
+ std::vector<ReconstructionTask> m_tasks;
+ size_t total_reccnt;
};
-}
+} // namespace de