diff options
| author | Douglas Rumbaugh <dbr4@psu.edu> | 2024-02-07 13:42:34 -0500 |
|---|---|---|
| committer | Douglas Rumbaugh <dbr4@psu.edu> | 2024-02-07 13:42:34 -0500 |
| commit | 2c5d549b3618b9ea72e6eece4cb4f3da5a6811a8 (patch) | |
| tree | 17e08973d38bd20b8358aeb77a90c99cd7f1c835 /include | |
| parent | 10b4425e842d10b7fbfa85978969ed4591d6b98e (diff) | |
| download | dynamic-extension-2c5d549b3618b9ea72e6eece4cb4f3da5a6811a8.tar.gz | |
Fully realized shard concept interface
Diffstat (limited to 'include')
| -rw-r--r-- | include/framework/DynamicExtension.h | 2 | ||||
| -rw-r--r-- | include/framework/interface/Shard.h | 25 | ||||
| -rw-r--r-- | include/framework/scheduling/Epoch.h | 2 | ||||
| -rw-r--r-- | include/framework/scheduling/Task.h | 4 | ||||
| -rw-r--r-- | include/framework/structure/ExtensionStructure.h | 2 | ||||
| -rw-r--r-- | include/framework/structure/InternalLevel.h | 4 | ||||
| -rw-r--r-- | include/query/irs.h | 2 | ||||
| -rw-r--r-- | include/query/rangecount.h | 2 | ||||
| -rw-r--r-- | include/query/rangequery.h | 2 | ||||
| -rw-r--r-- | include/query/wirs.h | 2 | ||||
| -rw-r--r-- | include/query/wss.h | 2 | ||||
| -rw-r--r-- | include/shard/Alias.h | 15 | ||||
| -rw-r--r-- | include/shard/ISAMTree.h | 8 | ||||
| -rw-r--r-- | include/shard/TrieSpline.h | 1 |
14 files changed, 33 insertions, 40 deletions
diff --git a/include/framework/DynamicExtension.h b/include/framework/DynamicExtension.h index 5c021f2..d88a945 100644 --- a/include/framework/DynamicExtension.h +++ b/include/framework/DynamicExtension.h @@ -31,7 +31,7 @@ namespace de { -template <RecordInterface R, ShardInterface S, QueryInterface<R, S> Q, LayoutPolicy L=LayoutPolicy::TEIRING, +template <RecordInterface R, ShardInterface<R> S, QueryInterface<R, S> Q, LayoutPolicy L=LayoutPolicy::TEIRING, DeletePolicy D=DeletePolicy::TAGGING, SchedulerInterface SCHED=SerialScheduler> class DynamicExtension { typedef S Shard; diff --git a/include/framework/interface/Shard.h b/include/framework/interface/Shard.h index 8c4db34..c4a9180 100644 --- a/include/framework/interface/Shard.h +++ b/include/framework/interface/Shard.h @@ -8,25 +8,17 @@ */ #pragma once -#include <concepts> - -#include "util/types.h" -#include "framework/interface/Record.h" -#include <vector> +#include "framework/ShardRequirements.h" namespace de { -// FIXME: The interface is not completely specified yet, as it is pending -// determining a good way to handle additional template arguments -// to get the Record type into play -template <typename S> -concept ShardInterface = requires(S s, std::vector<S*> spp, void *p, bool b, size_t i) { +template <typename S, typename R> +concept ShardInterface = RecordInterface<R> && requires(S s, std::vector<S*> spp, void *p, bool b, size_t i, BufferView<R> bv, R r) { {S(spp)}; - /* - {S(mutable buffer)} - {s.point_lookup(r, b) } -> std::convertible_to<void*> - */ - {s.get_data()} -> std::convertible_to<void*>; + {S(std::move(bv))}; + + {s.point_lookup(r, b) } -> std::same_as<Wrapped<R>*>; + {s.get_data()} -> std::same_as<Wrapped<R>*>; {s.get_record_count()} -> std::convertible_to<size_t>; {s.get_tombstone_count()} -> std::convertible_to<size_t>; @@ -35,9 +27,10 @@ concept ShardInterface = requires(S s, std::vector<S*> spp, void *p, bool b, siz }; template <typename S, typename R> -concept SortedShardInterface = ShardInterface<S> && requires(S s, R r, R *rp) { +concept SortedShardInterface = ShardInterface<S, R> && requires(S s, R r, R *rp, size_t i) { {s.lower_bound(r)} -> std::convertible_to<size_t>; {s.upper_bound(r)} -> std::convertible_to<size_t>; + {s.get_record_at(i)} -> std::same_as<Wrapped<R>*>; }; } diff --git a/include/framework/scheduling/Epoch.h b/include/framework/scheduling/Epoch.h index 48b7742..e58bd11 100644 --- a/include/framework/scheduling/Epoch.h +++ b/include/framework/scheduling/Epoch.h @@ -18,7 +18,7 @@ namespace de { -template <RecordInterface R, ShardInterface S, QueryInterface<R, S> Q, LayoutPolicy L> +template <RecordInterface R, ShardInterface<R> S, QueryInterface<R, S> Q, LayoutPolicy L> class Epoch { private: typedef MutableBuffer<R> Buffer; diff --git a/include/framework/scheduling/Task.h b/include/framework/scheduling/Task.h index ba0001d..008f232 100644 --- a/include/framework/scheduling/Task.h +++ b/include/framework/scheduling/Task.h @@ -18,7 +18,7 @@ namespace de { -template <RecordInterface R, ShardInterface S, QueryInterface<R, S> Q, LayoutPolicy L> +template <RecordInterface R, ShardInterface<R> S, QueryInterface<R, S> Q, LayoutPolicy L> struct ReconstructionArgs { Epoch<R, S, Q, L> *epoch; std::vector<ReconstructionTask> merges; @@ -27,7 +27,7 @@ struct ReconstructionArgs { void *extension; }; -template <RecordInterface R, ShardInterface S, QueryInterface<R, S> Q, LayoutPolicy L> +template <RecordInterface R, ShardInterface<R> S, QueryInterface<R, S> Q, LayoutPolicy L> struct QueryArgs { std::promise<std::vector<R>> result_set; void *query_parms; diff --git a/include/framework/structure/ExtensionStructure.h b/include/framework/structure/ExtensionStructure.h index 0b8263e..373a1e2 100644 --- a/include/framework/structure/ExtensionStructure.h +++ b/include/framework/structure/ExtensionStructure.h @@ -22,7 +22,7 @@ namespace de { -template <RecordInterface R, ShardInterface S, QueryInterface<R, S> Q, LayoutPolicy L=LayoutPolicy::TEIRING> +template <RecordInterface R, ShardInterface<R> S, QueryInterface<R, S> Q, LayoutPolicy L=LayoutPolicy::TEIRING> class ExtensionStructure { typedef S Shard; typedef BufferView<R> BuffView; diff --git a/include/framework/structure/InternalLevel.h b/include/framework/structure/InternalLevel.h index 0fd5275..d586869 100644 --- a/include/framework/structure/InternalLevel.h +++ b/include/framework/structure/InternalLevel.h @@ -19,12 +19,12 @@ #include "framework/structure/BufferView.h" namespace de { -template <RecordInterface R, ShardInterface S, QueryInterface<R, S> Q> +template <RecordInterface R, ShardInterface<R> S, QueryInterface<R, S> Q> class InternalLevel; -template <RecordInterface R, ShardInterface S, QueryInterface<R, S> Q> +template <RecordInterface R, ShardInterface<R> S, QueryInterface<R, S> Q> class InternalLevel { typedef S Shard; typedef BufferView<R> BuffView; diff --git a/include/query/irs.h b/include/query/irs.h index bef75bf..c14d0cf 100644 --- a/include/query/irs.h +++ b/include/query/irs.h @@ -44,7 +44,7 @@ struct BufferState { BufferState(BufferView<R> *buffer) : buffer(buffer) {} }; -template <ShardInterface S, RecordInterface R, bool Rejection=true> +template <RecordInterface R, ShardInterface<R> S, bool Rejection=true> class Query { public: constexpr static bool EARLY_ABORT=false; diff --git a/include/query/rangecount.h b/include/query/rangecount.h index a09ad64..6c57809 100644 --- a/include/query/rangecount.h +++ b/include/query/rangecount.h @@ -35,7 +35,7 @@ struct BufferState { : buffer(buffer) {} }; -template <ShardInterface S, KVPInterface R> +template <KVPInterface R, ShardInterface<R> S> class Query { public: constexpr static bool EARLY_ABORT=false; diff --git a/include/query/rangequery.h b/include/query/rangequery.h index c3985fa..24b38ec 100644 --- a/include/query/rangequery.h +++ b/include/query/rangequery.h @@ -36,7 +36,7 @@ struct BufferState { : buffer(buffer) {} }; -template <ShardInterface S, RecordInterface R> +template <RecordInterface R, ShardInterface<R> S> class Query { public: constexpr static bool EARLY_ABORT=false; diff --git a/include/query/wirs.h b/include/query/wirs.h index 07c5292..4fac7e7 100644 --- a/include/query/wirs.h +++ b/include/query/wirs.h @@ -57,7 +57,7 @@ struct BufferState { } }; -template <ShardInterface S, RecordInterface R, bool Rejection=true> +template <RecordInterface R, ShardInterface<R> S, bool Rejection=true> class Query { public: constexpr static bool EARLY_ABORT=false; diff --git a/include/query/wss.h b/include/query/wss.h index 9f192ee..ea36cb2 100644 --- a/include/query/wss.h +++ b/include/query/wss.h @@ -46,7 +46,7 @@ struct BufferState { } }; -template <ShardInterface S, RecordInterface R, bool Rejection=true> +template <RecordInterface R, ShardInterface<R> S, bool Rejection=true> class Query { public: constexpr static bool EARLY_ABORT=false; diff --git a/include/shard/Alias.h b/include/shard/Alias.h index a3e8ad8..a234575 100644 --- a/include/shard/Alias.h +++ b/include/shard/Alias.h @@ -15,9 +15,6 @@ #include <vector> #include <cassert> -#include <queue> -#include <memory> -#include <concepts> #include "framework/ShardRequirements.h" @@ -34,7 +31,7 @@ using psudb::queue_record; namespace de { -thread_local size_t wss_cancelations = 0; +static thread_local size_t wss_cancelations = 0; template <WeightedRecordInterface R> class Alias { @@ -44,7 +41,7 @@ private: typedef decltype(R::weight) W; public: - Alias(MutableBuffer<R>* buffer) + Alias(BufferView<R>* buffer) : m_reccnt(0), m_tombstone_cnt(0), m_total_weight(0), m_alias(nullptr), m_bf(nullptr) { m_alloc_size = (buffer->get_record_count() * sizeof(Wrapped<R>)) + (CACHELINE_SIZE - (buffer->get_record_count() * sizeof(Wrapped<R>)) % CACHELINE_SIZE); @@ -96,17 +93,17 @@ public: } } - Alias(Alias** shards, size_t len) + Alias(std::vector<Alias*> &shards) : m_reccnt(0), m_tombstone_cnt(0), m_total_weight(0), m_alias(nullptr), m_bf(nullptr) { std::vector<Cursor<Wrapped<R>>> cursors; - cursors.reserve(len); + cursors.reserve(shards.size()); - PriorityQueue<Wrapped<R>> pq(len); + PriorityQueue<Wrapped<R>> pq(shards.size()); size_t attemp_reccnt = 0; size_t tombstone_count = 0; - for (size_t i = 0; i < len; ++i) { + for (size_t i = 0; i < shards.size(); ++i) { if (shards[i]) { auto base = shards[i]->get_data(); cursors.emplace_back(Cursor{base, base + shards[i]->get_record_count(), 0, shards[i]->get_record_count()}); diff --git a/include/shard/ISAMTree.h b/include/shard/ISAMTree.h index 932e767..7de9cb1 100644 --- a/include/shard/ISAMTree.h +++ b/include/shard/ISAMTree.h @@ -25,6 +25,7 @@ using psudb::CACHELINE_SIZE; using psudb::BloomFilter; using psudb::PriorityQueue; using psudb::queue_record; +using psudb::byte; namespace de { @@ -222,9 +223,6 @@ public: return m_tombstone_cnt; } - const Wrapped<R>* get_record_at(size_t idx) const { - return (idx < m_reccnt) ? m_data + idx : nullptr; - } size_t get_memory_usage() { return m_alloc_size; @@ -234,6 +232,7 @@ public: return m_bf->memory_usage(); } + /* SortedShardInterface methods */ size_t get_lower_bound(const K& key) const { const InternalNode* now = m_root; while (!is_leaf(reinterpret_cast<const byte*>(now))) { @@ -274,6 +273,9 @@ public: return pos - m_data; } + const Wrapped<R>* get_record_at(size_t idx) const { + return (idx < m_reccnt) ? m_data + idx : nullptr; + } private: void build_internal_levels() { diff --git a/include/shard/TrieSpline.h b/include/shard/TrieSpline.h index 8142a67..9473177 100644 --- a/include/shard/TrieSpline.h +++ b/include/shard/TrieSpline.h @@ -25,6 +25,7 @@ using psudb::CACHELINE_SIZE; using psudb::BloomFilter; using psudb::PriorityQueue; using psudb::queue_record; +using psudb::byte; namespace de { |