OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RowToColumnLoader.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
24 #ifndef _ROWTOCOLUMNLOADER_H_
25 #define _ROWTOCOLUMNLOADER_H_
26 
27 #include "Logger/Logger.h"
28 
29 #include <boost/algorithm/string.hpp>
30 #include <boost/algorithm/string/trim.hpp>
31 
32 #include <cstring>
33 #include <iostream>
34 #include <iterator>
35 #include <string>
36 
37 #include "Shared/ThriftClient.h"
38 #include "Shared/sqltypes.h"
39 
40 #include <chrono>
41 #include <thread>
42 
43 #include <boost/program_options.hpp>
44 
45 // include files for Thrift and MapD Thrift Services
46 #include "CopyParams.h"
47 #include "gen-cpp/Heavy.h"
48 #include "gen-cpp/heavy_types.h"
49 
50 using namespace ::apache::thrift;
51 using namespace ::apache::thrift::protocol;
52 using namespace ::apache::thrift::transport;
53 
55  public:
56  RowToColumnLoader(const ThriftClientConnection& conn_details,
57  const std::string& user_name,
58  const std::string& passwd,
59  const std::string& db_name,
60  const std::string& table_name);
62  void do_load(int& nrows, int& nskipped, import_export::CopyParams copy_params);
63  bool convert_string_to_column(std::vector<TStringValue> row,
64  const import_export::CopyParams& copy_params);
65  TRowDescriptor get_row_descriptor();
66  std::string print_row_with_delim(std::vector<TStringValue> row,
67  const import_export::CopyParams& copy_params);
68 
69  private:
70  std::string user_name_;
71  std::string passwd_;
72  std::string db_name_;
73  std::string table_name_;
75 
76  std::vector<TColumn> input_columns_;
77  std::vector<SQLTypeInfo> column_type_info_;
78  std::vector<SQLTypeInfo> array_column_type_info_;
79 
80  TRowDescriptor row_desc_;
81 
82  std::shared_ptr<HeavyClient> client_;
83  TSessionId session_;
84 
86  void closeConnection();
87  void wait_disconnect_reconnect_retry(size_t tries,
88  import_export::CopyParams copy_params);
89 };
90 
91 #endif // _ROWTOCOLUMNLOADER_H_
TRowDescriptor get_row_descriptor()
std::string print_row_with_delim(std::vector< TStringValue > row, const import_export::CopyParams &copy_params)
std::string table_name_
Constants for Builtin SQL Types supported by HEAVY.AI.
std::vector< SQLTypeInfo > column_type_info_
std::string user_name_
std::shared_ptr< HeavyClient > client_
void do_load(int &nrows, int &nskipped, import_export::CopyParams copy_params)
TRowDescriptor row_desc_
std::vector< TColumn > input_columns_
std::vector< SQLTypeInfo > array_column_type_info_
RowToColumnLoader(const ThriftClientConnection &conn_details, const std::string &user_name, const std::string &passwd, const std::string &db_name, const std::string &table_name)
bool convert_string_to_column(std::vector< TStringValue > row, const import_export::CopyParams &copy_params)
void wait_disconnect_reconnect_retry(size_t tries, import_export::CopyParams copy_params)
void createConnection(const ThriftClientConnection &con)
ThriftClientConnection conn_details_