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

Public Member Functions

 LogicalCopyToFile (CopyFunction function, unique_ptr< FunctionData > bind_data, unique_ptr< CopyInfo > copy_info)
vector< ColumnBinding > GetColumnBindings () override
idx_t EstimateCardinality (ClientContext &context) override
void Serialize (Serializer &serializer) const override
Public Member Functions inherited from duckdb::LogicalOperator
 LogicalOperator (LogicalOperatorType type)
 LogicalOperator (LogicalOperatorType type, vector< unique_ptr< Expression > > expressions)
virtual idx_t GetRootIndex ()
void PrintColumnBindings ()
void ResolveOperatorTypes ()
 Resolve the types of the logical operator and its children.
virtual string GetName () const
virtual InsertionOrderPreservingMap< string > ParamsToString () const
virtual string ToString (ExplainFormat format=ExplainFormat::DEFAULT) const
DUCKDB_API void Print ()
virtual void Verify (ClientContext &context)
 Debug method: verify that the integrity of expressions & child nodes are maintained.
void AddChild (unique_ptr< LogicalOperator > child)
void SetEstimatedCardinality (idx_t _estimated_cardinality)
void SetParamsEstimatedCardinality (InsertionOrderPreservingMap< string > &result) const
virtual unique_ptr< LogicalOperator > Copy (ClientContext &context) const
virtual bool RequireOptimizer () const
virtual bool SupportSerialization () const
 Allows LogicalOperators to opt out of serialization.
virtual bool HasProjectionMap () const
virtual vector< idx_t > GetTableIndex () const
 Returns the set of table indexes of this operator.
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Static Public Member Functions

static unique_ptr< LogicalOperator > Deserialize (Deserializer &deserializer)
static vector< LogicalType > GetTypesWithoutPartitions (const vector< LogicalType > &col_types, const vector< idx_t > &part_cols, bool write_part_cols)
static vector< string > GetNamesWithoutPartitions (const vector< string > &col_names, const vector< column_t > &part_cols, bool write_part_cols)
Static Public Member Functions inherited from duckdb::LogicalOperator
static string ColumnBindingsToString (const vector< ColumnBinding > &bindings)
static vector< ColumnBinding > GenerateColumnBindings (idx_t table_idx, idx_t column_count)
static vector< LogicalType > MapTypes (const vector< LogicalType > &types, const vector< idx_t > &projection_map)
static vector< ColumnBinding > MapBindings (const vector< ColumnBinding > &types, const vector< idx_t > &projection_map)
static unique_ptr< LogicalOperator > Deserialize (Deserializer &deserializer)

Public Attributes

CopyFunction function
unique_ptr< FunctionData > bind_data
unique_ptr< CopyInfo > copy_info
std::string file_path
bool use_tmp_file
FilenamePattern filename_pattern
string file_extension
CopyOverwriteMode overwrite_mode
bool per_thread_output
optional_idx file_size_bytes
bool rotate
CopyFunctionReturnType return_type
bool partition_output
bool write_partition_columns
bool write_empty_file = true
bool hive_file_pattern = true
PreserveOrderType preserve_order = PreserveOrderType::AUTOMATIC
vector< idx_t > partition_columns
vector< string > names
vector< LogicalType > expected_types
Public Attributes inherited from duckdb::LogicalOperator
LogicalOperatorType type
 The type of the logical operator.
vector< unique_ptr< LogicalOperator > > children
 The set of children of the operator.
vector< unique_ptr< Expression > > expressions
 The set of expressions contained within the operator, if any.
vector< LogicalType > types
 The types returned by this logical operator. Set by calling LogicalOperator::ResolveTypes.
idx_t estimated_cardinality
 Estimated Cardinality.
bool has_estimated_cardinality

Static Public Attributes

static constexpr const LogicalOperatorType TYPE = LogicalOperatorType::LOGICAL_COPY_TO_FILE

Protected Member Functions

void ResolveTypes () override
 Resolve types for this specific operator.

Constructor & Destructor Documentation

◆ LogicalCopyToFile()

duckdb::LogicalCopyToFile::LogicalCopyToFile ( CopyFunction function,
unique_ptr< FunctionData > bind_data,
unique_ptr< CopyInfo > copy_info )
inline
193885 : LogicalOperator(LogicalOperatorType::LOGICAL_COPY_TO_FILE), function(std::move(function)),
193886 bind_data(std::move(bind_data)), copy_info(std::move(copy_info)) {
193887 }

Member Function Documentation

◆ GetColumnBindings()

vector< ColumnBinding > duckdb::LogicalCopyToFile::GetColumnBindings ( )
overridevirtual

Reimplemented from duckdb::LogicalOperator.

381740 {
381741 idx_t return_column_count = GetCopyFunctionReturnLogicalTypes(return_type).size();
381742 vector<ColumnBinding> result;
381743 for (idx_t i = 0; i < return_column_count; i++) {
381744 result.emplace_back(0, i);
381745 }
381746 return result;
381747}
vector< LogicalType > GetCopyFunctionReturnLogicalTypes(CopyFunctionReturnType return_type)
Definition duckdb.cpp:220611
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ EstimateCardinality()

idx_t duckdb::LogicalCopyToFile::EstimateCardinality ( ClientContext & context)
overridevirtual

Reimplemented from duckdb::LogicalOperator.

381749 {
381750 return 1;
381751}

◆ Serialize()

void duckdb::LogicalCopyToFile::Serialize ( Serializer & serializer) const
overridevirtual

Reimplemented from duckdb::LogicalOperator.

381624 {
381625 LogicalOperator::Serialize(serializer);
381626 serializer.WriteProperty(200, "file_path", file_path);
381627 serializer.WriteProperty(201, "use_tmp_file", use_tmp_file);
381628 serializer.WriteProperty(202, "filename_pattern", filename_pattern);
381629 serializer.WriteProperty(203, "overwrite_or_ignore", overwrite_mode);
381630 serializer.WriteProperty(204, "per_thread_output", per_thread_output);
381631 serializer.WriteProperty(205, "partition_output", partition_output);
381632 serializer.WriteProperty(206, "partition_columns", partition_columns);
381633 serializer.WriteProperty(207, "names", names);
381634 serializer.WriteProperty(208, "expected_types", expected_types);
381635 serializer.WriteProperty(209, "copy_info", copy_info);
381636
381637 // Serialize function
381638 serializer.WriteProperty(210, "function_name", function.name);
381639
381640 bool has_serialize = function.serialize;
381641 serializer.WriteProperty(211, "function_has_serialize", has_serialize);
381642 if (has_serialize) {
381643 D_ASSERT(function.deserialize); // if serialize is set, deserialize should be set as well
381644 serializer.WriteObject(212, "function_data",
381645 [&](Serializer &obj) { function.serialize(obj, *bind_data, function); });
381646 }
381647
381648 serializer.WriteProperty(213, "file_extension", file_extension);
381649 serializer.WriteProperty(214, "rotate", rotate);
381650 serializer.WriteProperty(215, "return_type", return_type);
381651 serializer.WritePropertyWithDefault(216, "write_partition_columns", write_partition_columns, true);
381652 serializer.WritePropertyWithDefault(217, "write_empty_file", write_empty_file, true);
381653 serializer.WritePropertyWithDefault(218, "preserve_order", preserve_order, PreserveOrderType::AUTOMATIC);
381654 serializer.WritePropertyWithDefault(219, "hive_file_pattern", hive_file_pattern, true);
381655 serializer.WritePropertyWithDefault(220, "file_size_bytes", file_size_bytes, optional_idx());
381656}

◆ Deserialize()

unique_ptr< LogicalOperator > duckdb::LogicalCopyToFile::Deserialize ( Deserializer & deserializer)
static
381658 {
381659 auto file_path = deserializer.ReadProperty<string>(200, "file_path");
381660 auto use_tmp_file = deserializer.ReadProperty<bool>(201, "use_tmp_file");
381661 auto filename_pattern = deserializer.ReadProperty<FilenamePattern>(202, "filename_pattern");
381662 auto overwrite_mode = deserializer.ReadProperty<CopyOverwriteMode>(203, "overwrite_mode");
381663 auto per_thread_output = deserializer.ReadProperty<bool>(204, "per_thread_output");
381664 auto partition_output = deserializer.ReadProperty<bool>(205, "partition_output");
381665 auto partition_columns = deserializer.ReadProperty<vector<idx_t>>(206, "partition_columns");
381666 auto names = deserializer.ReadProperty<vector<string>>(207, "names");
381667 auto expected_types = deserializer.ReadProperty<vector<LogicalType>>(208, "expected_types");
381668 auto copy_info =
381669 unique_ptr_cast<ParseInfo, CopyInfo>(deserializer.ReadProperty<unique_ptr<ParseInfo>>(209, "copy_info"));
381670
381671 // Deserialize function
381672 auto &context = deserializer.Get<ClientContext &>();
381673 auto name = deserializer.ReadProperty<string>(210, "function_name");
381674
381675 auto &func_catalog_entry =
381676 Catalog::GetEntry<CopyFunctionCatalogEntry>(context, SYSTEM_CATALOG, DEFAULT_SCHEMA, name);
381677 if (func_catalog_entry.type != CatalogType::COPY_FUNCTION_ENTRY) {
381678 throw InternalException("DeserializeFunction - cant find catalog entry for function %s", name);
381679 }
381680 auto &function_entry = func_catalog_entry.Cast<CopyFunctionCatalogEntry>();
381681 auto function = function_entry.function;
381682 // Deserialize function data
381683 unique_ptr<FunctionData> bind_data;
381684 auto has_serialize = deserializer.ReadProperty<bool>(211, "function_has_serialize");
381685 if (has_serialize) {
381686 // Just deserialize the bind data
381687 deserializer.ReadObject(212, "function_data",
381688 [&](Deserializer &obj) { bind_data = function.deserialize(obj, function); });
381689 }
381690
381691 auto default_extension = function.extension;
381692
381693 auto file_extension =
381694 deserializer.ReadPropertyWithExplicitDefault<string>(213, "file_extension", std::move(default_extension));
381695
381696 auto rotate = deserializer.ReadPropertyWithExplicitDefault(214, "rotate", false);
381697 auto return_type =
381698 deserializer.ReadPropertyWithExplicitDefault(215, "return_type", CopyFunctionReturnType::CHANGED_ROWS);
381699 auto write_partition_columns = deserializer.ReadPropertyWithExplicitDefault(216, "write_partition_columns", true);
381700 auto write_empty_file = deserializer.ReadPropertyWithExplicitDefault(217, "write_empty_file", true);
381701 auto preserve_order =
381702 deserializer.ReadPropertyWithExplicitDefault(218, "preserve_order", PreserveOrderType::AUTOMATIC);
381703 auto hive_file_pattern = deserializer.ReadPropertyWithExplicitDefault(219, "hive_file_pattern", true);
381704 auto file_size_bytes = deserializer.ReadPropertyWithExplicitDefault(220, "file_size_bytes", optional_idx());
381705
381706 if (!has_serialize) {
381707 // If not serialized, re-bind with the copy info
381708 if (!function.copy_to_bind) {
381709 throw InternalException("Copy function \"%s\" has neither bind nor (de)serialize", function.name);
381710 }
381711
381712 CopyFunctionBindInput function_bind_input(*copy_info, function.function_info);
381713 auto names_to_write = GetNamesWithoutPartitions(names, partition_columns, write_partition_columns);
381714 auto types_to_write = GetTypesWithoutPartitions(expected_types, partition_columns, write_partition_columns);
381715 bind_data = function.copy_to_bind(context, function_bind_input, names_to_write, types_to_write);
381716 }
381717
381718 auto result = make_uniq<LogicalCopyToFile>(function, std::move(bind_data), std::move(copy_info));
381719 result->file_path = file_path;
381720 result->use_tmp_file = use_tmp_file;
381721 result->filename_pattern = filename_pattern;
381722 result->file_extension = file_extension;
381723 result->overwrite_mode = overwrite_mode;
381724 result->per_thread_output = per_thread_output;
381725 result->partition_output = partition_output;
381726 result->partition_columns = partition_columns;
381727 result->names = names;
381728 result->expected_types = expected_types;
381729 result->rotate = rotate;
381730 result->return_type = return_type;
381731 result->write_partition_columns = write_partition_columns;
381732 result->write_empty_file = write_empty_file;
381733 result->preserve_order = preserve_order;
381734 result->hive_file_pattern = hive_file_pattern;
381735 result->file_size_bytes = file_size_bytes;
381736
381737 return std::move(result);
381738}
DUCKDB_API optional_ptr< CatalogEntry > GetEntry(ClientContext &context, const string &schema, const EntryLookupInfo &lookup_info, OnEntryNotFound if_not_found)
Gets the "schema.name" entry of the specified type, if entry does not exist behavior depends on OnEnt...
Definition duckdb.cpp:8156

◆ GetTypesWithoutPartitions()

vector< LogicalType > duckdb::LogicalCopyToFile::GetTypesWithoutPartitions ( const vector< LogicalType > & col_types,
const vector< idx_t > & part_cols,
bool write_part_cols )
static
381595 {
381596 if (write_part_cols || part_cols.empty()) {
381597 return col_types;
381598 }
381599 vector<LogicalType> types;
381600 set<idx_t> part_col_set(part_cols.begin(), part_cols.end());
381601 for (idx_t col_idx = 0; col_idx < col_types.size(); col_idx++) {
381602 if (part_col_set.find(col_idx) == part_col_set.end()) {
381603 types.push_back(col_types[col_idx]);
381604 }
381605 }
381606 return types;
381607}
vector< LogicalType > types
The types returned by this logical operator. Set by calling LogicalOperator::ResolveTypes.
Definition duckdb.hpp:21266

◆ GetNamesWithoutPartitions()

vector< string > duckdb::LogicalCopyToFile::GetNamesWithoutPartitions ( const vector< string > & col_names,
const vector< column_t > & part_cols,
bool write_part_cols )
static
381610 {
381611 if (write_part_cols || part_cols.empty()) {
381612 return col_names;
381613 }
381614 vector<string> names;
381615 set<idx_t> part_col_set(part_cols.begin(), part_cols.end());
381616 for (idx_t col_idx = 0; col_idx < col_names.size(); col_idx++) {
381617 if (part_col_set.find(col_idx) == part_col_set.end()) {
381618 names.push_back(col_names[col_idx]);
381619 }
381620 }
381621 return names;
381622}

◆ ResolveTypes()

void duckdb::LogicalCopyToFile::ResolveTypes ( )
inlineoverrideprotectedvirtual

Resolve types for this specific operator.

Implements duckdb::LogicalOperator.

193922 {
193924 }
Here is the call graph for this function:

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