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

Parse a file from disk using a specified copy function and return the set of chunks retrieved from the file. More...

Inheritance diagram for duckdb::PhysicalExport:
Collaboration diagram for duckdb::PhysicalExport:

Public Member Functions

 PhysicalExport (PhysicalPlan &physical_plan, vector< LogicalType > types, CopyFunction function, unique_ptr< CopyInfo > info, idx_t estimated_cardinality, unique_ptr< BoundExportData > exported_tables)
unique_ptr< GlobalSourceState > GetGlobalSourceState (ClientContext &context) const override
SourceResultType GetDataInternal (ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const override
bool IsSource () const override
SinkResultType Sink (ExecutionContext &context, DataChunk &chunk, OperatorSinkInput &input) const override
bool ParallelSink () const override
bool IsSink () const override
void BuildPipelines (Pipeline &current, MetaPipeline &meta_pipeline) override
vector< const_reference< PhysicalOperator > > GetSources () const override
Public Member Functions inherited from duckdb::PhysicalOperator
 PhysicalOperator (PhysicalPlan &physical_plan, PhysicalOperatorType type, vector< LogicalType > types, idx_t estimated_cardinality)
 PhysicalOperator (const PhysicalOperator &other)=delete
 Deleted copy constructors.
PhysicalOperator & operator= (const PhysicalOperator &)=delete
virtual string GetName () const
virtual InsertionOrderPreservingMap< string > ParamsToString () const
virtual string ToString (ExplainFormat format=ExplainFormat::DEFAULT) const
void Print () const
virtual vector< const_reference< PhysicalOperator > > GetChildren () const
const vector< LogicalType > & GetTypes () const
 Return a vector of the types that will be returned by this operator.
virtual bool Equals (const PhysicalOperator &other) const
idx_t EstimatedThreadCount () const
 Functions to help decide how to set up pipeline dependencies.
bool CanSaturateThreads (ClientContext &context) const
virtual void Verify ()
virtual unique_ptr< OperatorState > GetOperatorState (ExecutionContext &context) const
virtual unique_ptr< GlobalOperatorState > GetGlobalOperatorState (ClientContext &context) const
virtual OperatorResultType Execute (ExecutionContext &context, DataChunk &input, DataChunk &chunk, GlobalOperatorState &gstate, OperatorState &state) const
virtual OperatorFinalizeResultType FinalExecute (ExecutionContext &context, DataChunk &chunk, GlobalOperatorState &gstate, OperatorState &state) const
virtual OperatorFinalResultType OperatorFinalize (Pipeline &pipeline, Event &event, ClientContext &context, OperatorFinalizeInput &input) const
virtual bool ParallelOperator () const
virtual bool RequiresFinalExecute () const
virtual bool RequiresOperatorFinalize () const
virtual OrderPreservationType OperatorOrder () const
 The influence the operator has on order (insertion order means no influence).
virtual unique_ptr< LocalSourceState > GetLocalSourceState (ExecutionContext &context, GlobalSourceState &gstate) const
SourceResultType GetData (ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const
virtual OperatorPartitionData GetPartitionData (ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate, LocalSourceState &lstate, const OperatorPartitionInfo &partition_info) const
virtual bool ParallelSource () const
virtual bool SupportsPartitioning (const OperatorPartitionInfo &partition_info) const
virtual OrderPreservationType SourceOrder () const
 The type of order emitted by the operator (as a source).
virtual ProgressData GetProgress (ClientContext &context, GlobalSourceState &gstate) const
 Returns the current progress percentage, or a negative value if progress bars are not supported.
virtual ProgressData GetSinkProgress (ClientContext &context, GlobalSinkState &gstate, const ProgressData source_progress) const
 Returns the current progress percentage, or a negative value if progress bars are not supported.
virtual InsertionOrderPreservingMap< string > ExtraSourceParams (GlobalSourceState &gstate, LocalSourceState &lstate) const
virtual SinkCombineResultType Combine (ExecutionContext &context, OperatorSinkCombineInput &input) const
virtual void PrepareFinalize (ClientContext &context, GlobalSinkState &sink_state) const
virtual SinkFinalizeType Finalize (Pipeline &pipeline, Event &event, ClientContext &context, OperatorSinkFinalizeInput &input) const
virtual SinkNextBatchType NextBatch (ExecutionContext &context, OperatorSinkNextBatchInput &input) const
virtual unique_ptr< LocalSinkState > GetLocalSinkState (ExecutionContext &context) const
virtual unique_ptr< GlobalSinkState > GetGlobalSinkState (ClientContext &context) const
virtual OperatorPartitionInfo RequiredPartitionInfo () const
virtual bool SinkOrderDependent () const
bool AllSourcesSupportBatchIndex () const
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Static Public Member Functions

static void ExtractEntries (ClientContext &context, vector< reference< SchemaCatalogEntry > > &schemas, ExportEntries &result)
static catalog_entry_vector_t GetNaiveExportOrder (ClientContext &context, Catalog &catalog)
Static Public Member Functions inherited from duckdb::PhysicalOperator
static void SetEstimatedCardinality (InsertionOrderPreservingMap< string > &result, idx_t estimated_cardinality)
static idx_t GetMaxThreadMemory (ClientContext &context)
 The maximum amount of memory the operator should use per thread.
static OperatorCachingMode SelectOperatorCachingMode (ExecutionContext &context)
 Whether operator caching is allowed in the current execution context.

Public Attributes

CopyFunction function
 The copy function to use to read the file.
unique_ptr< CopyInfo > info
 The binding info containing the set of options for reading the file.
unique_ptr< BoundExportData > exported_tables
 The table info for each table that will be exported.
Public Attributes inherited from duckdb::PhysicalOperator
ArenaLinkedList< reference< PhysicalOperator > > children
 The child operators.
PhysicalOperatorType type
 The physical operator type.
vector< LogicalType > types
 The return types.
idx_t estimated_cardinality
 The estimated cardinality.
unique_ptr< GlobalSinkState > sink_state
 The global sink state.
unique_ptr< GlobalOperatorState > op_state
 The global operator state.
mutex lock
 Lock for (re)setting any of the operator states.

Static Public Attributes

static constexpr const PhysicalOperatorType TYPE = PhysicalOperatorType::EXPORT
Static Public Attributes inherited from duckdb::PhysicalOperator
static constexpr const PhysicalOperatorType TYPE = PhysicalOperatorType::INVALID

Detailed Description

Parse a file from disk using a specified copy function and return the set of chunks retrieved from the file.

Constructor & Destructor Documentation

◆ PhysicalExport()

duckdb::PhysicalExport::PhysicalExport ( PhysicalPlan & physical_plan,
vector< LogicalType > types,
CopyFunction function,
unique_ptr< CopyInfo > info,
idx_t estimated_cardinality,
unique_ptr< BoundExportData > exported_tables )
195154 : PhysicalOperator(physical_plan, PhysicalOperatorType::EXPORT, std::move(types), estimated_cardinality),
195155 function(std::move(function)), info(std::move(info)), exported_tables(std::move(exported_tables)) {
195156}
unique_ptr< CopyInfo > info
The binding info containing the set of options for reading the file.
Definition duckdb.cpp:195093
CopyFunction function
The copy function to use to read the file.
Definition duckdb.cpp:195091
unique_ptr< BoundExportData > exported_tables
The table info for each table that will be exported.
Definition duckdb.cpp:195095
vector< LogicalType > types
The return types.
Definition duckdb.hpp:22152
idx_t estimated_cardinality
The estimated cardinality.
Definition duckdb.hpp:22154

Member Function Documentation

◆ GetGlobalSourceState()

unique_ptr< GlobalSourceState > duckdb::PhysicalExport::GetGlobalSourceState ( ClientContext & context) const
overridevirtual

Reimplemented from duckdb::PhysicalOperator.

195237 {
195238 return make_uniq<ExportSourceState>();
195239}

◆ GetDataInternal()

SourceResultType duckdb::PhysicalExport::GetDataInternal ( ExecutionContext & context,
DataChunk & chunk,
OperatorSourceInput & input ) const
overridevirtual

Reimplemented from duckdb::PhysicalOperator.

195336 {
195337 auto &state = input.global_state.Cast<ExportSourceState>();
195338 if (state.finished) {
195339 return SourceResultType::FINISHED;
195340 }
195341
195342 auto &ccontext = context.client;
195343 auto &fs = FileSystem::GetFileSystem(ccontext);
195344
195345 auto &catalog = Catalog::GetCatalog(ccontext, info->catalog);
195346
195347 catalog_entry_vector_t catalog_entries;
195348 catalog_entries = GetNaiveExportOrder(context.client, catalog);
195349 auto dependency_manager = catalog.GetDependencyManager();
195350 if (dependency_manager) {
195351 dependency_manager->ReorderEntries(catalog_entries, ccontext);
195352 }
195353
195354 // write the schema.sql file
195355 stringstream ss;
195356 WriteCatalogEntries(ss, catalog_entries);
195357 WriteStringStreamToFile(fs, ss, fs.JoinPath(info->file_path, "schema.sql"));
195358
195359 // write the load.sql file
195360 // for every table, we write COPY INTO statement with the specified options
195361 stringstream load_ss;
195362 for (idx_t i = 0; i < exported_tables->data.size(); i++) {
195363 auto exported_table_info = exported_tables->data[i].table_data;
195364 WriteCopyStatement(fs, load_ss, *info, exported_table_info);
195365 }
195366 WriteStringStreamToFile(fs, load_ss, fs.JoinPath(info->file_path, "load.sql"));
195367 state.finished = true;
195368
195369 return SourceResultType::FINISHED;
195370}
static DUCKDB_API Catalog & GetCatalog(ClientContext &context, const string &catalog_name)
Get the specified Catalog from the ClientContext.
Definition duckdb.cpp:7211
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
static void WriteCopyStatement(FileSystem &fs, stringstream &ss, CopyInfo &info, ExportedTableData &exported_table)
Definition duckdb.cpp:195185

◆ IsSource()

bool duckdb::PhysicalExport::IsSource ( ) const
inlineoverridevirtual

Reimplemented from duckdb::PhysicalOperator.

195103 {
195104 return true;
195105 }

◆ ExtractEntries()

void duckdb::PhysicalExport::ExtractEntries ( ClientContext & context,
vector< reference< SchemaCatalogEntry > > & schemas,
ExportEntries & result )
static
195242 {
195243 for (auto &schema_p : schema_list) {
195244 auto &schema = schema_p.get();
195245 auto &catalog = schema.ParentCatalog();
195246 if (catalog.IsSystemCatalog() || catalog.IsTemporaryCatalog()) {
195247 continue;
195248 }
195249 if (!schema.internal) {
195250 result.schemas.push_back(schema);
195251 }
195252 schema.Scan(context, CatalogType::TABLE_ENTRY, [&](CatalogEntry &entry) {
195253 if (entry.internal) {
195254 return;
195255 }
195256 if (entry.type != CatalogType::TABLE_ENTRY) {
195257 result.views.push_back(entry);
195258 }
195259 if (entry.type == CatalogType::TABLE_ENTRY) {
195260 result.tables.push_back(entry);
195261 }
195262 });
195263 schema.Scan(context, CatalogType::SEQUENCE_ENTRY, [&](CatalogEntry &entry) {
195264 if (entry.internal) {
195265 return;
195266 }
195267 result.sequences.push_back(entry);
195268 });
195269 schema.Scan(context, CatalogType::TYPE_ENTRY, [&](CatalogEntry &entry) {
195270 if (entry.internal) {
195271 return;
195272 }
195273 result.custom_types.push_back(entry);
195274 });
195275 schema.Scan(context, CatalogType::INDEX_ENTRY, [&](CatalogEntry &entry) {
195276 if (entry.internal) {
195277 return;
195278 }
195279 result.indexes.push_back(entry);
195280 });
195281 schema.Scan(context, CatalogType::MACRO_ENTRY, [&](CatalogEntry &entry) {
195282 if (!entry.internal && entry.type == CatalogType::MACRO_ENTRY) {
195283 result.macros.push_back(entry);
195284 }
195285 });
195286 schema.Scan(context, CatalogType::TABLE_MACRO_ENTRY, [&](CatalogEntry &entry) {
195287 if (!entry.internal && entry.type == CatalogType::TABLE_MACRO_ENTRY) {
195288 result.macros.push_back(entry);
195289 }
195290 });
195291 }
195292}

◆ GetNaiveExportOrder()

catalog_entry_vector_t duckdb::PhysicalExport::GetNaiveExportOrder ( ClientContext & context,
Catalog & catalog )
static
195301 {
195302 // gather all catalog types to export
195303 ExportEntries entries;
195304 auto schema_list = catalog.GetSchemas(context);
195305 PhysicalExport::ExtractEntries(context, schema_list, entries);
195306
195307 ReorderTableEntries(entries.tables);
195308
195309 // order macro's by timestamp so nested macro's are imported nicely
195310 sort(entries.macros.begin(), entries.macros.end(),
195311 [](const reference<CatalogEntry> &lhs, const reference<CatalogEntry> &rhs) {
195312 return lhs.get().oid < rhs.get().oid;
195313 });
195314
195315 catalog_entry_vector_t catalog_entries;
195316 idx_t size = 0;
195317 size += entries.schemas.size();
195318 size += entries.custom_types.size();
195319 size += entries.sequences.size();
195320 size += entries.tables.size();
195321 size += entries.views.size();
195322 size += entries.indexes.size();
195323 size += entries.macros.size();
195324 catalog_entries.reserve(size);
195325 AddEntries(catalog_entries, entries.schemas);
195326 AddEntries(catalog_entries, entries.sequences);
195327 AddEntries(catalog_entries, entries.custom_types);
195328 AddEntries(catalog_entries, entries.tables);
195329 AddEntries(catalog_entries, entries.macros);
195330 AddEntries(catalog_entries, entries.views);
195331 AddEntries(catalog_entries, entries.indexes);
195332 return catalog_entries;
195333}
void sort(InputArray src, OutputArray dst, int flags)
GOpaque< Size > size(const GMat &src)

◆ Sink()

SinkResultType duckdb::PhysicalExport::Sink ( ExecutionContext & context,
DataChunk & chunk,
OperatorSinkInput & input ) const
overridevirtual

The sink method is called constantly with new input, as long as new input is available. Note that this method CAN be called in parallel, proper locking is needed when accessing dat a inside the GlobalSinkState.

Reimplemented from duckdb::PhysicalOperator.

195375 {
195376 // nop
195377 return SinkResultType::NEED_MORE_INPUT;
195378}

◆ ParallelSink()

bool duckdb::PhysicalExport::ParallelSink ( ) const
inlineoverridevirtual

Reimplemented from duckdb::PhysicalOperator.

195115 {
195116 return true;
195117 }

◆ IsSink()

bool duckdb::PhysicalExport::IsSink ( ) const
inlineoverridevirtual

Reimplemented from duckdb::PhysicalOperator.

195118 {
195119 return true;
195120 }

◆ BuildPipelines()

void duckdb::PhysicalExport::BuildPipelines ( Pipeline & current,
MetaPipeline & meta_pipeline )
overridevirtual

Reimplemented from duckdb::PhysicalOperator.

195383 {
195384 // EXPORT has an optional child
195385 // we only need to schedule child pipelines if there is a child
195386 auto &state = meta_pipeline.GetState();
195387 state.SetPipelineSource(current, *this);
195388 if (children.empty()) {
195389 return;
195390 }
195391 PhysicalOperator::BuildPipelines(current, meta_pipeline);
195392}
ArenaLinkedList< reference< PhysicalOperator > > children
The child operators.
Definition duckdb.hpp:22148

◆ GetSources()

vector< const_reference< PhysicalOperator > > duckdb::PhysicalExport::GetSources ( ) const
overridevirtual

Reimplemented from duckdb::PhysicalOperator.

195394 {
195395 return {*this};
195396}

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