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::VariableSortKey< SORT_KEY, HAS_PAYLOAD > Struct Template Reference
Inheritance diagram for duckdb::VariableSortKey< SORT_KEY, HAS_PAYLOAD >:
Collaboration diagram for duckdb::VariableSortKey< SORT_KEY, HAS_PAYLOAD >:

Public Member Functions

void ByteSwap ()
 
void Construct (const string_t &val, data_ptr_t &heap_ptr)
 
void Construct (const int64_t &, data_ptr_t &)
 
void Deconstruct (string_t &val)
 
void Deconstruct (int64_t &)
 
data_ptr_t GetData () const
 
void SetData (const data_ptr_t &data)
 
idx_t GetSize () const
 
idx_t GetHeapSize () const
 

Static Public Member Functions

static int32_t TernaryCompare (const uint64_t &lhs, const uint64_t &rhs)
 
static int32_t LessThan (const uint64_t *const &lhs, const uint64_t *const &rhs)
 

Static Public Attributes

static constexpr bool CONSTANT_SIZE = false
 

Protected Attributes

friend SORT_KEY
 

Friends

bool operator< (const SORT_KEY &lhs, const SORT_KEY &rhs)
 

Member Function Documentation

◆ ByteSwap()

template<class SORT_KEY , bool HAS_PAYLOAD>
void duckdb::VariableSortKey< SORT_KEY, HAS_PAYLOAD >::ByteSwap ( )
inline
55488 {
55489 auto &sort_key = static_cast<SORT_KEY &>(*this);
55490 for (idx_t i = 0; i < SORT_KEY::PARTS; i++) {
55491 (&sort_key.part0)[i] = BSwapIfLE((&sort_key.part0)[i]);
55492 }
55493 }

◆ Construct() [1/2]

template<class SORT_KEY , bool HAS_PAYLOAD>
void duckdb::VariableSortKey< SORT_KEY, HAS_PAYLOAD >::Construct ( const string_t val,
data_ptr_t &  heap_ptr 
)
inline
55495 {
55496 auto &sort_key = static_cast<SORT_KEY &>(*this);
55497 // Initialize to 0's (including size by doing + 1)
55498 for (idx_t i = 0; i < SORT_KEY::PARTS + 1; i++) {
55499 (&sort_key.part0)[i] = 0;
55500 }
55501
55502 // Deal with inlined part first
55503 memcpy(&sort_key.part0, val.GetData(), MinValue(val.GetSize(), SORT_KEY::INLINE_LENGTH));
55504 // Same as FixedSortKey, we do not store the data in byte-comparable order
55505 ByteSwap();
55506
55507 // Deal with non-inlined part (if necessary)
55508 if (val.GetSize() > SORT_KEY::INLINE_LENGTH) {
55509 sort_key.size = val.GetSize();
55510 sort_key.data.u.ptr = heap_ptr;
55511 memcpy(sort_key.data.u.ptr, val.GetData(), sort_key.size);
55512 heap_ptr += sort_key.size;
55513 }
55514 }

◆ Construct() [2/2]

template<class SORT_KEY , bool HAS_PAYLOAD>
void duckdb::VariableSortKey< SORT_KEY, HAS_PAYLOAD >::Construct ( const int64_t ,
data_ptr_t &   
)
inline
55516 {
55517 throw InternalException("VariableSortKey::Construct() called with an int64_t");
55518 }

◆ Deconstruct() [1/2]

template<class SORT_KEY , bool HAS_PAYLOAD>
void duckdb::VariableSortKey< SORT_KEY, HAS_PAYLOAD >::Deconstruct ( string_t val)
inline
55520 {
55521 auto &sort_key = static_cast<SORT_KEY &>(*this);
55522 if (sort_key.size > SORT_KEY::INLINE_LENGTH) {
55523 val = string_t(const_char_ptr_cast(sort_key.data.u.ptr), UnsafeNumericCast<uint32_t>(sort_key.size));
55524 } else {
55525 ByteSwap();
55526 val = string_t(const_char_ptr_cast(&sort_key.part0), UnsafeNumericCast<uint32_t>(SORT_KEY::INLINE_LENGTH));
55527 }
55528 }

◆ Deconstruct() [2/2]

template<class SORT_KEY , bool HAS_PAYLOAD>
void duckdb::VariableSortKey< SORT_KEY, HAS_PAYLOAD >::Deconstruct ( int64_t )
inline
55530 {
55531 throw InternalException("VariableSortKey::Deconstruct() called with an int64_t");
55532 }

◆ GetData()

template<class SORT_KEY , bool HAS_PAYLOAD>
data_ptr_t duckdb::VariableSortKey< SORT_KEY, HAS_PAYLOAD >::GetData ( ) const
inline
55534 {
55535 auto &sort_key = static_cast<const SORT_KEY &>(*this);
55536 return sort_key.data.u.ptr;
55537 }

◆ SetData()

template<class SORT_KEY , bool HAS_PAYLOAD>
void duckdb::VariableSortKey< SORT_KEY, HAS_PAYLOAD >::SetData ( const data_ptr_t &  data)
inline
55539 {
55540 auto &sort_key = static_cast<SORT_KEY &>(*this);
55541 sort_key.data.u.ptr = data;
55542 }

◆ GetSize()

template<class SORT_KEY , bool HAS_PAYLOAD>
idx_t duckdb::VariableSortKey< SORT_KEY, HAS_PAYLOAD >::GetSize ( ) const
inline
55544 {
55545 auto &sort_key = static_cast<const SORT_KEY &>(*this);
55546 return MaxValue(sort_key.size, SORT_KEY::INLINE_LENGTH);
55547 }

◆ GetHeapSize()

template<class SORT_KEY , bool HAS_PAYLOAD>
idx_t duckdb::VariableSortKey< SORT_KEY, HAS_PAYLOAD >::GetHeapSize ( ) const
inline
55549 {
55550 auto &sort_key = static_cast<const SORT_KEY &>(*this);
55551 return sort_key.size;
55552 }

◆ TernaryCompare()

template<class SORT_KEY , bool HAS_PAYLOAD>
static int32_t duckdb::VariableSortKey< SORT_KEY, HAS_PAYLOAD >::TernaryCompare ( const uint64_t lhs,
const uint64_t rhs 
)
inlinestatic
55554 {
55555 return (lhs > rhs) - (lhs < rhs);
55556 }

◆ LessThan()

template<class SORT_KEY , bool HAS_PAYLOAD>
static int32_t duckdb::VariableSortKey< SORT_KEY, HAS_PAYLOAD >::LessThan ( const uint64_t *const lhs,
const uint64_t *const rhs 
)
inlinestatic
55558 {
55559 switch (SORT_KEY::PARTS) {
55560 case 1:
55561 return TernaryCompare(lhs[0], rhs[0]);
55562 case 2:
55563 return 2 * TernaryCompare(lhs[0], rhs[0]) + TernaryCompare(lhs[1], rhs[1]);
55564 default:
55565 throw NotImplementedException("VariableSortKey::LessThan for %llu parts", SORT_KEY::PARTS);
55566 }
55567 }

Friends And Related Symbol Documentation

◆ operator<

template<class SORT_KEY , bool HAS_PAYLOAD>
bool operator< ( const SORT_KEY &  lhs,
const SORT_KEY &  rhs 
)
friend
55569 {
55570 auto comp_res = LessThan(&lhs.part0, &rhs.part0);
55571 // If inlined is not equal, we can return already
55572 if (comp_res != 0) {
55573 return comp_res < 0;
55574 }
55575
55576 // Inlined is equal. If either string is inlined, it is considered "less than"
55577 if (lhs.size <= SORT_KEY::INLINE_LENGTH || rhs.size <= SORT_KEY::INLINE_LENGTH) {
55578 return lhs.size < rhs.size;
55579 }
55580
55581 // Both strings are non-inlined
55582 comp_res = memcmp(lhs.data.u.ptr, rhs.data.u.ptr, MinValue(lhs.size, rhs.size));
55583 return comp_res < 0 || (comp_res == 0 && lhs.size < rhs.size);
55584 }

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