OmniSciDB  c07336695a
Importer_NS::ImporterUtils Class Reference

#include <Importer.h>

Static Public Member Functions

static bool parseStringArray (const std::string &s, const CopyParams &copy_params, std::vector< std::string > &string_vec)
 
static ArrayDatum composeNullArray (const SQLTypeInfo &ti)
 

Detailed Description

Definition at line 812 of file Importer.h.

Member Function Documentation

◆ composeNullArray()

ArrayDatum Importer_NS::ImporterUtils::composeNullArray ( const SQLTypeInfo ti)
static

Definition at line 522 of file Importer.cpp.

References Importer_NS::NullArray().

Referenced by MapDHandler::insert_data().

522  {
523  return NullArray(ti);
524 }
ArrayDatum NullArray(const SQLTypeInfo &ti)
Definition: Importer.cpp:494
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseStringArray()

static bool Importer_NS::ImporterUtils::parseStringArray ( const std::string &  s,
const CopyParams copy_params,
std::vector< std::string > &  string_vec 
)
inlinestatic

Definition at line 814 of file Importer.h.

References Importer_NS::CopyParams::array_begin, Importer_NS::CopyParams::array_delim, Importer_NS::CopyParams::array_end, StringDictionary::MAX_STRLEN, Importer_NS::CopyParams::null_str, and to_string().

Referenced by Importer_NS::TypedImportBuffer::add_value(), and RowToColumnLoader::convert_string_to_column().

816  {
817  if (s == copy_params.null_str || s == "NULL" || s.size() < 1 || s.empty()) {
818  // TODO: should not convert NULL, empty arrays to {"NULL"},
819  // need to support NULL, empty properly
820  string_vec.emplace_back("NULL");
821  return true;
822  }
823  if (s[0] != copy_params.array_begin || s[s.size() - 1] != copy_params.array_end) {
824  throw std::runtime_error("Malformed Array :" + s);
825  }
826  size_t last = 1;
827  for (size_t i = s.find(copy_params.array_delim, 1); i != std::string::npos;
828  i = s.find(copy_params.array_delim, last)) {
829  if (i > last) { // if not empty string - disallow empty strings for now
830  if (s.substr(last, i - last).length() > StringDictionary::MAX_STRLEN) {
831  throw std::runtime_error("Array String too long : " +
832  std::to_string(s.substr(last, i - last).length()) +
833  " max is " +
835  }
836 
837  string_vec.push_back(s.substr(last, i - last));
838  }
839  last = i + 1;
840  }
841  if (s.size() - 1 > last) { // if not empty string - disallow empty strings for now
842  if (s.substr(last, s.size() - 1 - last).length() > StringDictionary::MAX_STRLEN) {
843  throw std::runtime_error(
844  "Array String too long : " +
845  std::to_string(s.substr(last, s.size() - 1 - last).length()) + " max is " +
847  }
848 
849  string_vec.push_back(s.substr(last, s.size() - 1 - last));
850  }
851  return false;
852  }
std::string null_str
std::string to_string(char const *&&v)
static constexpr size_t MAX_STRLEN
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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