diff options
| author | Douglas Rumbaugh <dbr4@psu.edu> | 2025-01-16 13:18:37 -0500 |
|---|---|---|
| committer | Douglas Rumbaugh <dbr4@psu.edu> | 2025-01-16 13:18:37 -0500 |
| commit | 77589d4cc82b766d2cf16294fab98a57f6579cb4 (patch) | |
| tree | 0cc136d13c20021e0278b8b2ededf2652c27a84e /include/framework/reconstruction | |
| parent | bac86504220da4c169089a3a1803e0a21f5acbc2 (diff) | |
| download | dynamic-extension-77589d4cc82b766d2cf16294fab98a57f6579cb4.tar.gz | |
Additional layout policies + more flexibility in buffer flushing
Diffstat (limited to 'include/framework/reconstruction')
| -rw-r--r-- | include/framework/reconstruction/FixedShardCountPolicy.h | 66 | ||||
| -rw-r--r-- | include/framework/reconstruction/FloodL0Policy.h | 65 |
2 files changed, 131 insertions, 0 deletions
diff --git a/include/framework/reconstruction/FixedShardCountPolicy.h b/include/framework/reconstruction/FixedShardCountPolicy.h new file mode 100644 index 0000000..ec8e4e6 --- /dev/null +++ b/include/framework/reconstruction/FixedShardCountPolicy.h @@ -0,0 +1,66 @@ +/* + * include/framework/reconstruction/FixedShardCountPolicy.h + * + * Copyright (C) 2023-2024 Douglas B. Rumbaugh <drumbaugh@psu.edu> + * Dong Xie <dongx@psu.edu> + * + * Distributed under the Modified BSD License. + * + */ +#pragma once +#include <cmath> + +#include "framework/reconstruction/ReconstructionPolicy.h" +#include "framework/scheduling/Epoch.h" +#include "util/types.h" + +namespace de { +template <ShardInterface ShardType, QueryInterface<ShardType> QueryType> +class FixedShardCountPolicy : public ReconstructionPolicy<ShardType, QueryType> { + typedef std::vector<std::shared_ptr<InternalLevel<ShardType, QueryType>>> + LevelVector; + +public: + FixedShardCountPolicy(size_t buffer_size, size_t shard_count, size_t max_record_count) + : m_buffer_size(buffer_size), m_shard_count(shard_count), m_max_reccnt(max_record_count) {} + + ReconstructionVector + get_reconstruction_tasks(const Epoch<ShardType, QueryType> *epoch, + size_t incoming_reccnt) const override { + ReconstructionVector reconstructions; + return reconstructions; + + } + + ReconstructionTask + get_flush_task(const Epoch<ShardType, QueryType> *epoch) const override { + + auto levels = epoch->get_structure()->get_level_vector(); + + if (levels.size() == 0) { + return ReconstructionTask{ + {{buffer_shid}}, 0, m_buffer_size, ReconstructionType::Append}; + } + + ShardID last_shid = {0, (shard_index) (levels[0]->get_shard_count() - 1)}; + + if (levels[0]->get_shard(last_shid.shard_idx)->get_record_count() + m_buffer_size <= capacity()) { + return ReconstructionTask{ + {{buffer_shid, last_shid}}, 0, m_buffer_size, ReconstructionType::Merge}; + } else { + return ReconstructionTask{ + {{buffer_shid}}, 0, m_buffer_size, ReconstructionType::Append}; + } + } + +private: + inline size_t capacity() const { + double bps = (double) m_max_reccnt / (double) m_buffer_size / m_shard_count; + return ceil(bps) * m_buffer_size; + } + + size_t m_buffer_size; + size_t m_shard_count; + size_t m_max_reccnt; +}; +} // namespace de diff --git a/include/framework/reconstruction/FloodL0Policy.h b/include/framework/reconstruction/FloodL0Policy.h new file mode 100644 index 0000000..da4c297 --- /dev/null +++ b/include/framework/reconstruction/FloodL0Policy.h @@ -0,0 +1,65 @@ +/* + * include/framework/reconstruction/FloodL0Policy.h + * + * Copyright (C) 2023-2024 Douglas B. Rumbaugh <drumbaugh@psu.edu> + * Dong Xie <dongx@psu.edu> + * + * Distributed under the Modified BSD License. + * + */ +#pragma once +#include <cmath> + +#include "framework/reconstruction/ReconstructionPolicy.h" +#include "framework/scheduling/Epoch.h" +#include "util/types.h" + +namespace de { +template <ShardInterface ShardType, QueryInterface<ShardType> QueryType> +class FloodL0Policy : public ReconstructionPolicy<ShardType, QueryType> { + typedef std::vector<std::shared_ptr<InternalLevel<ShardType, QueryType>>> + LevelVector; + +public: + FloodL0Policy(size_t buffer_size) : m_buffer_size(buffer_size) {} + + ReconstructionVector + get_reconstruction_tasks(const Epoch<ShardType, QueryType> *epoch, + size_t incoming_reccnt) const override { + + ReconstructionVector reconstructions; + return reconstructions; + + } + + ReconstructionTask + get_flush_task(const Epoch<ShardType, QueryType> *epoch) const override { + return ReconstructionTask{ + {{buffer_shid}}, 0, m_buffer_size, ReconstructionType::Append}; + } + +private: + level_index find_reconstruction_target(LevelVector &levels) const { + level_index target_level = invalid_level_idx; + size_t incoming_records = m_buffer_size; + + for (level_index i = 0; i < (level_index)levels.size(); i++) { + if (levels[i]->get_record_count() + incoming_records < capacity(i)) { + target_level = i; + break; + } + + incoming_records = levels[i]->get_record_count(); + } + + return target_level; + } + + inline size_t capacity(level_index level) const { + return m_buffer_size * pow(m_scale_factor, level + 1); + } + + size_t m_scale_factor; + size_t m_buffer_size; +}; +} // namespace de |