OmniSciDB  471d68cefb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
import_export::Detector Class Reference

#include <Importer.h>

+ Inheritance diagram for import_export::Detector:
+ Collaboration diagram for import_export::Detector:

Public Member Functions

 Detector (const boost::filesystem::path &fp, CopyParams &cp)
 
std::vector< std::string > get_headers ()
 
std::vector< std::vector
< std::string > > 
get_sample_rows (size_t n)
 
- Public Member Functions inherited from import_export::DataStreamSink
 DataStreamSink ()
 
 DataStreamSink (const CopyParams &copy_params, const std::string file_path)
 
virtual ~DataStreamSink ()
 
const CopyParamsget_copy_params () const
 
void import_compressed (std::vector< std::string > &file_paths, const Catalog_Namespace::SessionInfo *session_info)
 

Static Public Member Functions

static SQLTypes detect_sqltype (const std::string &str)
 

Public Attributes

std::vector< std::vector
< std::string > > 
raw_rows
 
std::vector< SQLTypesbest_sqltypes
 
std::vector< EncodingTypebest_encodings
 
bool has_headers = false
 

Private Member Functions

void init ()
 
void read_file ()
 
void detect_row_delimiter ()
 
void split_raw_data ()
 
std::vector< SQLTypesdetect_column_types (const std::vector< std::string > &row)
 
void find_best_sqltypes ()
 
std::vector< SQLTypesfind_best_sqltypes (const std::vector< std::vector< std::string >> &raw_rows, const CopyParams &copy_params)
 
std::vector< SQLTypesfind_best_sqltypes (const std::vector< std::vector< std::string >>::const_iterator &row_begin, const std::vector< std::vector< std::string >>::const_iterator &row_end, const CopyParams &copy_params)
 
std::vector< EncodingTypefind_best_encodings (const std::vector< std::vector< std::string >>::const_iterator &row_begin, const std::vector< std::vector< std::string >>::const_iterator &row_end, const std::vector< SQLTypes > &best_types)
 
bool detect_headers (const std::vector< SQLTypes > &first_types, const std::vector< SQLTypes > &rest_types)
 
void find_best_sqltypes_and_headers ()
 
ImportStatus importDelimited (const std::string &file_path, const bool decompressed, const Catalog_Namespace::SessionInfo *session_info) override
 

Static Private Member Functions

static bool more_restrictive_sqltype (const SQLTypes a, const SQLTypes b)
 

Private Attributes

std::string raw_data
 
boost::filesystem::path file_path
 
std::chrono::duration< double > timeout {1}
 
std::string line1
 

Additional Inherited Members

- Protected Member Functions inherited from import_export::DataStreamSink
ImportStatus archivePlumber (const Catalog_Namespace::SessionInfo *session_info)
 
- Protected Attributes inherited from import_export::DataStreamSink
CopyParams copy_params
 
const std::string file_path
 
FILE * p_file = nullptr
 
ImportStatus import_status_
 
mapd_shared_mutex import_mutex_
 
size_t total_file_size {0}
 
std::vector< size_t > file_offsets
 
std::mutex file_offsets_mutex
 

Detailed Description

Definition at line 712 of file Importer.h.

Constructor & Destructor Documentation

import_export::Detector::Detector ( const boost::filesystem::path &  fp,
CopyParams cp 
)
inline

Definition at line 714 of file Importer.h.

References init(), and read_file().

715  : DataStreamSink(cp, fp.string()), file_path(fp) {
716  read_file();
717  init();
718  };
boost::filesystem::path file_path
Definition: Importer.h:760

+ Here is the call graph for this function:

Member Function Documentation

std::vector< SQLTypes > import_export::Detector::detect_column_types ( const std::vector< std::string > &  row)
private

Definition at line 3393 of file Importer.cpp.

References detect_sqltype(), and i.

Referenced by find_best_sqltypes_and_headers().

3393  {
3394  std::vector<SQLTypes> types(row.size());
3395  for (size_t i = 0; i < row.size(); i++) {
3396  types[i] = detect_sqltype(row[i]);
3397  }
3398  return types;
3399 }
static SQLTypes detect_sqltype(const std::string &str)
Definition: Importer.cpp:3311

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool import_export::Detector::detect_headers ( const std::vector< SQLTypes > &  first_types,
const std::vector< SQLTypes > &  rest_types 
)
private

Definition at line 3535 of file Importer.cpp.

References has_headers, and kTEXT.

Referenced by find_best_sqltypes_and_headers().

3536  {
3537  if (head_types.size() != tail_types.size()) {
3538  return false;
3539  }
3540  bool has_headers = false;
3541  for (size_t col_idx = 0; col_idx < tail_types.size(); col_idx++) {
3542  if (head_types[col_idx] != kTEXT) {
3543  return false;
3544  }
3545  has_headers = has_headers || tail_types[col_idx] != kTEXT;
3546  }
3547  return has_headers;
3548 }
Definition: sqltypes.h:52

+ Here is the caller graph for this function:

void import_export::Detector::detect_row_delimiter ( )
private

Definition at line 3251 of file Importer.cpp.

References import_export::DataStreamSink::copy_params, import_export::CopyParams::delimiter, and file_path.

Referenced by init().

3251  {
3252  if (copy_params.delimiter == '\0') {
3253  copy_params.delimiter = ',';
3254  if (boost::filesystem::extension(file_path) == ".tsv") {
3255  copy_params.delimiter = '\t';
3256  }
3257  }
3258 }
boost::filesystem::path file_path
Definition: Importer.h:760

+ Here is the caller graph for this function:

SQLTypes import_export::Detector::detect_sqltype ( const std::string &  str)
static

Definition at line 3311 of file Importer.cpp.

References dateTimeParseOptional< kDATE >(), dateTimeParseOptional< kTIME >(), dateTimeParseOptional< kTIMESTAMP >(), kBIGINT, kDATE, kDOUBLE, kFLOAT, kINT, kLINESTRING, kMULTIPOLYGON, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, import_export::PROMOTE_POLYGON_TO_MULTIPOLYGON, and run_benchmark_import::type.

Referenced by detect_column_types(), and find_best_sqltypes().

3311  {
3312  SQLTypes type = kTEXT;
3313  if (try_cast<double>(str)) {
3314  type = kDOUBLE;
3315  /*if (try_cast<bool>(str)) {
3316  type = kBOOLEAN;
3317  }*/
3318  if (try_cast<int16_t>(str)) {
3319  type = kSMALLINT;
3320  } else if (try_cast<int32_t>(str)) {
3321  type = kINT;
3322  } else if (try_cast<int64_t>(str)) {
3323  type = kBIGINT;
3324  } else if (try_cast<float>(str)) {
3325  type = kFLOAT;
3326  }
3327  }
3328 
3329  // check for geo types
3330  if (type == kTEXT) {
3331  // convert to upper case
3332  std::string str_upper_case = str;
3333  std::transform(
3334  str_upper_case.begin(), str_upper_case.end(), str_upper_case.begin(), ::toupper);
3335 
3336  // then test for leading words
3337  if (str_upper_case.find("POINT") == 0) {
3338  type = kPOINT;
3339  } else if (str_upper_case.find("LINESTRING") == 0) {
3340  type = kLINESTRING;
3341  } else if (str_upper_case.find("POLYGON") == 0) {
3343  type = kMULTIPOLYGON;
3344  } else {
3345  type = kPOLYGON;
3346  }
3347  } else if (str_upper_case.find("MULTIPOLYGON") == 0) {
3348  type = kMULTIPOLYGON;
3349  } else if (str_upper_case.find_first_not_of("0123456789ABCDEF") ==
3350  std::string::npos &&
3351  (str_upper_case.size() % 2) == 0) {
3352  // simple hex blob (two characters per byte, not uu-encode or base64)
3353  if (str_upper_case.size() >= 10) {
3354  // match WKB blobs for supported geometry types
3355  // the first byte specifies if the data is big-endian or little-endian
3356  // the next four bytes are the geometry type (1 = POINT etc.)
3357  // @TODO support eWKB, which has extra bits set in the geometry type
3358  auto first_five_bytes = str_upper_case.substr(0, 10);
3359  if (first_five_bytes == "0000000001" || first_five_bytes == "0101000000") {
3360  type = kPOINT;
3361  } else if (first_five_bytes == "0000000002" || first_five_bytes == "0102000000") {
3362  type = kLINESTRING;
3363  } else if (first_five_bytes == "0000000003" || first_five_bytes == "0103000000") {
3364  type = kPOLYGON;
3365  } else if (first_five_bytes == "0000000006" || first_five_bytes == "0106000000") {
3366  type = kMULTIPOLYGON;
3367  } else {
3368  // unsupported WKB type
3369  return type;
3370  }
3371  } else {
3372  // too short to be WKB
3373  return type;
3374  }
3375  }
3376  }
3377 
3378  // check for time types
3379  if (type == kTEXT) {
3380  // This won't match unix timestamp, since floats and ints were checked above.
3381  if (dateTimeParseOptional<kTIME>(str, 0)) {
3382  type = kTIME;
3383  } else if (dateTimeParseOptional<kTIMESTAMP>(str, 0)) {
3384  type = kTIMESTAMP;
3385  } else if (dateTimeParseOptional<kDATE>(str, 0)) {
3386  type = kDATE;
3387  }
3388  }
3389 
3390  return type;
3391 }
Definition: sqltypes.h:49
SQLTypes
Definition: sqltypes.h:38
std::optional< int64_t > dateTimeParseOptional< kTIME >(std::string_view str, unsigned const dim)
std::optional< int64_t > dateTimeParseOptional< kDATE >(std::string_view str, unsigned const dim)
static constexpr bool PROMOTE_POLYGON_TO_MULTIPOLYGON
Definition: Importer.cpp:165
std::optional< int64_t > dateTimeParseOptional< kTIMESTAMP >(std::string_view str, unsigned const dim)
Definition: sqltypes.h:52
Definition: sqltypes.h:53
Definition: sqltypes.h:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< EncodingType > import_export::Detector::find_best_encodings ( const std::vector< std::vector< std::string >>::const_iterator &  row_begin,
const std::vector< std::vector< std::string >>::const_iterator &  row_end,
const std::vector< SQLTypes > &  best_types 
)
private

Definition at line 3499 of file Importer.cpp.

References file_path, IS_STRING, kENCODING_DICT, kENCODING_NONE, and raw_rows.

Referenced by find_best_sqltypes_and_headers().

3502  {
3503  if (raw_rows.size() < 1) {
3504  throw std::runtime_error("No rows found in: " +
3505  boost::filesystem::basename(file_path));
3506  }
3507  size_t num_cols = best_types.size();
3508  std::vector<EncodingType> best_encodes(num_cols, kENCODING_NONE);
3509  std::vector<size_t> num_rows_per_col(num_cols, 1);
3510  std::vector<std::unordered_set<std::string>> count_set(num_cols);
3511  for (auto row = row_begin; row != row_end; row++) {
3512  for (size_t col_idx = 0; col_idx < row->size() && col_idx < num_cols; col_idx++) {
3513  if (IS_STRING(best_types[col_idx])) {
3514  count_set[col_idx].insert(row->at(col_idx));
3515  num_rows_per_col[col_idx]++;
3516  }
3517  }
3518  }
3519  for (size_t col_idx = 0; col_idx < num_cols; col_idx++) {
3520  if (IS_STRING(best_types[col_idx])) {
3521  float uniqueRatio =
3522  static_cast<float>(count_set[col_idx].size()) / num_rows_per_col[col_idx];
3523  if (uniqueRatio < 0.75) {
3524  best_encodes[col_idx] = kENCODING_DICT;
3525  }
3526  }
3527  }
3528  return best_encodes;
3529 }
std::vector< std::vector< std::string > > raw_rows
Definition: Importer.h:725
boost::filesystem::path file_path
Definition: Importer.h:760
#define IS_STRING(T)
Definition: sqltypes.h:250

+ Here is the caller graph for this function:

void import_export::Detector::find_best_sqltypes ( )
private

Definition at line 3446 of file Importer.cpp.

References best_sqltypes, import_export::DataStreamSink::copy_params, and raw_rows.

Referenced by find_best_sqltypes(), and find_best_sqltypes_and_headers().

3446  {
3448 }
std::vector< SQLTypes > best_sqltypes
Definition: Importer.h:727
std::vector< std::vector< std::string > > raw_rows
Definition: Importer.h:725

+ Here is the caller graph for this function:

std::vector< SQLTypes > import_export::Detector::find_best_sqltypes ( const std::vector< std::vector< std::string >> &  raw_rows,
const CopyParams copy_params 
)
private

Definition at line 3450 of file Importer.cpp.

References import_export::DataStreamSink::copy_params, find_best_sqltypes(), and raw_rows.

3452  {
3453  return find_best_sqltypes(raw_rows.begin(), raw_rows.end(), copy_params);
3454 }
std::vector< std::vector< std::string > > raw_rows
Definition: Importer.h:725

+ Here is the call graph for this function:

std::vector< SQLTypes > import_export::Detector::find_best_sqltypes ( const std::vector< std::vector< std::string >>::const_iterator &  row_begin,
const std::vector< std::vector< std::string >>::const_iterator &  row_end,
const CopyParams copy_params 
)
private

Definition at line 3456 of file Importer.cpp.

References detect_sqltype(), run_benchmark_import::end_time, file_path, kCHAR, kTEXT, more_restrictive_sqltype(), import_export::CopyParams::null_str, raw_rows, t, and timeout.

3459  {
3460  if (raw_rows.size() < 1) {
3461  throw std::runtime_error("No rows found in: " +
3462  boost::filesystem::basename(file_path));
3463  }
3464  auto end_time = std::chrono::steady_clock::now() + timeout;
3465  size_t num_cols = raw_rows.front().size();
3466  std::vector<SQLTypes> best_types(num_cols, kCHAR);
3467  std::vector<size_t> non_null_col_counts(num_cols, 0);
3468  for (auto row = row_begin; row != row_end; row++) {
3469  while (best_types.size() < row->size() || non_null_col_counts.size() < row->size()) {
3470  best_types.push_back(kCHAR);
3471  non_null_col_counts.push_back(0);
3472  }
3473  for (size_t col_idx = 0; col_idx < row->size(); col_idx++) {
3474  // do not count nulls
3475  if (row->at(col_idx) == "" || !row->at(col_idx).compare(copy_params.null_str)) {
3476  continue;
3477  }
3478  SQLTypes t = detect_sqltype(row->at(col_idx));
3479  non_null_col_counts[col_idx]++;
3480  if (!more_restrictive_sqltype(best_types[col_idx], t)) {
3481  best_types[col_idx] = t;
3482  }
3483  }
3484  if (std::chrono::steady_clock::now() > end_time) {
3485  break;
3486  }
3487  }
3488  for (size_t col_idx = 0; col_idx < num_cols; col_idx++) {
3489  // if we don't have any non-null values for this column make it text to be
3490  // safe b/c that is least restrictive type
3491  if (non_null_col_counts[col_idx] == 0) {
3492  best_types[col_idx] = kTEXT;
3493  }
3494  }
3495 
3496  return best_types;
3497 }
SQLTypes
Definition: sqltypes.h:38
static SQLTypes detect_sqltype(const std::string &str)
Definition: Importer.cpp:3311
std::vector< std::vector< std::string > > raw_rows
Definition: Importer.h:725
boost::filesystem::path file_path
Definition: Importer.h:760
Definition: sqltypes.h:52
static bool more_restrictive_sqltype(const SQLTypes a, const SQLTypes b)
Definition: Importer.cpp:3401
std::chrono::duration< double > timeout
Definition: Importer.h:761
Definition: sqltypes.h:41
char * t

+ Here is the call graph for this function:

void import_export::Detector::find_best_sqltypes_and_headers ( )
private

Definition at line 3423 of file Importer.cpp.

References import_export::AUTODETECT, best_encodings, best_sqltypes, import_export::DataStreamSink::copy_params, detect_column_types(), detect_headers(), find_best_encodings(), find_best_sqltypes(), import_export::HAS_HEADER, import_export::CopyParams::has_header, has_headers, import_export::NO_HEADER, and raw_rows.

Referenced by init().

3423  {
3425  best_encodings =
3426  find_best_encodings(raw_rows.begin() + 1, raw_rows.end(), best_sqltypes);
3427  std::vector<SQLTypes> head_types = detect_column_types(raw_rows.at(0));
3428  switch (copy_params.has_header) {
3430  has_headers = detect_headers(head_types, best_sqltypes);
3431  if (has_headers) {
3433  } else {
3435  }
3436  break;
3438  has_headers = false;
3439  break;
3441  has_headers = true;
3442  break;
3443  }
3444 }
std::vector< SQLTypes > best_sqltypes
Definition: Importer.h:727
ImportHeaderRow has_header
Definition: CopyParams.h:51
std::vector< EncodingType > find_best_encodings(const std::vector< std::vector< std::string >>::const_iterator &row_begin, const std::vector< std::vector< std::string >>::const_iterator &row_end, const std::vector< SQLTypes > &best_types)
Definition: Importer.cpp:3499
std::vector< std::vector< std::string > > raw_rows
Definition: Importer.h:725
std::vector< EncodingType > best_encodings
Definition: Importer.h:728
bool detect_headers(const std::vector< SQLTypes > &first_types, const std::vector< SQLTypes > &rest_types)
Definition: Importer.cpp:3535
std::vector< SQLTypes > detect_column_types(const std::vector< std::string > &row)
Definition: Importer.cpp:3393

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< std::string > import_export::Detector::get_headers ( )

Definition at line 3558 of file Importer.cpp.

References best_sqltypes, has_headers, i, raw_rows, and to_string().

Referenced by DBHandler::detect_column_types().

3558  {
3559  std::vector<std::string> headers(best_sqltypes.size());
3560  for (size_t i = 0; i < best_sqltypes.size(); i++) {
3561  if (has_headers && i < raw_rows[0].size()) {
3562  headers[i] = raw_rows[0][i];
3563  } else {
3564  headers[i] = "column_" + std::to_string(i + 1);
3565  }
3566  }
3567  return headers;
3568 }
std::vector< SQLTypes > best_sqltypes
Definition: Importer.h:727
std::string to_string(char const *&&v)
std::vector< std::vector< std::string > > raw_rows
Definition: Importer.h:725

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< std::vector< std::string > > import_export::Detector::get_sample_rows ( size_t  n)

Definition at line 3550 of file Importer.cpp.

References has_headers, anonymous_namespace{Utm.h}::n, and raw_rows.

Referenced by DBHandler::detect_column_types().

3550  {
3551  n = std::min(n, raw_rows.size());
3552  size_t offset = (has_headers && raw_rows.size() > 1) ? 1 : 0;
3553  std::vector<std::vector<std::string>> sample_rows(raw_rows.begin() + offset,
3554  raw_rows.begin() + n);
3555  return sample_rows;
3556 }
std::vector< std::vector< std::string > > raw_rows
Definition: Importer.h:725
constexpr double n
Definition: Utm.h:46

+ Here is the caller graph for this function:

ImportStatus import_export::Detector::importDelimited ( const std::string &  file_path,
const bool  decompressed,
const Catalog_Namespace::SessionInfo session_info 
)
overrideprivatevirtual

Implements import_export::DataStreamSink.

Definition at line 3182 of file Importer.cpp.

References import_export::DataStreamSink::copy_params, run_benchmark_import::end_time, omnisci::fopen(), import_export::DataStreamSink::import_mutex_, import_export::DataStreamSink::import_status_, parse_ast::line, line1, import_export::CopyParams::line_delim, import_export::ImportStatus::load_failed, anonymous_namespace{Utm.h}::n, import_export::DataStreamSink::p_file, raw_data, import_export::ImportStatus::rows_completed, and timeout.

3185  {
3186  // we do not check interrupt status for this detection
3187  if (!p_file) {
3188  p_file = fopen(file_path.c_str(), "rb");
3189  }
3190  if (!p_file) {
3191  throw std::runtime_error("failed to open file '" + file_path +
3192  "': " + strerror(errno));
3193  }
3194 
3195  // somehow clang does not support ext/stdio_filebuf.h, so
3196  // need to diy readline with customized copy_params.line_delim...
3197  std::string line;
3198  line.reserve(1 * 1024 * 1024);
3199  auto end_time = std::chrono::steady_clock::now() +
3200  timeout * (boost::istarts_with(file_path, "s3://") ? 3 : 1);
3201  try {
3202  while (!feof(p_file)) {
3203  int c;
3204  size_t n = 0;
3205  while (EOF != (c = fgetc(p_file)) && copy_params.line_delim != c) {
3206  if (n++ >= line.capacity()) {
3207  break;
3208  }
3209  line += c;
3210  }
3211  if (0 == n) {
3212  break;
3213  }
3214  // remember the first line, which is possibly a header line, to
3215  // ignore identical header line(s) in 2nd+ files of a archive;
3216  // otherwise, 2nd+ header may be mistaken as an all-string row
3217  // and so be final column types.
3218  if (line1.empty()) {
3219  line1 = line;
3220  } else if (line == line1) {
3221  line.clear();
3222  continue;
3223  }
3224 
3225  raw_data += line;
3227  line.clear();
3229  if (std::chrono::steady_clock::now() > end_time) {
3230  if (import_status_.rows_completed > 10000) {
3231  break;
3232  }
3233  }
3234  }
3235  } catch (std::exception& e) {
3236  }
3237 
3238  mapd_lock_guard<mapd_shared_mutex> write_lock(import_mutex_);
3239  import_status_.load_failed = true;
3240 
3241  fclose(p_file);
3242  p_file = nullptr;
3243  return import_status_;
3244 }
::FILE * fopen(const char *filename, const char *mode)
Definition: omnisci_fs.cpp:72
mapd_shared_mutex import_mutex_
Definition: Importer.h:706
boost::filesystem::path file_path
Definition: Importer.h:760
tuple line
Definition: parse_ast.py:10
std::chrono::duration< double > timeout
Definition: Importer.h:761
std::string raw_data
Definition: Importer.h:759
mapd_unique_lock< mapd_shared_mutex > write_lock
constexpr double n
Definition: Utm.h:46

+ Here is the call graph for this function:

void import_export::Detector::init ( )
private

Definition at line 3176 of file Importer.cpp.

References detect_row_delimiter(), find_best_sqltypes_and_headers(), and split_raw_data().

Referenced by Detector().

3176  {
3178  split_raw_data();
3180 }
void find_best_sqltypes_and_headers()
Definition: Importer.cpp:3423

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool import_export::Detector::more_restrictive_sqltype ( const SQLTypes  a,
const SQLTypes  b 
)
staticprivate

Definition at line 3401 of file Importer.cpp.

References anonymous_namespace{Utm.h}::a, kBIGINT, kBOOLEAN, kCHAR, kDATE, kDOUBLE, kFLOAT, kINT, kLINESTRING, kMULTIPOLYGON, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, and kTIMESTAMP.

Referenced by find_best_sqltypes().

3401  {
3402  static std::array<int, kSQLTYPE_LAST> typeorder;
3403  typeorder[kCHAR] = 0;
3404  typeorder[kBOOLEAN] = 2;
3405  typeorder[kSMALLINT] = 3;
3406  typeorder[kINT] = 4;
3407  typeorder[kBIGINT] = 5;
3408  typeorder[kFLOAT] = 6;
3409  typeorder[kDOUBLE] = 7;
3410  typeorder[kTIMESTAMP] = 8;
3411  typeorder[kTIME] = 9;
3412  typeorder[kDATE] = 10;
3413  typeorder[kPOINT] = 11;
3414  typeorder[kLINESTRING] = 11;
3415  typeorder[kPOLYGON] = 11;
3416  typeorder[kMULTIPOLYGON] = 11;
3417  typeorder[kTEXT] = 12;
3418 
3419  // note: b < a instead of a < b because the map is ordered most to least restrictive
3420  return typeorder[b] < typeorder[a];
3421 }
Definition: sqltypes.h:49
constexpr double a
Definition: Utm.h:38
Definition: sqltypes.h:52
Definition: sqltypes.h:53
Definition: sqltypes.h:41
Definition: sqltypes.h:45

+ Here is the caller graph for this function:

void import_export::Detector::read_file ( )
private

Definition at line 3246 of file Importer.cpp.

References import_export::DataStreamSink::archivePlumber().

Referenced by Detector().

3246  {
3247  // this becomes analogous to Importer::import()
3248  (void)DataStreamSink::archivePlumber(nullptr);
3249 }
ImportStatus archivePlumber(const Catalog_Namespace::SessionInfo *session_info)
Definition: Importer.cpp:3616

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void import_export::Detector::split_raw_data ( )
private

Definition at line 3260 of file Importer.cpp.

References import_export::DataStreamSink::copy_params, import_export::delimited_parser::get_row(), raw_data, raw_rows, and import_export::CopyParams::threads.

Referenced by init().

3260  {
3261  const char* buf = raw_data.c_str();
3262  const char* buf_end = buf + raw_data.size();
3263  bool try_single_thread = false;
3264  for (const char* p = buf; p < buf_end; p++) {
3265  std::vector<std::string> row;
3266  std::vector<std::unique_ptr<char[]>> tmp_buffers;
3268  buf_end,
3269  buf_end,
3270  copy_params,
3271  nullptr,
3272  row,
3273  tmp_buffers,
3274  try_single_thread,
3275  true);
3276  raw_rows.push_back(row);
3277  if (try_single_thread) {
3278  break;
3279  }
3280  }
3281  if (try_single_thread) {
3282  copy_params.threads = 1;
3283  raw_rows.clear();
3284  for (const char* p = buf; p < buf_end; p++) {
3285  std::vector<std::string> row;
3286  std::vector<std::unique_ptr<char[]>> tmp_buffers;
3288  buf_end,
3289  buf_end,
3290  copy_params,
3291  nullptr,
3292  row,
3293  tmp_buffers,
3294  try_single_thread,
3295  true);
3296  raw_rows.push_back(row);
3297  }
3298  }
3299 }
const char * get_row(const char *buf, const char *buf_end, const char *entire_buf_end, const import_export::CopyParams &copy_params, const bool *is_array, std::vector< T > &row, std::vector< std::unique_ptr< char[]>> &tmp_buffers, bool &try_single_thread, bool filter_empty_lines)
Parses the first row in the given buffer and inserts fields into given vector.
std::vector< std::vector< std::string > > raw_rows
Definition: Importer.h:725
std::string raw_data
Definition: Importer.h:759

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

std::vector<EncodingType> import_export::Detector::best_encodings

Definition at line 728 of file Importer.h.

Referenced by DBHandler::detect_column_types(), and find_best_sqltypes_and_headers().

std::vector<SQLTypes> import_export::Detector::best_sqltypes
boost::filesystem::path import_export::Detector::file_path
private

Definition at line 760 of file Importer.h.

Referenced by detect_row_delimiter(), find_best_encodings(), and find_best_sqltypes().

bool import_export::Detector::has_headers = false
std::string import_export::Detector::line1
private

Definition at line 762 of file Importer.h.

Referenced by importDelimited().

std::string import_export::Detector::raw_data
private

Definition at line 759 of file Importer.h.

Referenced by importDelimited(), and split_raw_data().

std::vector<std::vector<std::string> > import_export::Detector::raw_rows
std::chrono::duration<double> import_export::Detector::timeout {1}
private

Definition at line 761 of file Importer.h.

Referenced by find_best_sqltypes(), and importDelimited().


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