From e920fa57cf9c503e560055864e4de37912b239e1 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Mon, 29 May 2023 14:30:08 -0400 Subject: Adjusted the way that Wrapping records works to clean up interfaces --- include/framework/MutableBuffer.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'include/framework/MutableBuffer.h') diff --git a/include/framework/MutableBuffer.h b/include/framework/MutableBuffer.h index c154001..bc80922 100644 --- a/include/framework/MutableBuffer.h +++ b/include/framework/MutableBuffer.h @@ -28,14 +28,13 @@ namespace de { template class MutableBuffer { - //typedef WrappedRecord R; public: MutableBuffer(size_t capacity, bool rej_sampling, size_t max_tombstone_cap) : m_cap(capacity), m_tombstone_cap(max_tombstone_cap), m_reccnt(0) , m_tombstonecnt(0), m_weight(0), m_max_weight(0) { - auto len = capacity * sizeof(R); + auto len = capacity * sizeof(Wrapped); size_t aligned_buffersize = len + (CACHELINE_SIZE - (len % CACHELINE_SIZE)); - m_data = (R*) std::aligned_alloc(CACHELINE_SIZE, aligned_buffersize); + m_data = (Wrapped*) std::aligned_alloc(CACHELINE_SIZE, aligned_buffersize); m_tombstone_filter = nullptr; if (max_tombstone_cap > 0) { m_tombstone_filter = new BloomFilter(BF_FPR, max_tombstone_cap, BF_HASH_FUNCS); @@ -54,10 +53,11 @@ public: int32_t pos = 0; if ((pos = try_advance_tail()) == -1) return 0; - R new_rec = rec; - if (tombstone) new_rec.set_tombstone(); + Wrapped wrec; + wrec.rec = rec; + if (tombstone) wrec.set_tombstone(); - m_data[pos] = new_rec; + m_data[pos] = wrec; m_data[pos].header |= (pos << 2); if (tombstone) { @@ -66,7 +66,7 @@ public: } if constexpr (WeightedRecordInterface) { - m_weight.fetch_add(new_rec.weight); + m_weight.fetch_add(rec.weight); double old = m_max_weight.load(); while (old < rec.weight) { m_max_weight.compare_exchange_strong(old, rec.weight); @@ -123,7 +123,7 @@ public: auto offset = 0; while (offset < m_reccnt.load()) { - if (m_data[offset] == rec && m_data[offset].is_tombstone()) { + if (m_data[offset].rec == rec && m_data[offset].is_tombstone()) { return true; } offset++;; @@ -147,7 +147,7 @@ public: return m_weight.load(); } - R *get_data() { + Wrapped *get_data() { return m_data; } @@ -162,7 +162,7 @@ private: size_t m_cap; size_t m_tombstone_cap; - R* m_data; + Wrapped* m_data; BloomFilter* m_tombstone_filter; alignas(64) std::atomic m_tombstonecnt; -- cgit v1.2.3