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::roaring::ContainerMetadata Struct Reference

Public Member Functions

bool operator== (const ContainerMetadata &other) const
idx_t GetDataSizeInBytes (idx_t container_size) const
bool IsUncompressed () const
bool IsRun () const
bool IsInverted () const
bool IsArray () const
idx_t NumberOfRuns () const
idx_t Cardinality () const

Static Public Member Functions

static ContainerMetadata CreateMetadata (uint16_t count, uint16_t array_null, uint16_t array_non_null, uint16_t runs)
static ContainerMetadata RunContainer (uint16_t runs)
static ContainerMetadata ArrayContainer (uint16_t array_size, bool nulls)
static ContainerMetadata BitsetContainer (uint16_t container_size)

Public Attributes

ContainerType container_type
bool nulls
 Whether nulls are being encoded or non-nulls.
uint16_t count
 The amount (meaning depends on container_type).

Constructor & Destructor Documentation

◆ ContainerMetadata()

duckdb::roaring::ContainerMetadata::ContainerMetadata ( )
inlineprivate
403229 {
403230 }

Member Function Documentation

◆ operator==()

bool duckdb::roaring::ContainerMetadata::operator== ( const ContainerMetadata & other) const
inline
403158 {
403159 if (container_type != other.container_type) {
403160 return false;
403161 }
403162 if (count != other.count) {
403163 return false;
403164 }
403165 if (nulls != other.nulls) {
403166 return false;
403167 }
403168 return true;
403169 }
uint16_t count
The amount (meaning depends on container_type).
Definition duckdb.cpp:403226
bool nulls
Whether nulls are being encoded or non-nulls.
Definition duckdb.cpp:403224

◆ CreateMetadata()

ContainerMetadata duckdb::roaring::ContainerMetadata::CreateMetadata ( uint16_t count,
uint16_t array_null,
uint16_t array_non_null,
uint16_t runs )
static
405019 {
405020 const bool can_use_null_array = array_null < MAX_ARRAY_IDX;
405021 const bool can_use_non_null_array = array_non_null < MAX_ARRAY_IDX;
405022
405023 const bool can_use_run = runs < MAX_RUN_IDX;
405024
405025 const bool can_use_array = can_use_null_array || can_use_non_null_array;
405026 if (!can_use_array && !can_use_run) {
405027 // Can not efficiently encode at all, write it as bitset
405028 return ContainerMetadata::BitsetContainer(count);
405029 }
405030 uint16_t null_array_cost = array_null < COMPRESSED_ARRAY_THRESHOLD
405031 ? array_null * sizeof(uint16_t)
405032 : COMPRESSED_SEGMENT_COUNT + (array_null * sizeof(uint8_t));
405033 uint16_t non_null_array_cost = array_non_null < COMPRESSED_ARRAY_THRESHOLD
405034 ? array_non_null * sizeof(uint16_t)
405035 : COMPRESSED_SEGMENT_COUNT + (array_non_null * sizeof(uint8_t));
405036
405037 uint16_t lowest_array_cost = MinValue<uint16_t>(null_array_cost, non_null_array_cost);
405038 uint16_t lowest_run_cost = runs < COMPRESSED_RUN_THRESHOLD ? runs * sizeof(uint32_t)
405039 : COMPRESSED_SEGMENT_COUNT + (runs * sizeof(uint16_t));
405040 uint16_t bitset_cost =
405041 (AlignValue<uint16_t, ValidityMask::BITS_PER_VALUE>(count) / ValidityMask::BITS_PER_VALUE) * sizeof(validity_t);
405042 if (MinValue<uint16_t>(lowest_array_cost, lowest_run_cost) > bitset_cost) {
405043 // The amount of values is too small, better off using bitset
405044 // we can detect this at decompression because we know how many values are left
405045 return ContainerMetadata::BitsetContainer(count);
405046 }
405047
405048 if (lowest_array_cost <= lowest_run_cost) {
405049 if (array_null <= array_non_null) {
405050 return ContainerMetadata::ArrayContainer(array_null, NULLS);
405051 } else {
405052 return ContainerMetadata::ArrayContainer(array_non_null, NON_NULLS);
405053 }
405054 } else {
405055 return ContainerMetadata::RunContainer(runs);
405056 }
405057}
::uint32_t uint32_t
::uint8_t uint8_t
::uint16_t uint16_t
static T AlignValue(T n)
Align value (ceiling) (not for pointer types).
Definition duckdb.hpp:2126

◆ RunContainer()

ContainerMetadata duckdb::roaring::ContainerMetadata::RunContainer ( uint16_t runs)
inlinestatic
403174 {
403175 auto res = ContainerMetadata();
403176 res.container_type = ContainerType::RUN_CONTAINER;
403177 res.nulls = true;
403178 res.count = runs;
403179 return res;
403180 }

◆ ArrayContainer()

ContainerMetadata duckdb::roaring::ContainerMetadata::ArrayContainer ( uint16_t array_size,
bool nulls )
inlinestatic
403182 {
403183 auto res = ContainerMetadata();
403184 res.container_type = ContainerType::ARRAY_CONTAINER;
403185 res.nulls = nulls;
403186 res.count = array_size;
403187 return res;
403188 }

◆ BitsetContainer()

ContainerMetadata duckdb::roaring::ContainerMetadata::BitsetContainer ( uint16_t container_size)
inlinestatic
403190 {
403191 auto res = ContainerMetadata();
403192 res.container_type = ContainerType::BITSET_CONTAINER;
403193 res.nulls = true;
403194 res.count = container_size;
403195 return res;
403196 }

◆ GetDataSizeInBytes()

idx_t duckdb::roaring::ContainerMetadata::GetDataSizeInBytes ( idx_t container_size) const
405059 {
405060 if (IsUncompressed()) {
405061 return (container_size / ValidityMask::BITS_PER_VALUE) * sizeof(validity_t);
405062 }
405063 if (IsRun()) {
405064 auto number_of_runs = NumberOfRuns();
405065 if (number_of_runs >= COMPRESSED_RUN_THRESHOLD) {
405066 return COMPRESSED_SEGMENT_COUNT + (sizeof(uint8_t) * number_of_runs * 2);
405067 } else {
405068 return sizeof(RunContainerRLEPair) * number_of_runs;
405069 }
405070 } else {
405071 auto cardinality = Cardinality();
405072 if (cardinality >= COMPRESSED_ARRAY_THRESHOLD) {
405073 return COMPRESSED_SEGMENT_COUNT + (sizeof(uint8_t) * cardinality);
405074 } else {
405075 return sizeof(uint16_t) * cardinality;
405076 }
405077 }
405078}

◆ IsUncompressed()

bool duckdb::roaring::ContainerMetadata::IsUncompressed ( ) const
inline
403200 {
403201 return container_type == ContainerType::BITSET_CONTAINER;
403202 }

◆ IsRun()

bool duckdb::roaring::ContainerMetadata::IsRun ( ) const
inline
403203 {
403204 return container_type == ContainerType::RUN_CONTAINER;
403205 }

◆ IsInverted()

bool duckdb::roaring::ContainerMetadata::IsInverted ( ) const
inline
403206 {
403207 return nulls;
403208 }

◆ IsArray()

bool duckdb::roaring::ContainerMetadata::IsArray ( ) const
inline
403209 {
403210 return container_type == ContainerType::ARRAY_CONTAINER;
403211 }

◆ NumberOfRuns()

idx_t duckdb::roaring::ContainerMetadata::NumberOfRuns ( ) const
inline
403212 {
403213 D_ASSERT(IsRun());
403214 return count;
403215 }

◆ Cardinality()

idx_t duckdb::roaring::ContainerMetadata::Cardinality ( ) const
inline
403216 {
403217 D_ASSERT(IsArray());
403218 return count;
403219 }

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