OmniSciDB  471d68cefb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
foreign_storage::anonymous_namespace{CsvFileBufferParser.cpp} Namespace Reference

Functions

bool skip_column_import (ParseBufferRequest &request, int column_idx)
 
void set_array_flags_and_geo_columns_count (std::unique_ptr< bool[]> &array_flags, int &phys_cols, int &point_cols, const std::list< const ColumnDescriptor * > &columns)
 
void validate_expected_column_count (std::vector< std::string_view > &row, size_t num_cols, int point_cols, const std::string &file_name)
 
std::string validate_and_get_delimiter (const ForeignTable *foreign_table, const std::string &option_name)
 
std::string validate_and_get_string_with_length (const ForeignTable *foreign_table, const std::string &option_name, const size_t expected_num_chars)
 
std::optional< bool > validate_and_get_bool_value (const ForeignTable *foreign_table, const std::string &option_name)
 

Function Documentation

void foreign_storage::anonymous_namespace{CsvFileBufferParser.cpp}::set_array_flags_and_geo_columns_count ( std::unique_ptr< bool[]> &  array_flags,
int &  phys_cols,
int &  point_cols,
const std::list< const ColumnDescriptor * > &  columns 
)

Definition at line 30 of file CsvFileBufferParser.cpp.

References i, kARRAY, and kPOINT.

Referenced by foreign_storage::CsvFileBufferParser::parseBuffer().

34  {
35  array_flags = std::unique_ptr<bool[]>(new bool[columns.size()]);
36  size_t i = 0;
37  for (const auto cd : columns) {
38  const auto& col_ti = cd->columnType;
39  phys_cols += col_ti.get_physical_cols();
40  if (cd->columnType.get_type() == kPOINT) {
41  point_cols++;
42  }
43 
44  if (cd->columnType.get_type() == kARRAY) {
45  array_flags.get()[i] = true;
46  } else {
47  array_flags.get()[i] = false;
48  }
49  i++;
50  }
51 }

+ Here is the caller graph for this function:

bool foreign_storage::anonymous_namespace{CsvFileBufferParser.cpp}::skip_column_import ( ParseBufferRequest &  request,
int  column_idx 
)
inline

Definition at line 26 of file CsvFileBufferParser.cpp.

References foreign_storage::ParseBufferRequest::import_buffers.

Referenced by foreign_storage::CsvFileBufferParser::parseBuffer().

26  {
27  return request.import_buffers[column_idx] == nullptr;
28 }

+ Here is the caller graph for this function:

std::optional<bool> foreign_storage::anonymous_namespace{CsvFileBufferParser.cpp}::validate_and_get_bool_value ( const ForeignTable *  foreign_table,
const std::string &  option_name 
)

Definition at line 99 of file CsvFileBufferParser.cpp.

References foreign_storage::OptionsContainer::options.

Referenced by foreign_storage::Csv::validate_and_get_copy_params(), and foreign_storage::CsvFileBufferParser::validateAndGetCopyParams().

100  {
101  if (auto it = foreign_table->options.find(option_name);
102  it != foreign_table->options.end()) {
103  if (boost::iequals(it->second, "TRUE")) {
104  return true;
105  } else if (boost::iequals(it->second, "FALSE")) {
106  return false;
107  } else {
108  throw std::runtime_error{"Invalid boolean value specified for \"" + option_name +
109  "\" foreign table option. "
110  "Value must be either 'true' or 'false'."};
111  }
112  }
113  return std::nullopt;
114 }

+ Here is the caller graph for this function:

std::string foreign_storage::anonymous_namespace{CsvFileBufferParser.cpp}::validate_and_get_delimiter ( const ForeignTable *  foreign_table,
const std::string &  option_name 
)

Definition at line 63 of file CsvFileBufferParser.cpp.

References foreign_storage::OptionsContainer::options.

Referenced by foreign_storage::Csv::validate_and_get_copy_params(), and foreign_storage::CsvFileBufferParser::validateAndGetCopyParams().

64  {
65  if (auto it = foreign_table->options.find(option_name);
66  it != foreign_table->options.end()) {
67  if (it->second.length() == 1) {
68  return it->second;
69  } else {
70  if (it->second == std::string("\\n")) {
71  return "\n";
72  } else if (it->second == std::string("\\t")) {
73  return "\t";
74  } else {
75  throw std::runtime_error{"Invalid value specified for option \"" + option_name +
76  "\". Expected a single character, \"\\n\" or \"\\t\"."};
77  }
78  }
79  }
80  return "";
81 }

+ Here is the caller graph for this function:

std::string foreign_storage::anonymous_namespace{CsvFileBufferParser.cpp}::validate_and_get_string_with_length ( const ForeignTable *  foreign_table,
const std::string &  option_name,
const size_t  expected_num_chars 
)

Definition at line 83 of file CsvFileBufferParser.cpp.

References foreign_storage::OptionsContainer::options, and to_string().

Referenced by foreign_storage::Csv::validate_and_get_copy_params(), and foreign_storage::CsvFileBufferParser::validateAndGetCopyParams().

85  {
86  if (auto it = foreign_table->options.find(option_name);
87  it != foreign_table->options.end()) {
88  if (it->second.length() != expected_num_chars) {
89  throw std::runtime_error{"Value of \"" + option_name +
90  "\" foreign table option has the wrong number of "
91  "characters. Expected " +
92  std::to_string(expected_num_chars) + " character(s)."};
93  }
94  return it->second;
95  }
96  return "";
97 }
std::string to_string(char const *&&v)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void foreign_storage::anonymous_namespace{CsvFileBufferParser.cpp}::validate_expected_column_count ( std::vector< std::string_view > &  row,
size_t  num_cols,
int  point_cols,
const std::string &  file_name 
)

Definition at line 53 of file CsvFileBufferParser.cpp.

References foreign_storage::throw_number_of_columns_mismatch_error().

Referenced by foreign_storage::CsvFileBufferParser::parseBuffer(), and foreign_storage::CsvFileBufferParser::validateExpectedColumnCount().

56  {
57  // Each POINT could consume two separate coords instead of a single WKT
58  if (row.size() < num_cols || (num_cols + point_cols) < row.size()) {
59  throw_number_of_columns_mismatch_error(num_cols, row.size(), file_name);
60  }
61 }
void throw_number_of_columns_mismatch_error(size_t num_table_cols, size_t num_file_cols, const std::string &file_path)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: