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

Public Member Functions

 CopyToFunctionLocalState (ClientContext &context, unique_ptr< LocalFunctionData > local_state)
void InitializeAppendState (ClientContext &context, const PhysicalCopyToFile &op, CopyToFunctionGlobalState &gstate)
void AppendToPartition (ExecutionContext &context, const PhysicalCopyToFile &op, CopyToFunctionGlobalState &g, DataChunk &chunk)
void ResetAppendState ()
void SetDataWithoutPartitions (DataChunk &chunk, const DataChunk &source, const vector< LogicalType > &col_types, const vector< idx_t > &part_cols)
void FlushPartitions (ExecutionContext &context, const PhysicalCopyToFile &op, CopyToFunctionGlobalState &g)
Public Member Functions inherited from duckdb::LocalSinkState
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Public Attributes

unique_ptr< GlobalFunctionData > global_state
unique_ptr< LocalFunctionData > local_state
idx_t total_rows_copied = 0
idx_t partitioned_write_flush_threshold
unique_ptr< HivePartitionedColumnData > part_buffer
 Buffers the tuples in partitions before writing.
unique_ptr< PartitionedColumnDataAppendState > part_buffer_append_state
idx_t append_count = 0
Public Attributes inherited from duckdb::LocalSinkState
SourcePartitionInfo partition_info
 Source partition info.

Constructor & Destructor Documentation

◆ CopyToFunctionLocalState()

duckdb::CopyToFunctionLocalState::CopyToFunctionLocalState ( ClientContext & context,
unique_ptr< LocalFunctionData > local_state )
inlineexplicit
194203 : local_state(std::move(local_state)) {
194204 partitioned_write_flush_threshold = Settings::Get<PartitionedWriteFlushThresholdSetting>(context);
194205 }

Member Function Documentation

◆ InitializeAppendState()

void duckdb::CopyToFunctionLocalState::InitializeAppendState ( ClientContext & context,
const PhysicalCopyToFile & op,
CopyToFunctionGlobalState & gstate )
inline
194218 {
194219 part_buffer = make_uniq<HivePartitionedColumnData>(context, op.expected_types, op.partition_columns,
194220 gstate.partition_state);
194221 part_buffer_append_state = make_uniq<PartitionedColumnDataAppendState>();
194222 part_buffer->InitializeAppendState(*part_buffer_append_state);
194223 append_count = 0;
194224 }
unique_ptr< HivePartitionedColumnData > part_buffer
Buffers the tuples in partitions before writing.
Definition duckdb.cpp:194212

◆ AppendToPartition()

void duckdb::CopyToFunctionLocalState::AppendToPartition ( ExecutionContext & context,
const PhysicalCopyToFile & op,
CopyToFunctionGlobalState & g,
DataChunk & chunk )
inline
194227 {
194228 if (!part_buffer) {
194229 // re-initialize the append
194230 InitializeAppendState(context.client, op, g);
194231 }
194232 part_buffer->Append(*part_buffer_append_state, chunk);
194233 append_count += chunk.size();
194234 if (append_count >= partitioned_write_flush_threshold) {
194235 // flush all cached partitions
194236 FlushPartitions(context, op, g);
194237 }
194238 }

◆ ResetAppendState()

void duckdb::CopyToFunctionLocalState::ResetAppendState ( )
inline
194240 {
194241 part_buffer_append_state.reset();
194242 part_buffer.reset();
194243 append_count = 0;
194244 }

◆ SetDataWithoutPartitions()

void duckdb::CopyToFunctionLocalState::SetDataWithoutPartitions ( DataChunk & chunk,
const DataChunk & source,
const vector< LogicalType > & col_types,
const vector< idx_t > & part_cols )
inline
194247 {
194248 D_ASSERT(source.ColumnCount() == col_types.size());
194249 auto types = LogicalCopyToFile::GetTypesWithoutPartitions(col_types, part_cols, false);
194250 chunk.InitializeEmpty(types);
194251 set<idx_t> part_col_set(part_cols.begin(), part_cols.end());
194252 idx_t new_col_id = 0;
194253 for (idx_t col_idx = 0; col_idx < source.ColumnCount(); col_idx++) {
194254 if (part_col_set.find(col_idx) == part_col_set.end()) {
194255 chunk.data[new_col_id].Reference(source.data[col_idx]);
194256 new_col_id++;
194257 }
194258 }
194259 chunk.SetCardinality(source.size());
194260 }
DUCKDB_API void InitializeEmpty(const vector< LogicalType > &types)
Initializes a DataChunk with the given types and without any vector data allocation.
Definition duckdb.cpp:116783
vector< Vector > data
The vectors owned by the DataChunk.
Definition duckdb.hpp:11445
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ FlushPartitions()

void duckdb::CopyToFunctionLocalState::FlushPartitions ( ExecutionContext & context,
const PhysicalCopyToFile & op,
CopyToFunctionGlobalState & g )
inline
194262 {
194263 if (!part_buffer) {
194264 return;
194265 }
194266 part_buffer->FlushAppendState(*part_buffer_append_state);
194267 auto &partitions = part_buffer->GetPartitions();
194268 auto partition_key_map = part_buffer->GetReverseMap();
194269
194270 for (idx_t i = 0; i < partitions.size(); i++) {
194271 auto entry = partition_key_map.find(i);
194272 if (entry == partition_key_map.end()) {
194273 continue;
194274 }
194275 // get the partition write info for this buffer
194276 auto &info = g.GetPartitionWriteInfo(context, op, entry->second->values);
194277
194278 auto local_copy_state = op.function.copy_to_initialize_local(context, *op.bind_data);
194279 // push the chunks into the write state
194280 for (auto &chunk : partitions[i]->Chunks()) {
194281 if (op.write_partition_columns) {
194282 op.function.copy_to_sink(context, *op.bind_data, *info.global_state, *local_copy_state, chunk);
194283 } else {
194284 DataChunk filtered_chunk;
194285 SetDataWithoutPartitions(filtered_chunk, chunk, op.expected_types, op.partition_columns);
194286 op.function.copy_to_sink(context, *op.bind_data, *info.global_state, *local_copy_state,
194287 filtered_chunk);
194288 }
194289 }
194290 op.function.copy_to_combine(context, *op.bind_data, *info.global_state, *local_copy_state);
194291 local_copy_state.reset();
194292 partitions[i].reset();
194293 g.FinishPartitionWrite(info);
194294 }
194295 ResetAppendState();
194296 }

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