22template <
size_t BufferSize>
32 uint16_t
push(uint32_t value) {
33 const auto index =
count_++;
34 assert(index < 4096 &&
"SmallValueBuffer can only hold up to 4096 chunks");
41 overflow_ = std::make_unique<SmallValueBuffer::Overflow>();
45 overflow_->wideElements_.push_back(
false);
49 uint16_t
push(uint64_t value) {
50 const auto lsb =
static_cast<uint32_t
>(value & 0xFFFFFFFF);
51 const auto msb =
static_cast<uint32_t
>(value >> 32);
53 const auto lsbIndex =
push(lsb);
54 [[maybe_unused]]
const auto msbIndex =
push(msb);
56 msbIndex < 4096 &&
"SmallValueBuffer can only hold up to 4096 chunks");
58 if (lsbIndex <
buffer_.size()) {
68 [[nodiscard]] uint16_t
replace(uint16_t index, uint32_t value) {
78 [[nodiscard]] uint16_t
replace(uint16_t index, uint64_t value) {
84 const auto lsb =
static_cast<uint32_t
>(value & 0xFFFFFFFF);
85 const auto msb =
static_cast<uint32_t
>(value >> 32);
87 [[maybe_unused]]
auto lsbIndex =
replace(index, lsb);
88 [[maybe_unused]]
auto msbIndex =
replace(index + 1, msb);
96 uint32_t
get32(uint16_t index)
const {
104 uint64_t
get64(uint16_t index)
const {
105 const auto lsb =
get32(index);
106 const auto msb =
get32(index + 1);
107 return (
static_cast<uint64_t
>(msb) << 32) | lsb;
Definition SmallValueBuffer.h:23
std::unique_ptr< Overflow > overflow_
Definition SmallValueBuffer.h:130
uint16_t push(uint32_t value)
Definition SmallValueBuffer.h:32
uint16_t push(uint64_t value)
Definition SmallValueBuffer.h:49
SmallValueBuffer & operator=(const SmallValueBuffer &other)
Definition SmallValueBuffer.h:110
uint64_t get64(uint16_t index) const
Definition SmallValueBuffer.h:104
uint16_t replace(uint16_t index, uint64_t value)
Definition SmallValueBuffer.h:78
std::bitset< BufferSize > wideElements_
Definition SmallValueBuffer.h:129
SmallValueBuffer(SmallValueBuffer &&other) noexcept=default
uint16_t count_
Definition SmallValueBuffer.h:127
uint16_t replace(uint16_t index, uint32_t value)
Definition SmallValueBuffer.h:68
SmallValueBuffer(const SmallValueBuffer &other)
Definition SmallValueBuffer.h:26
uint32_t get32(uint16_t index) const
Definition SmallValueBuffer.h:96
std::array< uint32_t, BufferSize > buffer_
Definition SmallValueBuffer.h:128
SmallValueBuffer()=default
SmallValueBuffer & operator=(SmallValueBuffer &&other) noexcept=default
Definition Benchmark.cpp:19
Definition SmallValueBuffer.h:122
std::vector< bool > wideElements_
Definition SmallValueBuffer.h:124
std::vector< uint32_t > buffer_
Definition SmallValueBuffer.h:123