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

Public Types

using Predicates = vector<ExpressionType>

Public Member Functions

void Initialize (const bool no_match_sel, const TupleDataLayout &layout, const Predicates &predicates, vector< column_t > columns={})
idx_t Match (DataChunk &lhs, const vector< TupleDataVectorFormat > &lhs_formats, SelectionVector &sel, idx_t count, Vector &rhs_row_locations, SelectionVector *no_match_sel, idx_t &no_match_count)

Private Member Functions

MatchFunction GetMatchFunction (const bool no_match_sel, const LogicalType &type, const ExpressionType predicate)
 Gets the templated match function for a given column.
template<bool NO_MATCH_SEL>
MatchFunction GetMatchFunction (const LogicalType &type, const ExpressionType predicate)
template<bool NO_MATCH_SEL, class T>
MatchFunction GetMatchFunction (const ExpressionType predicate)
template<bool NO_MATCH_SEL>
MatchFunction GetStructMatchFunction (const LogicalType &type, const ExpressionType predicate)
template<bool NO_MATCH_SEL>
MatchFunction GetListMatchFunction (const ExpressionType predicate)

Private Attributes

optional_ptr< const TupleDataLayout > rhs_layout
vector< column_t > columns
vector< MatchFunction > match_functions
vector< LogicalType > rhs_types

Member Function Documentation

◆ Initialize()

void duckdb::RowMatcher::Initialize ( const bool no_match_sel,
const TupleDataLayout & layout,
const Predicates & predicates,
vector< column_t > columns = {} )

Initializes the RowMatcher, filling match_functions using layout and equality_predicates If columns is empty, we assume column indices 0, 1, 2, etc.

100195 {
100196 if (columns_p.empty()) {
100197 // Assume all columns
100198 columns_p.reserve(predicates.size());
100199 for (column_t col_idx = 0; col_idx < predicates.size(); col_idx++) {
100200 columns_p.emplace_back(col_idx);
100201 }
100202 }
100203
100204 rhs_layout = &layout;
100205 columns = columns_p;
100206
100207 // The columns must have the same size as the predicates vector
100208 D_ASSERT(columns.size() == predicates.size());
100209
100210 // The largest column_id must be smaller than the number of types to not cause an out-of-bounds error
100211 D_ASSERT(*max_element(columns.begin(), columns.end()) < layout.GetTypes().size());
100212
100213 match_functions.reserve(predicates.size());
100214 for (idx_t idx = 0; idx < predicates.size(); idx++) {
100215 const column_t col_idx = columns[idx];
100216 match_functions.push_back(GetMatchFunction(no_match_sel, layout.GetTypes()[col_idx], predicates[idx]));
100217 rhs_types.push_back(layout.GetTypes()[col_idx]);
100218 }
100219}
idx_t column_t
Type used for column identifiers.
Definition duckdb.hpp:259
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
MatchFunction GetMatchFunction(const bool no_match_sel, const LogicalType &type, const ExpressionType predicate)
Gets the templated match function for a given column.
Definition duckdb.cpp:100244
Here is the call graph for this function:

◆ Match()

idx_t duckdb::RowMatcher::Match ( DataChunk & lhs,
const vector< TupleDataVectorFormat > & lhs_formats,
SelectionVector & sel,
idx_t count,
Vector & rhs_row_locations,
SelectionVector * no_match_sel,
idx_t & no_match_count )

Given a DataChunk on the LHS, on which we've called TupleDataCollection::ToUnifiedFormat, we match it with rows on the RHS, according to the given layout and locations. Initially, 'sel' has 'count' entries which point to what needs to be compared. After matching is done, this returns how many matching entries there are, which 'sel' is modified to point to

100222 {
100223 D_ASSERT(!match_functions.empty());
100224
100225 // The column_ids must have the same size as the match_functions vector
100226 D_ASSERT(columns.size() == match_functions.size());
100227
100228 // The largest column_id must be smaller than the number columns to not cause an out-of-bounds error
100229 D_ASSERT(*max_element(columns.begin(), columns.end()) < lhs.ColumnCount());
100230
100231 for (idx_t fun_idx = 0; fun_idx < match_functions.size(); fun_idx++) {
100232 // if we only care about specific columns, we need to use the column_ids to get the correct column index
100233 // otherwise, we just use the fun_idx
100234 const auto col_idx = columns[fun_idx];
100235
100236 const auto &match_function = match_functions[fun_idx];
100237 count =
100238 match_function.function(lhs.data[col_idx], lhs_formats[col_idx], sel, count, *rhs_layout, rhs_row_locations,
100239 col_idx, match_function.child_functions, no_match_sel, no_match_count);
100240 }
100241 return count;
100242}
vector< Vector > data
The vectors owned by the DataChunk.
Definition duckdb.hpp:11445
Here is the caller graph for this function:

◆ GetMatchFunction() [1/3]

MatchFunction duckdb::RowMatcher::GetMatchFunction ( const bool no_match_sel,
const LogicalType & type,
const ExpressionType predicate )
private

Gets the templated match function for a given column.

100245 {
100246 return no_match_sel ? GetMatchFunction<true>(type, predicate) : GetMatchFunction<false>(type, predicate);
100247}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMatchFunction() [2/3]

template<bool NO_MATCH_SEL>
MatchFunction duckdb::RowMatcher::GetMatchFunction ( const LogicalType & type,
const ExpressionType predicate )
private
100250 {
100251 switch (type.InternalType()) {
100252 case PhysicalType::BOOL:
100253 return GetMatchFunction<NO_MATCH_SEL, bool>(predicate);
100254 case PhysicalType::INT8:
100255 return GetMatchFunction<NO_MATCH_SEL, int8_t>(predicate);
100256 case PhysicalType::INT16:
100257 return GetMatchFunction<NO_MATCH_SEL, int16_t>(predicate);
100258 case PhysicalType::INT32:
100259 return GetMatchFunction<NO_MATCH_SEL, int32_t>(predicate);
100260 case PhysicalType::INT64:
100261 return GetMatchFunction<NO_MATCH_SEL, int64_t>(predicate);
100262 case PhysicalType::INT128:
100264 case PhysicalType::UINT8:
100265 return GetMatchFunction<NO_MATCH_SEL, uint8_t>(predicate);
100272 case PhysicalType::UINT128:
100274 case PhysicalType::FLOAT:
100275 return GetMatchFunction<NO_MATCH_SEL, float>(predicate);
100277 return GetMatchFunction<NO_MATCH_SEL, double>(predicate);
100283 return GetStructMatchFunction<NO_MATCH_SEL>(type, predicate);
100284 case PhysicalType::LIST:
100285 return GetListMatchFunction<NO_MATCH_SEL>(predicate);
100286 case PhysicalType::ARRAY:
100287 // Same logic as for lists
100288 return GetListMatchFunction<NO_MATCH_SEL>(predicate);
100289 default:
100290 throw InternalException("Unsupported PhysicalType for RowMatcher::GetMatchFunction: %s",
100291 EnumUtil::ToString(type.InternalType()));
100292 }
100293}
@ UINT32
Unsigned 32-bit little-endian integer.
Definition duckdb.hpp:2758
@ INTERVAL
YEAR_MONTH or DAY_TIME interval in SQL style.
Definition duckdb.hpp:2806
@ LIST
A list of some logical data type.
Definition duckdb.hpp:2813
@ UINT16
Unsigned 16-bit little-endian integer.
Definition duckdb.hpp:2752
@ INT64
Signed 64-bit little-endian integer.
Definition duckdb.hpp:2767
@ INT16
Signed 16-bit little-endian integer.
Definition duckdb.hpp:2755
@ INT32
Signed 32-bit little-endian integer.
Definition duckdb.hpp:2761
@ UINT64
Unsigned 64-bit little-endian integer.
Definition duckdb.hpp:2764
@ BOOL
Boolean as 8 bit "bool" value.
Definition duckdb.hpp:2743
@ STRUCT
Struct of logical types.
Definition duckdb.hpp:2816
@ VARCHAR
DuckDB Extensions.
Definition duckdb.hpp:2847
@ FLOAT
4-byte floating point value
Definition duckdb.hpp:2773
@ UINT8
Unsigned 8-bit little-endian integer.
Definition duckdb.hpp:2746
@ INT8
Signed 8-bit little-endian integer.
Definition duckdb.hpp:2749
@ DOUBLE
8-byte floating point value
Definition duckdb.hpp:2776

◆ GetMatchFunction() [3/3]

template<bool NO_MATCH_SEL, class T>
MatchFunction duckdb::RowMatcher::GetMatchFunction ( const ExpressionType predicate)
private
100296 {
100297 MatchFunction result;
100298 switch (predicate) {
100299 case ExpressionType::COMPARE_EQUAL:
100300 result.function = TemplatedMatch<NO_MATCH_SEL, T, Equals>;
100301 break;
100302 case ExpressionType::COMPARE_NOTEQUAL:
100303 result.function = TemplatedMatch<NO_MATCH_SEL, T, NotEquals>;
100304 break;
100305 case ExpressionType::COMPARE_DISTINCT_FROM:
100306 result.function = TemplatedMatch<NO_MATCH_SEL, T, DistinctFrom>;
100307 break;
100308 case ExpressionType::COMPARE_NOT_DISTINCT_FROM:
100309 result.function = TemplatedMatch<NO_MATCH_SEL, T, NotDistinctFrom>;
100310 break;
100311 case ExpressionType::COMPARE_GREATERTHAN:
100312 result.function = TemplatedMatch<NO_MATCH_SEL, T, GreaterThan>;
100313 break;
100314 case ExpressionType::COMPARE_GREATERTHANOREQUALTO:
100315 result.function = TemplatedMatch<NO_MATCH_SEL, T, GreaterThanEquals>;
100316 break;
100317 case ExpressionType::COMPARE_LESSTHAN:
100318 result.function = TemplatedMatch<NO_MATCH_SEL, T, LessThan>;
100319 break;
100320 case ExpressionType::COMPARE_LESSTHANOREQUALTO:
100321 result.function = TemplatedMatch<NO_MATCH_SEL, T, LessThanEquals>;
100322 break;
100323 default:
100324 throw InternalException("Unsupported ExpressionType for RowMatcher::GetMatchFunction: %s",
100325 EnumUtil::ToString(predicate));
100326 }
100327 return result;
100328}

◆ GetStructMatchFunction()

template<bool NO_MATCH_SEL>
MatchFunction duckdb::RowMatcher::GetStructMatchFunction ( const LogicalType & type,
const ExpressionType predicate )
private
100331 {
100332 // We perform equality conditions like it's just a row, but we cannot perform inequality conditions like a row,
100333 // because for equality conditions we need to always loop through all columns, but for inequality conditions,
100334 // we need to find the first inequality, so the loop looks very different
100335 MatchFunction result;
100336 ExpressionType child_predicate = predicate;
100337 switch (predicate) {
100338 case ExpressionType::COMPARE_EQUAL:
100339 result.function = StructMatchEquality<NO_MATCH_SEL, Equals>;
100340 child_predicate = ExpressionType::COMPARE_NOT_DISTINCT_FROM;
100341 break;
100342 case ExpressionType::COMPARE_NOTEQUAL:
100343 result.function = GenericNestedMatch<NO_MATCH_SEL, NotEquals>;
100344 return result;
100345 case ExpressionType::COMPARE_DISTINCT_FROM:
100346 result.function = GenericNestedMatch<NO_MATCH_SEL, DistinctFrom>;
100347 return result;
100348 case ExpressionType::COMPARE_NOT_DISTINCT_FROM:
100349 result.function = StructMatchEquality<NO_MATCH_SEL, NotDistinctFrom>;
100350 break;
100351 case ExpressionType::COMPARE_GREATERTHAN:
100352 result.function = GenericNestedMatch<NO_MATCH_SEL, GreaterThan>;
100353 return result;
100354 case ExpressionType::COMPARE_GREATERTHANOREQUALTO:
100355 result.function = GenericNestedMatch<NO_MATCH_SEL, GreaterThanEquals>;
100356 return result;
100357 case ExpressionType::COMPARE_LESSTHAN:
100358 result.function = GenericNestedMatch<NO_MATCH_SEL, LessThan>;
100359 return result;
100360 case ExpressionType::COMPARE_LESSTHANOREQUALTO:
100361 result.function = GenericNestedMatch<NO_MATCH_SEL, LessThanEquals>;
100362 return result;
100363 default:
100364 throw InternalException("Unsupported ExpressionType for RowMatcher::GetStructMatchFunction: %s",
100365 EnumUtil::ToString(predicate));
100366 }
100367
100368 result.child_functions.reserve(StructType::GetChildCount(type));
100369 for (const auto &child_type : StructType::GetChildTypes(type)) {
100370 result.child_functions.push_back(GetMatchFunction<NO_MATCH_SEL>(child_type.second, child_predicate));
100371 }
100372
100373 return result;
100374}

◆ GetListMatchFunction()

template<bool NO_MATCH_SEL>
MatchFunction duckdb::RowMatcher::GetListMatchFunction ( const ExpressionType predicate)
private
100377 {
100378 MatchFunction result;
100379 switch (predicate) {
100380 case ExpressionType::COMPARE_EQUAL:
100381 result.function = GenericNestedMatch<NO_MATCH_SEL, Equals>;
100382 break;
100383 case ExpressionType::COMPARE_NOTEQUAL:
100384 result.function = GenericNestedMatch<NO_MATCH_SEL, NotEquals>;
100385 break;
100386 case ExpressionType::COMPARE_DISTINCT_FROM:
100387 result.function = GenericNestedMatch<NO_MATCH_SEL, DistinctFrom>;
100388 break;
100389 case ExpressionType::COMPARE_NOT_DISTINCT_FROM:
100390 result.function = GenericNestedMatch<NO_MATCH_SEL, NotDistinctFrom>;
100391 break;
100392 case ExpressionType::COMPARE_GREATERTHAN:
100393 result.function = GenericNestedMatch<NO_MATCH_SEL, GreaterThan>;
100394 break;
100395 case ExpressionType::COMPARE_GREATERTHANOREQUALTO:
100396 result.function = GenericNestedMatch<NO_MATCH_SEL, GreaterThanEquals>;
100397 break;
100398 case ExpressionType::COMPARE_LESSTHAN:
100399 result.function = GenericNestedMatch<NO_MATCH_SEL, LessThan>;
100400 break;
100401 case ExpressionType::COMPARE_LESSTHANOREQUALTO:
100402 result.function = GenericNestedMatch<NO_MATCH_SEL, LessThanEquals>;
100403 break;
100404 default:
100405 throw InternalException("Unsupported ExpressionType for RowMatcher::GetListMatchFunction: %s",
100406 EnumUtil::ToString(predicate));
100407 }
100408 return result;
100409}

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