OmniSciDB  a5dc49c757
 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 31 of file CsvFileBufferParser.cpp.

References kARRAY, and kPOINT.

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

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

+ 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 27 of file CsvFileBufferParser.cpp.

References foreign_storage::ParseBufferRequest::import_buffers.

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

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

+ 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 100 of file CsvFileBufferParser.cpp.

References foreign_storage::OptionsContainer::options.

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

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

+ 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 64 of file CsvFileBufferParser.cpp.

References foreign_storage::OptionsContainer::options.

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

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

+ 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 84 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().

86  {
87  if (auto it = foreign_table->options.find(option_name);
88  it != foreign_table->options.end()) {
89  if (it->second.length() != expected_num_chars) {
90  throw std::runtime_error{"Value of \"" + option_name +
91  "\" foreign table option has the wrong number of "
92  "characters. Expected " +
93  std::to_string(expected_num_chars) + " character(s)."};
94  }
95  return it->second;
96  }
97  return "";
98 }
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 54 of file CsvFileBufferParser.cpp.

References foreign_storage::throw_number_of_columns_mismatch_error().

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

57  {
58  // Each POINT could consume two separate coords instead of a single WKT
59  if (row.size() < num_cols || (num_cols + point_cols) < row.size()) {
60  throw_number_of_columns_mismatch_error(num_cols, row.size(), file_name);
61  }
62 }
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: