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::alp::AlpRDCompression< T, EMPTY > Struct Template Reference

Public Types

using CompressionData = AlpRDCompressionData<T, EMPTY>
using EXACT_TYPE = typename FloatingToExact<T>::TYPE

Static Public Member Functions

static double EstimateCompressionSize (uint8_t right_bit_width, uint8_t left_bit_width, uint16_t exceptions_count, uint64_t sample_count)
template<bool PERSIST_DICT>
static double BuildLeftPartsDictionary (const vector< EXACT_TYPE > &values, uint8_t right_bit_width, CompressionData &compression_data)
static double FindBestDictionary (const vector< EXACT_TYPE > &values, CompressionData &compression_data)
static void Compress (const EXACT_TYPE *input_vector, idx_t n_values, CompressionData &compression_data)

Static Public Attributes

static constexpr uint8_t EXACT_TYPE_BITSIZE = sizeof(EXACT_TYPE) * 8

Member Function Documentation

◆ EstimateCompressionSize()

template<class T, bool EMPTY>
double duckdb::alp::AlpRDCompression< T, EMPTY >::EstimateCompressionSize ( uint8_t right_bit_width,
uint8_t left_bit_width,
uint16_t exceptions_count,
uint64_t sample_count )
inlinestatic
393999 {
394000 double exceptions_size =
394002 double estimated_size =
394003 right_bit_width + left_bit_width + (exceptions_size / static_cast<double>(sample_count));
394004 return estimated_size;
394005 }
Definition duckdb.cpp:393990

◆ BuildLeftPartsDictionary()

template<class T, bool EMPTY>
template<bool PERSIST_DICT>
double duckdb::alp::AlpRDCompression< T, EMPTY >::BuildLeftPartsDictionary ( const vector< EXACT_TYPE > & values,
uint8_t right_bit_width,
CompressionData & compression_data )
inlinestatic

The dict keys are mapped to the left part themselves

Pararelly we store a map of the dictionary to quickly resolve exceptions during encoding

394009 {
394012
394013 // Building a hash for all the left parts and how many times they appear
394014 for (auto &value : values) {
394015 auto left_tmp = value >> right_bit_width;
394017 }
394018
394019 // We build a vector from the hash to be able to sort it by repetition count
394021 for (auto &hash_pair : left_parts_hash) {
394022 left_parts_sorted_repetitions.emplace_back(hash_pair.second, hash_pair.first);
394023 }
394025 [](const AlpRDLeftPartInfo &a, const AlpRDLeftPartInfo &b) { return a.count > b.count; });
394026
394027 // Exceptions are left parts which do not fit in the fixed dictionary size
394031 }
394032
394033 // The left parts bit width after compression is determined by how many elements are in the dictionary
394038
394039 if (PERSIST_DICT) {
394042 compression_data.left_parts_dict[dict_idx] =
394044 compression_data.left_parts_dict_map.insert({compression_data.left_parts_dict[dict_idx], dict_idx});
394045 }
394048 compression_data.left_parts_dict_map.insert({left_parts_sorted_repetitions[i].hash, i});
394049 }
394050 compression_data.left_bit_width = left_bit_width;
394051 compression_data.right_bit_width = right_bit_width;
394053
394054 D_ASSERT(compression_data.left_bit_width > 0 && compression_data.right_bit_width > 0 &&
394056 compression_data.actual_dictionary_size <= AlpRDConstants::MAX_DICTIONARY_SIZE);
394057 }
394058
394059 double estimated_size = EstimateCompressionSize(right_bit_width, left_bit_width,
394061 return estimated_size;
394062 }
Here is the caller graph for this function:

◆ FindBestDictionary()

template<class T, bool EMPTY>
double duckdb::alp::AlpRDCompression< T, EMPTY >::FindBestDictionary ( const vector< EXACT_TYPE > & values,
CompressionData & compression_data )
inlinestatic

Finding the best position to CUT the values

394064 {
394068 for (idx_t i = 1; i <= AlpRDConstants::CUTTING_LIMIT; i++) {
394070 double estimated_size =
394075 }
394076 // TODO: We could implement an early exit mechanism similar to normal ALP
394077 }
394079 return estimated_size;
394080 }
static double BuildLeftPartsDictionary(const vector< EXACT_TYPE > &values, uint8_t right_bit_width, CompressionData &compression_data)
Definition duckdb.cpp:394008
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Compress()

template<class T, bool EMPTY>
void duckdb::alp::AlpRDCompression< T, EMPTY >::Compress ( const EXACT_TYPE * input_vector,
idx_t n_values,
CompressionData & compression_data )
inlinestatic

If not found on the dictionary we store the smallest non-key index as exception (the dict size)

Left parts not found in the dictionary are stored as exceptions

394082 {
394085
394086 // Cutting the floating point values
394087 for (idx_t i = 0; i < n_values; i++) {
394088 EXACT_TYPE tmp = input_vector[i];
394089 right_parts[i] = tmp & ((1ULL << compression_data.right_bit_width) - 1);
394091 }
394092
394093 // Dictionary encoding for left parts
394094 for (idx_t i = 0; i < n_values; i++) {
394096 auto dictionary_key = left_parts[i];
394097 if (compression_data.left_parts_dict_map.find(dictionary_key) ==
394098 compression_data.left_parts_dict_map.end()) {
394100 dictionary_index = compression_data.actual_dictionary_size;
394101 } else {
394102 dictionary_index = compression_data.left_parts_dict_map[dictionary_key];
394103 }
394105
394107 if (dictionary_index >= compression_data.actual_dictionary_size) {
394108 compression_data.exceptions[compression_data.exceptions_count] = dictionary_key;
394109 compression_data.exceptions_positions[compression_data.exceptions_count] =
394111 compression_data.exceptions_count++;
394112 }
394113 }
394114
394117
394118 if (!EMPTY) {
394119 // Bitpacking Left and Right parts
394121 compression_data.left_bit_width);
394123 n_values, compression_data.right_bit_width);
394124 }
394125
394126 compression_data.left_bit_packed_size = left_bit_packed_size;
394127 compression_data.right_bit_packed_size = right_bit_packed_size;
394128 }
Here is the caller graph for this function:

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