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::ColumnDataConsumer Class Reference

ColumnDataConsumer can scan a ColumnDataCollection, and consume it in the process, i.e., read blocks are deleted. More...

Collaboration diagram for duckdb::ColumnDataConsumer:

Classes

struct  ChunkReference

Public Member Functions

 ColumnDataConsumer (ColumnDataCollection &collection, vector< column_t > column_ids)
idx_t Count () const
idx_t ChunkCount () const
void InitializeScan ()
 Initialize the scan of the ColumnDataCollection.
bool AssignChunk (ColumnDataConsumerScanState &state)
 Assign a chunk to the scan state.
void ScanChunk (ColumnDataConsumerScanState &state, DataChunk &chunk) const
 Scan the assigned chunk.
void FinishChunk (ColumnDataConsumerScanState &state)
 Indicate that scanning the chunk is done.

Private Member Functions

void ConsumeChunks (idx_t delete_index_start, idx_t delete_index_end)

Private Attributes

mutex lock
ColumnDataCollection & collection
 The collection being scanned.
vector< column_t > column_ids
 The column ids to scan.
idx_t chunk_count
 The number of chunk references.
vector< ChunkReference > chunk_references
 The chunks (in order) to be scanned.
idx_t current_chunk_index
 Current index into "chunks".
unordered_set< idx_t > chunks_in_progress
 Chunks currently in progress.
idx_t chunk_delete_index
 The data has been consumed up to this chunk index.

Detailed Description

ColumnDataConsumer can scan a ColumnDataCollection, and consume it in the process, i.e., read blocks are deleted.

Constructor & Destructor Documentation

◆ ColumnDataConsumer()

duckdb::ColumnDataConsumer::ColumnDataConsumer ( ColumnDataCollection & collection,
vector< column_t > column_ids )
116279 : collection(collection_p), column_ids(std::move(column_ids)) {
116280}
ColumnDataCollection & collection
The collection being scanned.
Definition duckdb.cpp:116245
vector< column_t > column_ids
The column ids to scan.
Definition duckdb.cpp:116247

Member Function Documentation

◆ Count()

idx_t duckdb::ColumnDataConsumer::Count ( ) const
inline
116221 {
116222 return collection.Count();
116223 }

◆ ChunkCount()

idx_t duckdb::ColumnDataConsumer::ChunkCount ( ) const
inline
116225 {
116226 return chunk_count;
116227 }
idx_t chunk_count
The number of chunk references.
Definition duckdb.cpp:116249

◆ InitializeScan()

void duckdb::ColumnDataConsumer::InitializeScan ( )

Initialize the scan of the ColumnDataCollection.

116282 {
116283 chunk_count = collection.ChunkCount();
116286
116287 // Initialize chunk references and sort them, so we can scan them in a sane order, regardless of how it was created
116288 chunk_references.reserve(chunk_count);
116289 for (auto &segment : collection.GetSegments()) {
116290 for (idx_t chunk_index = 0; chunk_index < segment->chunk_data.size(); chunk_index++) {
116291 chunk_references.emplace_back(segment.get(), chunk_index);
116292 }
116293 }
116294 std::sort(chunk_references.begin(), chunk_references.end());
116295}
vector< ChunkReference > chunk_references
The chunks (in order) to be scanned.
Definition duckdb.cpp:116251
idx_t current_chunk_index
Current index into "chunks".
Definition duckdb.cpp:116253
idx_t chunk_delete_index
The data has been consumed up to this chunk index.
Definition duckdb.cpp:116257
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
static constexpr const idx_t INVALID_INDEX
The value used to signify an invalid index entry.
Definition duckdb.hpp:1117

◆ AssignChunk()

bool duckdb::ColumnDataConsumer::AssignChunk ( ColumnDataConsumerScanState & state)

Assign a chunk to the scan state.

116297 {
116298 lock_guard<mutex> guard(lock);
116300 // All chunks have been assigned
116301 state.current_chunk_state.handles.clear();
116302 state.chunk_index = DConstants::INVALID_INDEX;
116303 return false;
116304 }
116305 // Assign chunk index
116306 state.chunk_index = current_chunk_index++;
116307 D_ASSERT(chunks_in_progress.find(state.chunk_index) == chunks_in_progress.end());
116308 chunks_in_progress.insert(state.chunk_index);
116309 return true;
116310}
unordered_set< idx_t > chunks_in_progress
Chunks currently in progress.
Definition duckdb.cpp:116255

◆ ScanChunk()

void duckdb::ColumnDataConsumer::ScanChunk ( ColumnDataConsumerScanState & state,
DataChunk & chunk ) const

Scan the assigned chunk.

116312 {
116313 D_ASSERT(state.chunk_index < chunk_count);
116314 auto &chunk_ref = chunk_references[state.chunk_index];
116315 if (state.allocator != chunk_ref.segment->allocator.get()) {
116316 // Previously scanned a chunk from a different allocator, reset the handles
116317 state.allocator = chunk_ref.segment->allocator.get();
116318 state.current_chunk_state.handles.clear();
116319 }
116320 chunk_ref.segment->ReadChunk(chunk_ref.chunk_index_in_segment, state.current_chunk_state, chunk, column_ids);
116321}

◆ FinishChunk()

void duckdb::ColumnDataConsumer::FinishChunk ( ColumnDataConsumerScanState & state)

Indicate that scanning the chunk is done.

116323 {
116324 D_ASSERT(state.chunk_index < chunk_count);
116325 idx_t delete_index_start;
116326 idx_t delete_index_end;
116327 {
116328 lock_guard<mutex> guard(lock);
116329 D_ASSERT(chunks_in_progress.find(state.chunk_index) != chunks_in_progress.end());
116330 delete_index_start = chunk_delete_index;
116331 delete_index_end = *std::min_element(chunks_in_progress.begin(), chunks_in_progress.end());
116332 chunks_in_progress.erase(state.chunk_index);
116333 chunk_delete_index = delete_index_end;
116334 }
116335 ConsumeChunks(delete_index_start, delete_index_end);
116336}

◆ ConsumeChunks()

void duckdb::ColumnDataConsumer::ConsumeChunks ( idx_t delete_index_start,
idx_t delete_index_end )
private
116337 {
116338 for (idx_t chunk_index = delete_index_start; chunk_index < delete_index_end; chunk_index++) {
116339 if (chunk_index == 0) {
116340 continue;
116341 }
116342 auto &prev_chunk_ref = chunk_references[chunk_index - 1];
116343 auto &curr_chunk_ref = chunk_references[chunk_index];
116344 auto prev_allocator = prev_chunk_ref.segment->allocator.get();
116345 auto curr_allocator = curr_chunk_ref.segment->allocator.get();
116346 auto prev_min_block_id = prev_chunk_ref.GetMinimumBlockID();
116347 auto curr_min_block_id = curr_chunk_ref.GetMinimumBlockID();
116348 if (prev_allocator != curr_allocator) {
116349 // Moved to the next allocator, delete all remaining blocks in the previous one
116350 for (uint32_t block_id = prev_min_block_id; block_id < prev_allocator->BlockCount(); block_id++) {
116351 prev_allocator->SetDestroyBufferUponUnpin(block_id);
116352 }
116353 continue;
116354 }
116355 // Same allocator, see if we can delete blocks
116356 for (uint32_t block_id = prev_min_block_id; block_id < curr_min_block_id; block_id++) {
116357 prev_allocator->SetDestroyBufferUponUnpin(block_id);
116358 }
116359 }
116360}

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