summaryrefslogtreecommitdiffstats
path: root/include/util/types.h
diff options
context:
space:
mode:
authorDouglas Rumbaugh <dbr4@psu.edu>2024-02-12 11:42:18 -0500
committerDouglas Rumbaugh <dbr4@psu.edu>2024-02-12 11:56:42 -0500
commit5c229093f9af21514b17cf778dbec7ac657e31d2 (patch)
tree7453b6dbf26362d36a4904175cc8303f5b45563e /include/util/types.h
parent90194cb5be5c7b80bfa21a353a75920e932d54d8 (diff)
downloaddynamic-extension-5c229093f9af21514b17cf778dbec7ac657e31d2.tar.gz
Refactored Reconstruction Tasks
Added a ReconVector type to make it easier to do load balancing by shifting tasks around, and clean up a few interfaces.
Diffstat (limited to 'include/util/types.h')
-rw-r--r--include/util/types.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/include/util/types.h b/include/util/types.h
index a13bd95..e22fd18 100644
--- a/include/util/types.h
+++ b/include/util/types.h
@@ -19,6 +19,8 @@
#include <cstdint>
#include <cstdlib>
+#include <vector>
+#include <cassert>
namespace de {
@@ -69,4 +71,69 @@ struct ShardID {
/* 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 {
+ level_index source;
+ level_index target;
+ size_t reccnt;
+} ReconstructionTask;
+
+class ReconstructionVector {
+public:
+ ReconstructionVector()
+ : total_reccnt(0) {}
+
+ ~ReconstructionVector() = default;
+
+ 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;
+ }
+
+ 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;
+
+ 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;
+ }
+
+ 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;
+};
+
}