diff options
| author | Douglas Rumbaugh <dbr4@psu.edu> | 2024-01-11 16:31:24 -0500 |
|---|---|---|
| committer | Douglas Rumbaugh <dbr4@psu.edu> | 2024-01-11 16:31:24 -0500 |
| commit | 7e503464176adbd0880373325e30a6bfd58616f0 (patch) | |
| tree | 8c7b999379caa5a3fdcfac3452749a56b5aaf852 /include/framework/structure | |
| parent | 5a2c378aad3f1a9923db3191ffaa3fb807d392b2 (diff) | |
| download | dynamic-extension-7e503464176adbd0880373325e30a6bfd58616f0.tar.gz | |
InternalLevel update and tests
Plus some assorted fixes for move semantics stuff in BufferView that
accompanied these changes.
Diffstat (limited to 'include/framework/structure')
| -rw-r--r-- | include/framework/structure/BufferView.h | 44 | ||||
| -rw-r--r-- | include/framework/structure/InternalLevel.h | 11 |
2 files changed, 39 insertions, 16 deletions
diff --git a/include/framework/structure/BufferView.h b/include/framework/structure/BufferView.h index 98e41dd..d058714 100644 --- a/include/framework/structure/BufferView.h +++ b/include/framework/structure/BufferView.h @@ -18,12 +18,25 @@ namespace de { -typedef std::_Bind<void (*(void*, long unsigned int))(void*, long unsigned int)> ReleaseFunction; +typedef std::_Bind<void (*(void*, long unsigned int))(void*, long unsigned int)> ReleaseFunction; + +static void noop_func(void *arg1, size_t arg2) { + return; +} + +constexpr auto noop_bind = std::bind(noop_func, (void*) nullptr, 0ul); template <RecordInterface R> class BufferView { public: - BufferView() = default; + BufferView() + : m_data(nullptr) + , m_release(noop_bind) + , m_head(0) + , m_tail(0) + , m_cap(0) + , m_approx_ts_cnt(0) + , m_tombstone_filter(nullptr) {} /* * the BufferView's lifetime is tightly linked to buffer versioning, and so @@ -32,14 +45,25 @@ public: BufferView(const BufferView&) = delete; BufferView &operator=(BufferView &) = delete; - void operator=(BufferView &&src) { - m_data = src.m_data; - m_release = src.m_release; - m_head = src.m_head; - m_tail = src.m_tail; - m_cap = src.m_cap; - m_approx_ts_cnt = src.m_approx_ts_cnt; - m_tombstone_filter = src.filter; + BufferView(BufferView &&other) + : m_data(std::exchange(other.m_data, nullptr)) + , m_release(std::move(other.m_release)) + , m_head(std::exchange(other.m_head, 0)) + , m_tail(std::exchange(other.m_tail, 0)) + , m_cap(std::exchange(other.m_cap, 0)) + , m_approx_ts_cnt(std::exchange(other.m_approx_ts_cnt, 0)) + , m_tombstone_filter(std::exchange(other.m_tombstone_filter, nullptr)) {} + + BufferView &operator=(BufferView &&other) noexcept { + std::swap(m_data, other.m_data); + m_release = std::move(other.m_release); + std::swap(m_head, other.m_head); + std::swap(m_tail, other.m_tail); + std::swap(m_cap, other.m_cap); + std::swap(m_approx_ts_cnt, other.m_approx_ts_cnt); + std::swap(m_tombstone_filter, other.m_tombstone_filter); + + return *this; } BufferView(Wrapped<R> *buffer, size_t cap, size_t head, size_t tail, size_t tombstone_cnt, psudb::BloomFilter<R> *filter, diff --git a/include/framework/structure/InternalLevel.h b/include/framework/structure/InternalLevel.h index ee85cb3..b35cadd 100644 --- a/include/framework/structure/InternalLevel.h +++ b/include/framework/structure/InternalLevel.h @@ -16,7 +16,7 @@ #include "framework/interface/Shard.h" #include "framework/interface/Query.h" #include "framework/interface/Record.h" -#include "framework/structure/MutableBuffer.h" +#include "framework/structure/BufferView.h" namespace de { template <RecordInterface R, ShardInterface S, QueryInterface Q> @@ -27,7 +27,7 @@ class InternalLevel; template <RecordInterface R, ShardInterface S, QueryInterface Q> class InternalLevel { typedef S Shard; - typedef MutableBuffer<R> Buffer; + typedef BufferView<R> BuffView; public: InternalLevel(ssize_t level_no, size_t shard_cap) : m_level_no(level_no) @@ -97,14 +97,14 @@ public: * into this level. This is used for buffer * flushes under the tiering layout policy. */ - void append_buffer(Buffer* buffer) { + void append_buffer(BuffView buffer) { if (m_shard_cnt == m_shards.size()) { assert(m_pending_shard == nullptr); - m_pending_shard = new S(buffer); + m_pending_shard = new S(std::move(buffer)); return; } - m_shards[m_shard_cnt] = std::make_shared<S>(buffer); + m_shards[m_shard_cnt] = std::make_shared<S>(std::move(buffer)); ++m_shard_cnt; } @@ -140,7 +140,6 @@ public: return new S(shards, m_shard_cnt); } - /* Append the sample range in-order */ void get_query_states(std::vector<std::pair<ShardID, Shard *>> &shards, std::vector<void*>& shard_states, void *query_parms) { for (size_t i=0; i<m_shard_cnt; i++) { if (m_shards[i]) { |