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
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
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:
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