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::DialectCandidates Struct Reference

All the options that will be used to sniff the dialect of the CSV file. More...

Collaboration diagram for duckdb::DialectCandidates:

Public Member Functions

 DialectCandidates (const CSVStateMachineOptions &options)
 The constructor populates all of our the options that will be used in our sniffer search space.
string Print ()

Static Public Member Functions

static vector< string > GetDefaultDelimiter ()
 Static functions to get defaults of the search space.
static vector< QuoteEscapeCombination > GetDefaultQuoteEscapeCombination ()
 Default Quote/Escape combinations in priority order.
static vector< char > GetDefaultComment ()

Public Attributes

vector< string > delim_candidates
 Candidates for the delimiter.
vector< char > comment_candidates
 Candidates for the comment.
vector< QuoteEscapeCombination > quote_escape_candidates
 Candidates for combinations of quotes and escapes.

Detailed Description

All the options that will be used to sniff the dialect of the CSV file.

Constructor & Destructor Documentation

◆ DialectCandidates()

duckdb::DialectCandidates::DialectCandidates ( const CSVStateMachineOptions & options)
explicit

The constructor populates all of our the options that will be used in our sniffer search space.

171631 {
171632 // assert that quotes escapes and rules have equal size
171633 const auto default_delimiter = GetDefaultDelimiter();
171634 const auto default_comment = GetDefaultComment();
171635 const auto default_quote_escape = GetDefaultQuoteEscapeCombination();
171636
171637 if (options.delimiter.IsSetByUser()) {
171638 // user provided a delimiter: use that delimiter
171639 delim_candidates = {options.delimiter.GetValue()};
171640 } else {
171641 // no delimiter provided: try standard/common delimiters
171642 delim_candidates = default_delimiter;
171643 }
171644
171645 if (options.comment.IsSetByUser()) {
171646 // user provided comment character: use that as a comment
171647 comment_candidates = {options.comment.GetValue()};
171648 } else {
171649 // no comment provided: try standard/common comments
171650 comment_candidates = default_comment;
171651 }
171652
171653 if (options.quote.IsSetByUser() && options.escape.IsSetByUser()) {
171654 // User set quote and escape, that's our only candidate then
171655 quote_escape_candidates.push_back({options.quote.GetValue(), options.escape.GetValue()});
171656 } else if (options.quote.IsSetByUser()) {
171657 // Only quote is set, look for escape matches.
171658 for (auto &candidate : default_quote_escape) {
171659 if (candidate.quote == options.quote.GetValue()) {
171660 quote_escape_candidates.push_back(candidate);
171661 }
171662 }
171663 if (quote_escape_candidates.empty()) {
171664 // This is an uncommon quote
171665 quote_escape_candidates.push_back({options.quote.GetValue(), options.quote.GetValue()});
171666 quote_escape_candidates.push_back({options.quote.GetValue(), '\0'});
171667 quote_escape_candidates.push_back({options.quote.GetValue(), '\\'});
171668 quote_escape_candidates.push_back({options.quote.GetValue(), '\"'});
171669 quote_escape_candidates.push_back({options.quote.GetValue(), '\''});
171670 }
171671 } else if (options.escape.IsSetByUser()) {
171672 // Only Escape is set, look for quote matches
171673 for (auto &candidate : default_quote_escape) {
171674 if (candidate.escape == options.escape.GetValue()) {
171675 quote_escape_candidates.push_back(candidate);
171676 }
171677 }
171678 if (quote_escape_candidates.empty()) {
171679 // This is an uncommon escape
171680 quote_escape_candidates.push_back({options.escape.GetValue(), options.escape.GetValue()});
171681 quote_escape_candidates.push_back({'\"', options.escape.GetValue()});
171682 quote_escape_candidates.push_back({'\'', options.escape.GetValue()});
171683 }
171684 } else {
171685 // Nothing is set
171686 quote_escape_candidates = default_quote_escape;
171687 }
171688}
vector< string > delim_candidates
Candidates for the delimiter.
Definition duckdb.cpp:168110
static vector< QuoteEscapeCombination > GetDefaultQuoteEscapeCombination()
Default Quote/Escape combinations in priority order.
Definition duckdb.cpp:171576
vector< QuoteEscapeCombination > quote_escape_candidates
Candidates for combinations of quotes and escapes.
Definition duckdb.cpp:168114
static vector< string > GetDefaultDelimiter()
Static functions to get defaults of the search space.
Definition duckdb.cpp:171572
vector< char > comment_candidates
Candidates for the comment.
Definition duckdb.cpp:168112
Here is the call graph for this function:

Member Function Documentation

◆ GetDefaultDelimiter()

vector< string > duckdb::DialectCandidates::GetDefaultDelimiter ( )
static

Static functions to get defaults of the search space.

171572 {
171573 return {",", "|", ";", "\t"};
171574}
Here is the caller graph for this function:

◆ GetDefaultQuoteEscapeCombination()

vector< QuoteEscapeCombination > duckdb::DialectCandidates::GetDefaultQuoteEscapeCombination ( )
static

Default Quote/Escape combinations in priority order.

171576 {
171577 return {{'\0', '\0'}, {'\"', '\0'}, {'\"', '\"'}, {'\"', '\''}, {'\"', '\\'},
171578 {'\'', '\0'}, {'\'', '\''}, {'\'', '\"'}, {'\'', '\\'}};
171579}
Here is the caller graph for this function:

◆ GetDefaultComment()

vector< char > duckdb::DialectCandidates::GetDefaultComment ( )
static
171581 {
171582 return {'\0', '#'};
171583}

◆ Print()

string duckdb::DialectCandidates::Print ( )
171585 {
171586 std::ostringstream search_space;
171587
171588 search_space << "Delimiter Candidates: ";
171589 for (idx_t i = 0; i < delim_candidates.size(); i++) {
171590 search_space << "\'" << delim_candidates[i] << "\'";
171591 if (i < delim_candidates.size() - 1) {
171592 search_space << ", ";
171593 }
171594 }
171595 search_space << "\n";
171596 search_space << "Quote/Escape Candidates: ";
171597 for (idx_t i = 0; i < quote_escape_candidates.size(); i++) {
171598 const auto quote_candidate = quote_escape_candidates[i].quote;
171599 const auto escape_candidate = quote_escape_candidates[i].escape;
171600 search_space << "[\'";
171601 if (quote_candidate == '\0') {
171602 search_space << "(no quote)";
171603 } else {
171604 search_space << quote_candidate;
171605 }
171606 search_space << "\',\'";
171607 if (escape_candidate == '\0') {
171608 search_space << "(no escape)";
171609 } else {
171610 search_space << escape_candidate;
171611 }
171612 search_space << "\']";
171613 if (i < quote_escape_candidates.size() - 1) {
171614 search_space << ",";
171615 }
171616 }
171617 search_space << "\n";
171618
171619 search_space << "Comment Candidates: ";
171620 for (idx_t i = 0; i < comment_candidates.size(); i++) {
171621 search_space << "\'" << comment_candidates[i] << "\'";
171622 if (i < comment_candidates.size() - 1) {
171623 search_space << ", ";
171624 }
171625 }
171626 search_space << "\n";
171627
171628 return search_space.str();
171629}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

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