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::CrossProductExecutor Class Reference
Collaboration diagram for duckdb::CrossProductExecutor:

Public Member Functions

 CrossProductExecutor (ColumnDataCollection &rhs)
OperatorResultType Execute (DataChunk &input, DataChunk &output)
bool ScanLHS ()
idx_t PositionInChunk ()
idx_t ScanPosition ()

Private Member Functions

void Reset (DataChunk &input, DataChunk &output)
bool NextValue (DataChunk &input, DataChunk &output)

Private Attributes

ColumnDataCollection & rhs
ColumnDataScanState scan_state
DataChunk scan_chunk
idx_t position_in_chunk
bool initialized
bool finished
bool scan_input_chunk

Constructor & Destructor Documentation

◆ CrossProductExecutor()

duckdb::CrossProductExecutor::CrossProductExecutor ( ColumnDataCollection & rhs)
explicit
183950 : rhs(rhs), position_in_chunk(0), initialized(false), finished(false) {
183951 rhs.InitializeScanChunk(scan_chunk);
183952}

Member Function Documentation

◆ Execute()

OperatorResultType duckdb::CrossProductExecutor::Execute ( DataChunk & input,
DataChunk & output )
183989 {
183990 if (rhs.Count() == 0) {
183991 // no RHS: empty result
183992 return OperatorResultType::FINISHED;
183993 }
183994 if (!NextValue(input, output)) {
183995 // ran out of entries on the RHS
183996 // reset the RHS and move to the next chunk on the LHS
183997 initialized = false;
183998 return OperatorResultType::NEED_MORE_INPUT;
183999 }
184000
184001 // set up the constant chunk
184002 auto &constant_chunk = scan_input_chunk ? scan_chunk : input;
184003 auto col_count = constant_chunk.ColumnCount();
184004 auto col_offset = scan_input_chunk ? input.ColumnCount() : 0;
184005 output.SetCardinality(constant_chunk.size());
184006 for (idx_t i = 0; i < col_count; i++) {
184007 output.data[col_offset + i].Reference(constant_chunk.data[i]);
184008 }
184009
184010 // for the chunk that we are scanning, scan a single value from that chunk
184011 auto &scan = scan_input_chunk ? input : scan_chunk;
184012 col_count = scan.ColumnCount();
184013 col_offset = scan_input_chunk ? 0 : input.ColumnCount();
184014 for (idx_t i = 0; i < col_count; i++) {
184015 ConstantVector::Reference(output.data[col_offset + i], scan.data[i], position_in_chunk, scan.size());
184016 }
184017 return OperatorResultType::HAVE_MORE_OUTPUT;
184018}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
static DUCKDB_API void Reference(Vector &vector, Vector &source, idx_t position, idx_t count)
Turns "vector" into a constant vector by referencing a value within the source vector.
Definition duckdb.cpp:137793

◆ ScanLHS()

bool duckdb::CrossProductExecutor::ScanLHS ( )
inline
183485 {
183486 return scan_input_chunk;
183487 }

◆ PositionInChunk()

idx_t duckdb::CrossProductExecutor::PositionInChunk ( )
inline
183490 {
183491 return position_in_chunk;
183492 }

◆ ScanPosition()

idx_t duckdb::CrossProductExecutor::ScanPosition ( )
inline
183494 {
183495 return scan_state.current_row_index;
183496 }

◆ Reset()

void duckdb::CrossProductExecutor::Reset ( DataChunk & input,
DataChunk & output )
private
183954 {
183955 initialized = true;
183956 finished = false;
183957 scan_input_chunk = false;
183958 rhs.InitializeScan(scan_state);
183959 position_in_chunk = 0;
183960 scan_chunk.Reset();
183961}

◆ NextValue()

bool duckdb::CrossProductExecutor::NextValue ( DataChunk & input,
DataChunk & output )
private
183963 {
183964 if (!initialized) {
183965 // not initialized yet: initialize the scan
183966 Reset(input, output);
183967 }
183968 position_in_chunk++;
183969 idx_t chunk_size = scan_input_chunk ? input.size() : scan_chunk.size();
183970 if (position_in_chunk < chunk_size) {
183971 return true;
183972 }
183973 // fetch the next chunk
183974 rhs.Scan(scan_state, scan_chunk);
183975 position_in_chunk = 0;
183976 if (scan_chunk.size() == 0) {
183977 return false;
183978 }
183979 // the way the cross product works is that we keep one chunk constantly referenced
183980 // while iterating over the other chunk one value at a time
183981 // the second one is the chunk we are "scanning"
183982
183983 // for the engine, it is better if we emit larger chunks
183984 // hence the chunk that we keep constantly referenced should be the larger of the two
183985 scan_input_chunk = input.size() < scan_chunk.size();
183986 return true;
183987}

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