Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::LeadingZeroBuffer< EMPTY > Class Template Reference

Public Member Functions

template<typename T>
const T Load (const uint8_t *ptr)
void SetBuffer (uint8_t *buffer)
void Flush ()
uint64_t BitsWritten () const
void Reset ()
uint64_t BlockIndex () const
void FlushBuffer ()
void Insert (const uint8_t &value)
uint8_t Extract ()
idx_t GetCount () const
idx_t BlockCount () const

Static Public Attributes

static constexpr uint32_t CHIMP_GROUP_SIZE = 1024
static constexpr uint32_t LEADING_ZERO_BITS_SIZE = 3
static constexpr uint32_t LEADING_ZERO_BLOCK_SIZE = 8
static constexpr uint32_t LEADING_ZERO_BLOCK_BIT_SIZE = LEADING_ZERO_BLOCK_SIZE * LEADING_ZERO_BITS_SIZE
static constexpr uint32_t MAX_LEADING_ZERO_BLOCKS = CHIMP_GROUP_SIZE / LEADING_ZERO_BLOCK_SIZE
static constexpr uint32_t MAX_BITS_USED_BY_ZERO_BLOCKS = MAX_LEADING_ZERO_BLOCKS * LEADING_ZERO_BLOCK_BIT_SIZE
static constexpr uint32_t MAX_BYTES_USED_BY_ZERO_BLOCKS = MAX_BITS_USED_BY_ZERO_BLOCKS / 8
static constexpr uint32_t BUFFER_SIZE

Private Attributes

uint32_t current
uint32_t counter = 0
uint8_t * buffer

Constructor & Destructor Documentation

◆ LeadingZeroBuffer()

template<bool EMPTY>
duckdb::LeadingZeroBuffer< EMPTY >::LeadingZeroBuffer ( )
inline
396554 : current(0), counter(0), buffer(nullptr) {
396555 }

Member Function Documentation

◆ Load()

template<bool EMPTY>
template<typename T>
const T duckdb::LeadingZeroBuffer< EMPTY >::Load ( const uint8_t * ptr)
inline
396547 {
396548 T ret;
396549 memcpy(&ret, ptr, sizeof(ret));
396550 return ret;
396551 }
Definition duckdb.cpp:396532

◆ SetBuffer()

template<bool EMPTY>
void duckdb::LeadingZeroBuffer< EMPTY >::SetBuffer ( uint8_t * buffer)
inline
396556 {
396557 // Set the internal buffer, when inserting this should be BUFFER_SIZE bytes in length
396558 // This buffer does not need to be zero-initialized for inserting
396559 this->buffer = buffer;
396560 this->counter = 0;
396561 }

◆ Flush()

template<bool EMPTY>
void duckdb::LeadingZeroBuffer< EMPTY >::Flush ( )
inline
396562 {
396563 if ((counter & 7) != 0) {
396564 FlushBuffer();
396565 }
396566 }

◆ BitsWritten()

template<bool EMPTY>
uint64_t duckdb::LeadingZeroBuffer< EMPTY >::BitsWritten ( ) const
inline
396568 {
396569 return counter * 3ULL;
396570 }

◆ Reset()

template<bool EMPTY>
void duckdb::LeadingZeroBuffer< EMPTY >::Reset ( )
inline
396573 {
396574 this->counter = 0;
396575 current = 0;
396576#ifdef DEBUG
396577 flags.clear();
396578#endif
396579 }

◆ BlockIndex()

template<bool EMPTY>
uint64_t duckdb::LeadingZeroBuffer< EMPTY >::BlockIndex ( ) const
inline
396589 {
396590 return ((counter >> 3ULL) * (LEADING_ZERO_BLOCK_BIT_SIZE / 8ULL));
396591 }

◆ FlushBuffer()

template<bool EMPTY>
void duckdb::LeadingZeroBuffer< EMPTY >::FlushBuffer ( )
inline
396593 {
396594 if (EMPTY) {
396595 return;
396596 }
396597 const auto buffer_idx = BlockIndex();
396598 memcpy((void *)(buffer + buffer_idx), (uint8_t *)&current, 3);
396599#ifdef DEBUG
396600 // Verify that the bits are copied correctly
396601
396602 uint32_t temp_value = 0;
396603 memcpy(reinterpret_cast<uint8_t *>(&temp_value), (void *)(buffer + buffer_idx), 3);
396604 for (idx_t i = 0; i < flags.size(); i++) {
396606 }
396607 flags.clear();
396608#endif
396609 }

◆ Insert()

template<bool EMPTY>
void duckdb::LeadingZeroBuffer< EMPTY >::Insert ( const uint8_t & value)
inline
396611 {
396612 if (!EMPTY) {
396613#ifdef DEBUG
396614 flags.push_back(value);
396615#endif
396616 current |= (value & 7) << LeadingZeroBufferConstants::SHIFTS[counter & 7];
396617#ifdef DEBUG
396618 // Verify that the bits are serialized correctly
396619 D_ASSERT(flags[counter & 7] == ExtractValue(current, counter & 7));
396620#endif
396621
396622 if ((counter & (LEADING_ZERO_BLOCK_SIZE - 1)) == 7) {
396623 FlushBuffer();
396624 current = 0;
396625 }
396626 }
396627 counter++;
396628 }

◆ Extract()

template<bool EMPTY>
uint8_t duckdb::LeadingZeroBuffer< EMPTY >::Extract ( )
inline
396630 {
396631 const auto buffer_idx = BlockIndex();
396632 auto const temp = Load<uint32_t>(buffer + buffer_idx);
396633
396636 counter++;
396637 return result;
396638 }

◆ GetCount()

template<bool EMPTY>
idx_t duckdb::LeadingZeroBuffer< EMPTY >::GetCount ( ) const
inline
396639 {
396640 return counter;
396641 }

◆ BlockCount()

template<bool EMPTY>
idx_t duckdb::LeadingZeroBuffer< EMPTY >::BlockCount ( ) const
inline
396642 {
396643 return (counter >> 3) + ((counter & 7) != 0);
396644 }

Member Data Documentation

◆ BUFFER_SIZE

template<bool EMPTY>
uint32_t duckdb::LeadingZeroBuffer< EMPTY >::BUFFER_SIZE
staticconstexpr
Initial value:
=
MAX_BYTES_USED_BY_ZERO_BLOCKS + (sizeof(uint32_t) - (LEADING_ZERO_BLOCK_BIT_SIZE / 8))
::uint32_t uint32_t

The documentation for this class was generated from the following file: