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

Public Member Functions

 ColumnScanState (optional_ptr< CollectionScanState > parent_p)
void PushDownCast (const LogicalType &original_type, const LogicalType &cast_type)
void Initialize (const QueryContext &context_p, const LogicalType &type, const StorageIndex &column_id, optional_ptr< TableScanOptions > options)
void Initialize (const QueryContext &context_p, const LogicalType &type, optional_ptr< TableScanOptions > options)
void Next (idx_t count)
 Move the scan state forward by "count" rows (including all child states).
void NextInternal (idx_t count)
 Move ONLY this state forward by "count" rows (i.e. not the child states).
idx_t GetPositionInSegment () const
 Returns the current row position in the segment.

Public Attributes

optional_ptr< CollectionScanState > parent
QueryContext context
 The query context for this scan.
optional_ptr< SegmentNode< ColumnSegment > > current
 The column segment that is currently being scanned.
ColumnSegmentTree * segment_tree = nullptr
 Column segment tree.
idx_t offset_in_column = 0
 The current row offset in the column.
idx_t internal_index = 0
 The internal row index (i.e. the position of the SegmentScanState).
StorageIndex storage_index
 Storage index of the current column that's being scanned.
unique_ptr< SegmentScanState > scan_state
 Segment scan state.
unsafe_vector< ColumnScanState > child_states
 Child states of the vector.
bool initialized = false
 Whether or not InitializeState has been called for this segment.
bool segment_checked = false
 If this segment has already been checked for skipping purposes.
vector< unique_ptr< SegmentScanState > > previous_states
idx_t last_offset = 0
 The last read offset in the child state (used for LIST columns only).
vector< bool > scan_child_column
 Whether or not we should scan a specific child column.
optional_ptr< TableScanOptions > scan_options
 Contains TableScan level config for scanning.
unique_ptr< PushedDownExpressionState > expression_state
 (optionally) the expression state for any pushed down expression(s)
UpdateScanType update_scan_type = UpdateScanType::STANDARD
 Whether or not updates should be allowed.

Constructor & Destructor Documentation

◆ ColumnScanState()

duckdb::ColumnScanState::ColumnScanState ( optional_ptr< CollectionScanState > parent_p)
inlineexplicit
74906 : parent(parent_p) {
74907 }

Member Function Documentation

◆ PushDownCast()

void duckdb::ColumnScanState::PushDownCast ( const LogicalType & original_type,
const LogicalType & cast_type )
433145 {
433146 D_ASSERT(context.Valid());
433147 D_ASSERT(!expression_state);
433148 auto &client_context = *context.GetClientContext();
433149
433150 auto input = make_uniq<BoundReferenceExpression>(original_type, 0ULL);
433151 auto cast_expression = BoundCastExpression::AddCastToType(client_context, std::move(input), cast_type);
433152 expression_state = make_uniq<PushedDownExpressionState>(client_context);
433153 expression_state->target.Initialize(client_context, {cast_type});
433154 expression_state->input.Initialize(client_context, {original_type});
433155 expression_state->executor.AddExpression(*cast_expression);
433156 expression_state->expression = std::move(cast_expression);
433157}
static DUCKDB_API unique_ptr< Expression > AddCastToType(ClientContext &context, unique_ptr< Expression > expr, const LogicalType &target_type, bool try_cast=false)
Cast an expression to the specified SQL type if required.
Definition duckdb.cpp:375869
unique_ptr< PushedDownExpressionState > expression_state
(optionally) the expression state for any pushed down expression(s)
Definition duckdb.cpp:74940
QueryContext context
The query context for this scan.
Definition duckdb.cpp:74911

◆ Initialize() [1/2]

void duckdb::ColumnScanState::Initialize ( const QueryContext & context_p,
const LogicalType & type,
const StorageIndex & column_id,
optional_ptr< TableScanOptions > options )
433160 {
433161 auto &children = column_id.GetChildIndexes();
433162 // Register the options in the state
433163 scan_options = options;
433164 context = context_p;
433165 storage_index = column_id;
433166
433167 D_ASSERT(type.id() != LogicalTypeId::INVALID);
433168 if (type.id() == LogicalTypeId::VALIDITY) {
433169 // validity - nothing to initialize
433170 return;
433171 }
433172
433173 if (type.id() == LogicalTypeId::VARIANT) {
433174 // variant - column scan states are created later
433175 // this is done because the internal shape of the VARIANT is different per rowgroup
433176 scan_child_column.resize(2, true);
433177 if (!storage_index.IsPushdownExtract()) {
433178 return;
433179 }
433180 auto &scan_type = storage_index.GetScanType();
433181 if (scan_type.id() != LogicalTypeId::VARIANT) {
433182 PushDownCast(type, scan_type);
433183 }
433184 return;
433185 }
433186
433187 D_ASSERT(child_states.empty());
433188 if (type.InternalType() == PhysicalType::STRUCT) {
433189 // validity + struct children
433190 auto &struct_children = StructType::GetChildTypes(type);
433191 child_states.reserve(struct_children.size() + 1);
433192 for (idx_t i = 0; i <= struct_children.size(); i++) {
433193 child_states.emplace_back(parent);
433194 }
433195
433196 if (children.empty()) {
433197 // scan all struct children
433198 scan_child_column.resize(struct_children.size(), true);
433199 for (idx_t i = 0; i < struct_children.size(); i++) {
433200 child_states[i + 1].Initialize(context, struct_children[i].second, options);
433201 }
433202 } else {
433203 if (storage_index.IsPushdownExtract()) {
433204 D_ASSERT(context.Valid());
433205 scan_child_column.resize(1, true);
433206 D_ASSERT(children.size() == 1);
433207 auto &child = children[0];
433208 auto child_index = child.GetPrimaryIndex();
433209 auto &child_type = StructType::GetChildTypes(type)[child_index].second;
433210 if (!child.HasChildren() && child_type != child.GetType()) {
433211 PushDownCast(child_type, child.GetType());
433212 }
433213 child_states[1].Initialize(context, struct_children[child_index].second, child, options);
433214 } else {
433215 // only scan the specified subset of columns
433216 scan_child_column.resize(struct_children.size(), false);
433217 for (idx_t i = 0; i < children.size(); i++) {
433218 auto &child = children[i];
433219 auto index = child.GetPrimaryIndex();
433220 scan_child_column[index] = true;
433221 child_states[index + 1].Initialize(context, struct_children[index].second, child, options);
433222 }
433223 }
433224 }
433225 child_states[0].scan_options = options;
433226 } else if (type.InternalType() == PhysicalType::LIST) {
433227 // validity + list child
433228 for (idx_t i = 0; i < 2; i++) {
433229 child_states.emplace_back(parent);
433230 }
433231 child_states[1].Initialize(context, ListType::GetChildType(type), options);
433232 child_states[0].scan_options = options;
433233 } else if (type.InternalType() == PhysicalType::ARRAY) {
433234 // validity + array child
433235 for (idx_t i = 0; i < 2; i++) {
433236 child_states.emplace_back(parent);
433237 }
433238 child_states[0].scan_options = options;
433239 child_states[1].Initialize(context, ArrayType::GetChildType(type), options);
433240 } else {
433241 // validity
433242 child_states.emplace_back(parent);
433243 child_states[0].scan_options = options;
433244 }
433245}
index
@ LIST
A list of some logical data type.
Definition duckdb.hpp:2813
@ STRUCT
Struct of logical types.
Definition duckdb.hpp:2816
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
optional_ptr< TableScanOptions > scan_options
Contains TableScan level config for scanning.
Definition duckdb.cpp:74938
unsafe_vector< ColumnScanState > child_states
Child states of the vector.
Definition duckdb.cpp:74925
StorageIndex storage_index
Storage index of the current column that's being scanned.
Definition duckdb.cpp:74921
vector< bool > scan_child_column
Whether or not we should scan a specific child column.
Definition duckdb.cpp:74936

◆ Initialize() [2/2]

void duckdb::ColumnScanState::Initialize ( const QueryContext & context_p,
const LogicalType & type,
optional_ptr< TableScanOptions > options )
433248 {
433249 auto column_id = StorageIndex(0);
433250 Initialize(context_p, type, column_id, options);
433251}

◆ Next()

void duckdb::ColumnScanState::Next ( idx_t count)

Move the scan state forward by "count" rows (including all child states).

437468 {
437469 NextInternal(count);
437470 for (auto &child_state : child_states) {
437471 child_state.Next(count);
437472 }
437473}
void NextInternal(idx_t count)
Move ONLY this state forward by "count" rows (i.e. not the child states).
Definition duckdb.cpp:437446
Here is the call graph for this function:
Here is the caller graph for this function:

◆ NextInternal()

void duckdb::ColumnScanState::NextInternal ( idx_t count)

Move ONLY this state forward by "count" rows (i.e. not the child states).

There is no column segment

437446 {
437447 if (!current) {
437449 return;
437450 }
437451 offset_in_column += count;
437452 while (offset_in_column >= current->GetRowStart() + current->GetNode().count) {
437453 current = segment_tree->GetNextSegment(*current);
437454 initialized = false;
437455 segment_checked = false;
437456 if (!current) {
437457 break;
437458 }
437459 }
437460 D_ASSERT(!current || (offset_in_column >= current->GetRowStart() &&
437461 offset_in_column < current->GetRowStart() + current->GetNode().count));
437462}
idx_t offset_in_column
The current row offset in the column.
Definition duckdb.cpp:74917
optional_ptr< SegmentNode< ColumnSegment > > current
The column segment that is currently being scanned.
Definition duckdb.cpp:74913
bool initialized
Whether or not InitializeState has been called for this segment.
Definition duckdb.cpp:74927
bool segment_checked
If this segment has already been checked for skipping purposes.
Definition duckdb.cpp:74929
ColumnSegmentTree * segment_tree
Column segment tree.
Definition duckdb.cpp:74915
Here is the caller graph for this function:

◆ GetPositionInSegment()

idx_t duckdb::ColumnScanState::GetPositionInSegment ( ) const

Returns the current row position in the segment.

437464 {
437465 return offset_in_column - (current ? current->GetRowStart() : 0);
437466}

Member Data Documentation

◆ previous_states

vector<unique_ptr<SegmentScanState> > duckdb::ColumnScanState::previous_states

We initialize one SegmentScanState per segment, however, if scanning a DataChunk requires us to scan over more than one Segment, we need to keep the scan states of the previous segments around


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