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::SortKeyPrefixComparison Struct Reference
Collaboration diagram for duckdb::SortKeyPrefixComparison:

Public Member Functions

template<class SORT_KEY>
SortKeyPrefixComparisonResult Compare (const SORT_KEY &lhs, const SORT_KEY &rhs)

Public Attributes

unsafe_vector< SortKeyPrefixComparisonColumn > columns
DataChunk decoded

Member Function Documentation

◆ Compare()

template<class SORT_KEY>
SortKeyPrefixComparisonResult duckdb::SortKeyPrefixComparison::Compare ( const SORT_KEY & lhs,
const SORT_KEY & rhs )
inline
182396 {
182397 SortKeyPrefixComparisonResult result {0, ExpressionType::COMPARE_EQUAL};
182398
182399 auto lhs_copy = lhs;
182400 string_t lhs_key;
182401 lhs_copy.Deconstruct(lhs_key);
182402 auto lhs_ptr = lhs_key.GetData();
182403
182404 auto rhs_copy = rhs;
182405 string_t rhs_key;
182406 rhs_copy.Deconstruct(rhs_key);
182407 auto rhs_ptr = rhs_key.GetData();
182408
182409 // Partition keys are always sorted this way.
182410 OrderModifiers modifiers(OrderType::ASCENDING, OrderByNullType::NULLS_FIRST);
182411
182412 for (column_t col_idx = 0; col_idx < columns.size(); ++col_idx) {
182413 const auto &col = columns[col_idx];
182414 auto &vec = decoded.data[col_idx];
182415 auto lhs_width = col.size;
182416 auto rhs_width = col.size;
182417 int cmp = 1;
182418 switch (col.type) {
182419 case SortKeyPrefixComparisonType::FIXED:
182420 cmp = memcmp(lhs_ptr, rhs_ptr, lhs_width);
182421 break;
182422 case SortKeyPrefixComparisonType::VARCHAR:
182423 // Include first null byte.
182424 lhs_width = 1 + strlen(lhs_ptr);
182425 rhs_width = 1 + strlen(rhs_ptr);
182426 cmp = memcmp(lhs_ptr, rhs_ptr, MinValue<idx_t>(lhs_width, rhs_width));
182427 break;
182428 case SortKeyPrefixComparisonType::NESTED:
182429 decoded.Reset();
182430 lhs_width = CreateSortKeyHelpers::DecodeSortKey(lhs_key, vec, 0, modifiers);
182431 rhs_width = CreateSortKeyHelpers::DecodeSortKey(rhs_key, vec, 1, modifiers);
182432 cmp = memcmp(lhs_ptr, rhs_ptr, MinValue<idx_t>(lhs_width, rhs_width));
182433 if (!cmp) {
182434 cmp = (rhs_width < lhs_width) - (lhs_width < rhs_width);
182435 }
182436 break;
182437 }
182438
182439 if (cmp) {
182440 result.type = (cmp < 0) ? ExpressionType::COMPARE_LESSTHAN : ExpressionType::COMPARE_GREATERTHAN;
182441 return result;
182442 }
182443
182444 ++result.column_index;
182445 lhs_ptr += lhs_width;
182446 rhs_ptr += rhs_width;
182447 }
182448
182449 return result;
182450 }
idx_t column_t
Type used for column identifiers.
Definition duckdb.hpp:259
DataChunk decoded
Definition duckdb.cpp:182393

Member Data Documentation

◆ decoded

DataChunk duckdb::SortKeyPrefixComparison::decoded

Two row buffer for measuring lhs and rhs widths for nested types. Gross, but there is currently no way to measure the width of a single key except as a side-effect of decoding it...


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