Class import_export::Detector

class Detector : public import_export::DataStreamSink

Public 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)
std::vector<SQLTypeInfo> getBestColumnTypes() const

Public Members

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

Public Static Functions

SQLTypes detect_sqltype(const std::string &str)

Public Static Attributes

constexpr size_t kDefaultSampleRowsCount = {100}

Private Functions

void init()
void read_file()
void detect_row_delimiter()
void split_raw_data()
std::vector<SQLTypes> detect_column_types(const std::vector<std::string> &row)
void find_best_sqltypes()
std::vector<SQLTypes> find_best_sqltypes(const std::vector<std::vector<std::string>> &raw_rows, const CopyParams &copy_params)
std::vector<SQLTypes> 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)
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)
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)

Private Members

std::string raw_data
boost::filesystem::path file_path
std::chrono::duration<double> timeout = {1}
std::string line1
std::vector<SQLTypes> best_sqltypes
std::vector<EncodingType> best_encodings

Private Static Functions

bool more_restrictive_sqltype(const SQLTypes a, const SQLTypes b)