OmniSciDB  340b00dbf6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
import_export::TypedImportBuffer Class Reference

#include <Importer.h>

+ Inheritance diagram for import_export::TypedImportBuffer:
+ Collaboration diagram for import_export::TypedImportBuffer:

Public Member Functions

 TypedImportBuffer (const ColumnDescriptor *col_desc, StringDictionary *string_dict)
 
 ~TypedImportBuffer ()
 
void addBoolean (const int8_t v)
 
void addTinyint (const int8_t v)
 
void addSmallint (const int16_t v)
 
void addInt (const int32_t v)
 
void addBigint (const int64_t v)
 
void addFloat (const float v)
 
void addDouble (const double v)
 
void addString (const std::string_view v)
 
void addGeoString (const std::string_view v)
 
void addArray (const ArrayDatum &v)
 
std::vector< std::string > & addStringArray ()
 
void addStringArray (const std::vector< std::string > &arr)
 
void addDictEncodedString (const std::vector< std::string > &string_vec)
 
void addDictEncodedStringArray (const std::vector< std::vector< std::string >> &string_array_vec)
 
const SQLTypeInfogetTypeInfo () const
 
const ColumnDescriptorgetColumnDesc () const
 
StringDictionarygetStringDictionary () const
 
int8_t * getAsBytes () const
 
size_t getElementSize () const
 
std::vector< std::string > * getStringBuffer () const
 
std::vector< std::string > * getGeoStringBuffer () const
 
std::vector< ArrayDatum > * getArrayBuffer () const
 
std::vector< std::vector
< std::string > > * 
getStringArrayBuffer () const
 
std::vector< ArrayDatum > * getStringArrayDictBuffer () const
 
int8_t * getStringDictBuffer () const
 
bool stringDictCheckpoint ()
 
void clear ()
 
size_t add_values (const ColumnDescriptor *cd, const TColumn &data)
 
size_t add_arrow_values (const ColumnDescriptor *cd, const arrow::Array &data, const bool exact_type_match, const ArraySliceRange &slice_range, BadRowsTracker *bad_rows_tracker)
 
void add_value (const ColumnDescriptor *cd, const std::string_view val, const bool is_null, const CopyParams &copy_params, const int64_t replicate_count=0)
 
void add_value (const ColumnDescriptor *cd, const TDatum &val, const bool is_null, const int64_t replicate_count=0)
 
void pop_value ()
 
int64_t get_replicate_count () const
 
void set_replicate_count (const int64_t replicate_count)
 
template<typename DATA_TYPE >
size_t convert_arrow_val_to_import_buffer (const ColumnDescriptor *cd, const arrow::Array &array, std::vector< DATA_TYPE > &buffer, const ArraySliceRange &slice_range, BadRowsTracker *const bad_rows_tracker)
 
template<typename DATA_TYPE >
auto del_values (std::vector< DATA_TYPE > &buffer, BadRowsTracker *const bad_rows_tracker)
 
auto del_values (const SQLTypes type, BadRowsTracker *const bad_rows_tracker)
 
template<typename DATA_TYPE >
size_t convert_arrow_val_to_import_buffer (const ColumnDescriptor *cd, const Array &array, std::vector< DATA_TYPE > &buffer, const ArraySliceRange &slice_range, import_export::BadRowsTracker *const bad_rows_tracker)
 

Public Attributes

std::vector< std::unique_ptr
< TypedImportBuffer > > * 
import_buffers
 
size_t col_idx
 
std::vector< int8_t > * bool_buffer_
 
std::vector< int8_t > * tinyint_buffer_
 
std::vector< int16_t > * smallint_buffer_
 
std::vector< int32_t > * int_buffer_
 
std::vector< int64_t > * bigint_buffer_
 
std::vector< float > * float_buffer_
 
std::vector< double > * double_buffer_
 
std::vector< std::string > * string_buffer_
 
std::vector< std::string > * geo_string_buffer_
 
std::vector< ArrayDatum > * array_buffer_
 
std::vector< std::vector
< std::string > > * 
string_array_buffer_
 
std::vector< uint8_t > * string_dict_i8_buffer_
 
std::vector< uint16_t > * string_dict_i16_buffer_
 
std::vector< int32_t > * string_dict_i32_buffer_
 
std::vector< ArrayDatum > * string_array_dict_buffer_
 

Private Attributes

union {
   std::vector< int8_t > *   bool_buffer_
 
   std::vector< int8_t > *   tinyint_buffer_
 
   std::vector< int16_t > *   smallint_buffer_
 
   std::vector< int32_t > *   int_buffer_
 
   std::vector< int64_t > *   bigint_buffer_
 
   std::vector< float > *   float_buffer_
 
   std::vector< double > *   double_buffer_
 
   std::vector< std::string > *   string_buffer_
 
   std::vector< std::string > *   geo_string_buffer_
 
   std::vector< ArrayDatum > *   array_buffer_
 
   std::vector< std::vector
< std::string > > *   string_array_buffer_
 
}; 
 
union {
   std::vector< uint8_t > *   string_dict_i8_buffer_
 
   std::vector< uint16_t > *   string_dict_i16_buffer_
 
   std::vector< int32_t > *   string_dict_i32_buffer_
 
   std::vector< ArrayDatum > *   string_array_dict_buffer_
 
}; 
 
const ColumnDescriptorcolumn_desc_
 
StringDictionarystring_dict_
 
size_t replicate_count_ = 0
 

Detailed Description

Definition at line 83 of file Importer.h.

Constructor & Destructor Documentation

import_export::TypedImportBuffer::TypedImportBuffer ( const ColumnDescriptor col_desc,
StringDictionary string_dict 
)
inline

Definition at line 85 of file Importer.h.

References array_buffer_, bigint_buffer_, bool_buffer_, CHECK, ColumnDescriptor::columnType, double_buffer_, float_buffer_, geo_string_buffer_, SQLTypeInfo::get_compression(), SQLTypeInfo::get_size(), SQLTypeInfo::get_subtype(), SQLTypeInfo::get_type(), int_buffer_, IS_STRING, kARRAY, kBIGINT, kBOOLEAN, kCHAR, kDATE, kDECIMAL, kDOUBLE, kENCODING_DICT, kFLOAT, kINT, kLINESTRING, kMULTIPOLYGON, kNUMERIC, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, smallint_buffer_, string_array_buffer_, string_array_dict_buffer_, string_buffer_, string_dict_i16_buffer_, string_dict_i32_buffer_, string_dict_i8_buffer_, and tinyint_buffer_.

86  : column_desc_(col_desc), string_dict_(string_dict) {
87  switch (col_desc->columnType.get_type()) {
88  case kBOOLEAN:
89  bool_buffer_ = new std::vector<int8_t>();
90  break;
91  case kTINYINT:
92  tinyint_buffer_ = new std::vector<int8_t>();
93  break;
94  case kSMALLINT:
95  smallint_buffer_ = new std::vector<int16_t>();
96  break;
97  case kINT:
98  int_buffer_ = new std::vector<int32_t>();
99  break;
100  case kBIGINT:
101  case kNUMERIC:
102  case kDECIMAL:
103  bigint_buffer_ = new std::vector<int64_t>();
104  break;
105  case kFLOAT:
106  float_buffer_ = new std::vector<float>();
107  break;
108  case kDOUBLE:
109  double_buffer_ = new std::vector<double>();
110  break;
111  case kTEXT:
112  case kVARCHAR:
113  case kCHAR:
114  string_buffer_ = new std::vector<std::string>();
115  if (col_desc->columnType.get_compression() == kENCODING_DICT) {
116  switch (col_desc->columnType.get_size()) {
117  case 1:
118  string_dict_i8_buffer_ = new std::vector<uint8_t>();
119  break;
120  case 2:
121  string_dict_i16_buffer_ = new std::vector<uint16_t>();
122  break;
123  case 4:
124  string_dict_i32_buffer_ = new std::vector<int32_t>();
125  break;
126  default:
127  CHECK(false);
128  }
129  }
130  break;
131  case kDATE:
132  case kTIME:
133  case kTIMESTAMP:
134  bigint_buffer_ = new std::vector<int64_t>();
135  break;
136  case kARRAY:
137  if (IS_STRING(col_desc->columnType.get_subtype())) {
139  string_array_buffer_ = new std::vector<std::vector<std::string>>();
140  string_array_dict_buffer_ = new std::vector<ArrayDatum>();
141  } else {
142  array_buffer_ = new std::vector<ArrayDatum>();
143  }
144  break;
145  case kPOINT:
146  case kLINESTRING:
147  case kPOLYGON:
148  case kMULTIPOLYGON:
149  geo_string_buffer_ = new std::vector<std::string>();
150  break;
151  default:
152  CHECK(false);
153  }
154  }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:331
HOST DEVICE int get_size() const
Definition: sqltypes.h:340
Definition: sqltypes.h:51
std::vector< std::string > * string_buffer_
Definition: Importer.h:498
std::vector< ArrayDatum > * array_buffer_
Definition: Importer.h:500
StringDictionary * string_dict_
Definition: Importer.h:510
std::vector< int16_t > * smallint_buffer_
Definition: Importer.h:493
std::vector< float > * float_buffer_
Definition: Importer.h:496
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:330
std::vector< double > * double_buffer_
Definition: Importer.h:497
std::vector< int32_t > * int_buffer_
Definition: Importer.h:494
std::vector< ArrayDatum > * string_array_dict_buffer_
Definition: Importer.h:507
std::vector< uint8_t > * string_dict_i8_buffer_
Definition: Importer.h:504
std::vector< int64_t > * bigint_buffer_
Definition: Importer.h:495
std::vector< int8_t > * bool_buffer_
Definition: Importer.h:491
std::vector< std::vector< std::string > > * string_array_buffer_
Definition: Importer.h:501
Definition: sqltypes.h:54
Definition: sqltypes.h:55
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:338
std::vector< int32_t > * string_dict_i32_buffer_
Definition: Importer.h:506
Definition: sqltypes.h:43
#define IS_STRING(T)
Definition: sqltypes.h:244
const ColumnDescriptor * column_desc_
Definition: Importer.h:509
std::vector< uint16_t > * string_dict_i16_buffer_
Definition: Importer.h:505
std::vector< int8_t > * tinyint_buffer_
Definition: Importer.h:492
#define CHECK(condition)
Definition: Logger.h:197
Definition: sqltypes.h:47
SQLTypeInfo columnType
std::vector< std::string > * geo_string_buffer_
Definition: Importer.h:499

+ Here is the call graph for this function:

import_export::TypedImportBuffer::~TypedImportBuffer ( )
inline

Definition at line 156 of file Importer.h.

References array_buffer_, bigint_buffer_, bool_buffer_, CHECK, column_desc_, ColumnDescriptor::columnType, double_buffer_, float_buffer_, geo_string_buffer_, SQLTypeInfo::get_compression(), SQLTypeInfo::get_size(), SQLTypeInfo::get_subtype(), SQLTypeInfo::get_type(), int_buffer_, IS_STRING, kARRAY, kBIGINT, kBOOLEAN, kCHAR, kDATE, kDECIMAL, kDOUBLE, kENCODING_DICT, kFLOAT, kINT, kLINESTRING, kMULTIPOLYGON, kNUMERIC, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, smallint_buffer_, string_array_buffer_, string_array_dict_buffer_, string_buffer_, string_dict_i16_buffer_, string_dict_i32_buffer_, string_dict_i8_buffer_, and tinyint_buffer_.

156  {
157  switch (column_desc_->columnType.get_type()) {
158  case kBOOLEAN:
159  delete bool_buffer_;
160  break;
161  case kTINYINT:
162  delete tinyint_buffer_;
163  break;
164  case kSMALLINT:
165  delete smallint_buffer_;
166  break;
167  case kINT:
168  delete int_buffer_;
169  break;
170  case kBIGINT:
171  case kNUMERIC:
172  case kDECIMAL:
173  delete bigint_buffer_;
174  break;
175  case kFLOAT:
176  delete float_buffer_;
177  break;
178  case kDOUBLE:
179  delete double_buffer_;
180  break;
181  case kTEXT:
182  case kVARCHAR:
183  case kCHAR:
184  delete string_buffer_;
186  switch (column_desc_->columnType.get_size()) {
187  case 1:
188  delete string_dict_i8_buffer_;
189  break;
190  case 2:
192  break;
193  case 4:
195  break;
196  }
197  }
198  break;
199  case kDATE:
200  case kTIME:
201  case kTIMESTAMP:
202  delete bigint_buffer_;
203  break;
204  case kARRAY:
206  delete string_array_buffer_;
208  } else {
209  delete array_buffer_;
210  }
211  break;
212  case kPOINT:
213  case kLINESTRING:
214  case kPOLYGON:
215  case kMULTIPOLYGON:
216  delete geo_string_buffer_;
217  break;
218  default:
219  CHECK(false);
220  }
221  }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:331
HOST DEVICE int get_size() const
Definition: sqltypes.h:340
Definition: sqltypes.h:51
std::vector< std::string > * string_buffer_
Definition: Importer.h:498
std::vector< ArrayDatum > * array_buffer_
Definition: Importer.h:500
std::vector< int16_t > * smallint_buffer_
Definition: Importer.h:493
std::vector< float > * float_buffer_
Definition: Importer.h:496
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:330
std::vector< double > * double_buffer_
Definition: Importer.h:497
std::vector< int32_t > * int_buffer_
Definition: Importer.h:494
std::vector< ArrayDatum > * string_array_dict_buffer_
Definition: Importer.h:507
std::vector< uint8_t > * string_dict_i8_buffer_
Definition: Importer.h:504
std::vector< int64_t > * bigint_buffer_
Definition: Importer.h:495
std::vector< int8_t > * bool_buffer_
Definition: Importer.h:491
std::vector< std::vector< std::string > > * string_array_buffer_
Definition: Importer.h:501
Definition: sqltypes.h:54
Definition: sqltypes.h:55
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:338
std::vector< int32_t > * string_dict_i32_buffer_
Definition: Importer.h:506
Definition: sqltypes.h:43
#define IS_STRING(T)
Definition: sqltypes.h:244
const ColumnDescriptor * column_desc_
Definition: Importer.h:509
std::vector< uint16_t > * string_dict_i16_buffer_
Definition: Importer.h:505
std::vector< int8_t > * tinyint_buffer_
Definition: Importer.h:492
#define CHECK(condition)
Definition: Logger.h:197
Definition: sqltypes.h:47
SQLTypeInfo columnType
std::vector< std::string > * geo_string_buffer_
Definition: Importer.h:499

+ Here is the call graph for this function:

Member Function Documentation

size_t import_export::TypedImportBuffer::add_arrow_values ( const ColumnDescriptor cd,
const arrow::Array &  data,
const bool  exact_type_match,
const ArraySliceRange slice_range,
BadRowsTracker bad_rows_tracker 
)

Definition at line 847 of file Importer.cpp.

References arrow_throw_if(), bigint_buffer_, bool_buffer_, ColumnDescriptor::columnName, ColumnDescriptor::columnType, convert_arrow_val_to_import_buffer(), double_buffer_, float_buffer_, geo_string_buffer_, SQLTypeInfo::get_notnull(), SQLTypeInfo::get_type(), int_buffer_, kARRAY, kBIGINT, kBOOLEAN, kCHAR, kDATE, kDECIMAL, kDOUBLE, kFLOAT, kINT, kLINESTRING, kMULTIPOLYGON, kNUMERIC, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, smallint_buffer_, omnisci.dtypes::STRING, string_buffer_, tinyint_buffer_, and run_benchmark_import::type.

851  {
852  const auto type = cd->columnType.get_type();
853  if (cd->columnType.get_notnull()) {
854  // We can't have any null values for this column; to have them is an error
855  arrow_throw_if(col.null_count() > 0, "NULL not allowed for column " + cd->columnName);
856  }
857 
858  switch (type) {
859  case kBOOLEAN:
860  if (exact_type_match) {
861  arrow_throw_if(col.type_id() != Type::BOOL, "Expected boolean type");
862  }
864  cd, col, *bool_buffer_, slice_range, bad_rows_tracker);
865  case kTINYINT:
866  if (exact_type_match) {
867  arrow_throw_if(col.type_id() != Type::INT8, "Expected int8 type");
868  }
870  cd, col, *tinyint_buffer_, slice_range, bad_rows_tracker);
871  case kSMALLINT:
872  if (exact_type_match) {
873  arrow_throw_if(col.type_id() != Type::INT16, "Expected int16 type");
874  }
876  cd, col, *smallint_buffer_, slice_range, bad_rows_tracker);
877  case kINT:
878  if (exact_type_match) {
879  arrow_throw_if(col.type_id() != Type::INT32, "Expected int32 type");
880  }
882  cd, col, *int_buffer_, slice_range, bad_rows_tracker);
883  case kBIGINT:
884  case kNUMERIC:
885  case kDECIMAL:
886  if (exact_type_match) {
887  arrow_throw_if(col.type_id() != Type::INT64, "Expected int64 type");
888  }
890  cd, col, *bigint_buffer_, slice_range, bad_rows_tracker);
891  case kFLOAT:
892  if (exact_type_match) {
893  arrow_throw_if(col.type_id() != Type::FLOAT, "Expected float type");
894  }
896  cd, col, *float_buffer_, slice_range, bad_rows_tracker);
897  case kDOUBLE:
898  if (exact_type_match) {
899  arrow_throw_if(col.type_id() != Type::DOUBLE, "Expected double type");
900  }
902  cd, col, *double_buffer_, slice_range, bad_rows_tracker);
903  case kTEXT:
904  case kVARCHAR:
905  case kCHAR:
906  if (exact_type_match) {
907  arrow_throw_if(col.type_id() != Type::BINARY && col.type_id() != Type::STRING,
908  "Expected string type");
909  }
911  cd, col, *string_buffer_, slice_range, bad_rows_tracker);
912  case kTIME:
913  if (exact_type_match) {
914  arrow_throw_if(col.type_id() != Type::TIME32 && col.type_id() != Type::TIME64,
915  "Expected time32 or time64 type");
916  }
918  cd, col, *bigint_buffer_, slice_range, bad_rows_tracker);
919  case kTIMESTAMP:
920  if (exact_type_match) {
921  arrow_throw_if(col.type_id() != Type::TIMESTAMP, "Expected timestamp type");
922  }
924  cd, col, *bigint_buffer_, slice_range, bad_rows_tracker);
925  case kDATE:
926  if (exact_type_match) {
927  arrow_throw_if(col.type_id() != Type::DATE32 && col.type_id() != Type::DATE64,
928  "Expected date32 or date64 type");
929  }
931  cd, col, *bigint_buffer_, slice_range, bad_rows_tracker);
932  case kPOINT:
933  case kLINESTRING:
934  case kPOLYGON:
935  case kMULTIPOLYGON:
936  arrow_throw_if(col.type_id() != Type::BINARY && col.type_id() != Type::STRING,
937  "Expected string type");
939  cd, col, *geo_string_buffer_, slice_range, bad_rows_tracker);
940  case kARRAY:
941  throw std::runtime_error("Arrow array appends not yet supported");
942  default:
943  throw std::runtime_error("Invalid Type");
944  }
945 }
Definition: sqltypes.h:51
std::vector< std::string > * string_buffer_
Definition: Importer.h:498
std::vector< int16_t > * smallint_buffer_
Definition: Importer.h:493
std::vector< float > * float_buffer_
Definition: Importer.h:496
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:330
std::vector< double > * double_buffer_
Definition: Importer.h:497
std::vector< int32_t > * int_buffer_
Definition: Importer.h:494
std::vector< int64_t > * bigint_buffer_
Definition: Importer.h:495
tuple STRING
Definition: dtypes.py:31
std::vector< int8_t > * bool_buffer_
Definition: Importer.h:491
Definition: sqltypes.h:54
Definition: sqltypes.h:55
Definition: sqltypes.h:43
std::vector< int8_t > * tinyint_buffer_
Definition: Importer.h:492
size_t convert_arrow_val_to_import_buffer(const ColumnDescriptor *cd, const arrow::Array &array, std::vector< DATA_TYPE > &buffer, const ArraySliceRange &slice_range, BadRowsTracker *const bad_rows_tracker)
Definition: sqltypes.h:47
SQLTypeInfo columnType
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:337
std::string columnName
void arrow_throw_if(const bool cond, const std::string &message)
Definition: ArrowImporter.h:41
std::vector< std::string > * geo_string_buffer_
Definition: Importer.h:499

+ Here is the call graph for this function:

void import_export::TypedImportBuffer::add_value ( const ColumnDescriptor cd,
const std::string_view  val,
const bool  is_null,
const CopyParams copy_params,
const int64_t  replicate_count = 0 
)

Definition at line 497 of file Importer.cpp.

References addArray(), addBigint(), addBoolean(), addDouble(), addFloat(), addGeoString(), addInt(), addSmallint(), addString(), addStringArray(), addTinyint(), Datum::bigintval, Datum::boolval, CHECK, ColumnDescriptor::columnName, ColumnDescriptor::columnType, convert_decimal_value_to_scale(), SQLTypeInfo::get_elem_type(), SQLTypeInfo::get_notnull(), SQLTypeInfo::get_size(), SQLTypeInfo::get_subtype(), SQLTypeInfo::get_type(), inline_fixed_encoding_null_val(), Datum::intval, IS_STRING, kARRAY, kBIGINT, kBOOLEAN, kCHAR, kDATE, kDECIMAL, kDOUBLE, kFLOAT, kINT, kLINESTRING, kMULTIPOLYGON, kNUMERIC, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, StringDictionary::MAX_STRLEN, NULL_DOUBLE, NULL_FLOAT, import_export::NullArray(), import_export::delimited_parser::parse_string_array(), set_replicate_count(), Datum::smallintval, import_export::StringToArray(), StringToDatum(), Datum::tinyintval, to_string(), and run_benchmark_import::type.

501  {
502  set_replicate_count(replicate_count);
503  const auto type = cd->columnType.get_type();
504  switch (type) {
505  case kBOOLEAN: {
506  if (is_null) {
507  if (cd->columnType.get_notnull()) {
508  throw std::runtime_error("NULL for column " + cd->columnName);
509  }
511  } else {
512  auto ti = cd->columnType;
513  Datum d = StringToDatum(val, ti);
514  addBoolean(static_cast<int8_t>(d.boolval));
515  }
516  break;
517  }
518  case kTINYINT: {
519  if (!is_null && (isdigit(val[0]) || val[0] == '-')) {
520  auto ti = cd->columnType;
521  Datum d = StringToDatum(val, ti);
523  } else {
524  if (cd->columnType.get_notnull()) {
525  throw std::runtime_error("NULL for column " + cd->columnName);
526  }
528  }
529  break;
530  }
531  case kSMALLINT: {
532  if (!is_null && (isdigit(val[0]) || val[0] == '-')) {
533  auto ti = cd->columnType;
534  Datum d = StringToDatum(val, ti);
536  } else {
537  if (cd->columnType.get_notnull()) {
538  throw std::runtime_error("NULL for column " + cd->columnName);
539  }
541  }
542  break;
543  }
544  case kINT: {
545  if (!is_null && (isdigit(val[0]) || val[0] == '-')) {
546  auto ti = cd->columnType;
547  Datum d = StringToDatum(val, ti);
548  addInt(d.intval);
549  } else {
550  if (cd->columnType.get_notnull()) {
551  throw std::runtime_error("NULL for column " + cd->columnName);
552  }
554  }
555  break;
556  }
557  case kBIGINT: {
558  if (!is_null && (isdigit(val[0]) || val[0] == '-')) {
559  auto ti = cd->columnType;
560  Datum d = StringToDatum(val, ti);
561  addBigint(d.bigintval);
562  } else {
563  if (cd->columnType.get_notnull()) {
564  throw std::runtime_error("NULL for column " + cd->columnName);
565  }
567  }
568  break;
569  }
570  case kDECIMAL:
571  case kNUMERIC: {
572  if (!is_null) {
573  SQLTypeInfo ti(kNUMERIC, 0, 0, false);
574  Datum d = StringToDatum(val, ti);
575  const auto converted_decimal_value =
577  addBigint(converted_decimal_value);
578  } else {
579  if (cd->columnType.get_notnull()) {
580  throw std::runtime_error("NULL for column " + cd->columnName);
581  }
583  }
584  break;
585  }
586  case kFLOAT:
587  if (!is_null && (val[0] == '.' || isdigit(val[0]) || val[0] == '-')) {
588  addFloat(static_cast<float>(std::atof(std::string(val).c_str())));
589  } else {
590  if (cd->columnType.get_notnull()) {
591  throw std::runtime_error("NULL for column " + cd->columnName);
592  }
594  }
595  break;
596  case kDOUBLE:
597  if (!is_null && (val[0] == '.' || isdigit(val[0]) || val[0] == '-')) {
598  addDouble(std::atof(std::string(val).c_str()));
599  } else {
600  if (cd->columnType.get_notnull()) {
601  throw std::runtime_error("NULL for column " + cd->columnName);
602  }
604  }
605  break;
606  case kTEXT:
607  case kVARCHAR:
608  case kCHAR: {
609  // @TODO(wei) for now, use empty string for nulls
610  if (is_null) {
611  if (cd->columnType.get_notnull()) {
612  throw std::runtime_error("NULL for column " + cd->columnName);
613  }
614  addString(std::string());
615  } else {
616  if (val.length() > StringDictionary::MAX_STRLEN) {
617  throw std::runtime_error("String too long for column " + cd->columnName +
618  " was " + std::to_string(val.length()) + " max is " +
620  }
621  addString(val);
622  }
623  break;
624  }
625  case kTIME:
626  case kTIMESTAMP:
627  case kDATE:
628  if (!is_null && (isdigit(val[0]) || val[0] == '-')) {
629  SQLTypeInfo ti = cd->columnType;
630  Datum d = StringToDatum(val, ti);
631  addBigint(d.bigintval);
632  } else {
633  if (cd->columnType.get_notnull()) {
634  throw std::runtime_error("NULL for column " + cd->columnName);
635  }
637  }
638  break;
639  case kARRAY: {
640  if (is_null && cd->columnType.get_notnull()) {
641  throw std::runtime_error("NULL for column " + cd->columnName);
642  }
643  SQLTypeInfo ti = cd->columnType;
644  if (IS_STRING(ti.get_subtype())) {
645  std::vector<std::string> string_vec;
646  // Just parse string array, don't push it to buffer yet as we might throw
648  std::string(val), copy_params, string_vec);
649  if (!is_null) {
650  // TODO: add support for NULL string arrays
651  if (ti.get_size() > 0) {
652  auto sti = ti.get_elem_type();
653  size_t expected_size = ti.get_size() / sti.get_size();
654  size_t actual_size = string_vec.size();
655  if (actual_size != expected_size) {
656  throw std::runtime_error("Fixed length array column " + cd->columnName +
657  " expects " + std::to_string(expected_size) +
658  " values, received " +
659  std::to_string(actual_size));
660  }
661  }
662  addStringArray(string_vec);
663  } else {
664  if (ti.get_size() > 0) {
665  // TODO: remove once NULL fixlen arrays are allowed
666  throw std::runtime_error("Fixed length array column " + cd->columnName +
667  " currently cannot accept NULL arrays");
668  }
669  // TODO: add support for NULL string arrays, replace with addStringArray(),
670  // for now add whatever parseStringArray() outputs for NULLs ("NULL")
671  addStringArray(string_vec);
672  }
673  } else {
674  if (!is_null) {
675  ArrayDatum d = StringToArray(std::string(val), ti, copy_params);
676  if (d.is_null) { // val could be "NULL"
677  addArray(NullArray(ti));
678  } else {
679  if (ti.get_size() > 0 && static_cast<size_t>(ti.get_size()) != d.length) {
680  throw std::runtime_error("Fixed length array for column " + cd->columnName +
681  " has incorrect length: " + std::string(val));
682  }
683  addArray(d);
684  }
685  } else {
686  addArray(NullArray(ti));
687  }
688  }
689  break;
690  }
691  case kPOINT:
692  case kLINESTRING:
693  case kPOLYGON:
694  case kMULTIPOLYGON:
695  addGeoString(val);
696  break;
697  default:
698  CHECK(false) << "TypedImportBuffer::add_value() does not support type " << type;
699  }
700 }
int8_t tinyintval
Definition: sqltypes.h:206
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:331
#define NULL_DOUBLE
Definition: sqltypes.h:257
HOST DEVICE int get_size() const
Definition: sqltypes.h:340
void addBigint(const int64_t v)
Definition: Importer.h:231
void addSmallint(const int16_t v)
Definition: Importer.h:227
Definition: sqltypes.h:51
void addString(const std::string_view v)
Definition: Importer.h:237
bool boolval
Definition: sqltypes.h:205
void set_replicate_count(const int64_t replicate_count)
Definition: Importer.h:474
void addDouble(const double v)
Definition: Importer.h:235
ArrayDatum NullArray(const SQLTypeInfo &ti)
Definition: Importer.cpp:366
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:330
int32_t intval
Definition: sqltypes.h:208
std::string to_string(char const *&&v)
void addFloat(const float v)
Definition: Importer.h:233
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Definition: sqltypes.h:202
void addGeoString(const std::string_view v)
Definition: Importer.h:239
void addBoolean(const int8_t v)
Definition: Importer.h:223
void addTinyint(const int8_t v)
Definition: Importer.h:225
int64_t bigintval
Definition: sqltypes.h:209
#define NULL_FLOAT
Definition: sqltypes.h:256
void addInt(const int32_t v)
Definition: Importer.h:229
int16_t smallintval
Definition: sqltypes.h:207
Datum StringToDatum(std::string_view s, SQLTypeInfo &ti)
Definition: Datum.cpp:124
Definition: sqltypes.h:54
Definition: sqltypes.h:55
std::vector< std::string > & addStringArray()
Definition: Importer.h:243
ArrayDatum StringToArray(const std::string &s, const SQLTypeInfo &ti, const CopyParams &copy_params)
Definition: Importer.cpp:313
bool is_null(const T &v, const SQLTypeInfo &t)
int64_t convert_decimal_value_to_scale(const int64_t decimal_value, const SQLTypeInfo &type_info, const SQLTypeInfo &new_type_info)
Definition: Datum.cpp:318
void addArray(const ArrayDatum &v)
Definition: Importer.h:241
Definition: sqltypes.h:43
#define IS_STRING(T)
Definition: sqltypes.h:244
#define CHECK(condition)
Definition: Logger.h:197
int64_t inline_fixed_encoding_null_val(const SQL_TYPE_INFO &ti)
static constexpr size_t MAX_STRLEN
Definition: sqltypes.h:47
SQLTypeInfo columnType
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:337
SQLTypeInfo get_elem_type() const
Definition: sqltypes.h:703
std::string columnName
void parse_string_array(const std::string &s, const import_export::CopyParams &copy_params, std::vector< std::string > &string_vec)
Parses given string array and inserts into given vector of strings.

+ Here is the call graph for this function:

void import_export::TypedImportBuffer::add_value ( const ColumnDescriptor cd,
const TDatum &  val,
const bool  is_null,
const int64_t  replicate_count = 0 
)

Definition at line 1269 of file Importer.cpp.

References addArray(), addBigint(), import_export::addBinaryStringArray(), addBoolean(), addDouble(), addFloat(), addGeoString(), addInt(), addSmallint(), addString(), addStringArray(), addTinyint(), CHECK, ColumnDescriptor::columnName, ColumnDescriptor::columnType, decimal_to_int_type(), SQLTypeInfo::get_notnull(), SQLTypeInfo::get_subtype(), SQLTypeInfo::get_type(), inline_fixed_encoding_null_val(), SQLTypeInfo::is_decimal(), IS_STRING, kARRAY, kBIGINT, kBOOLEAN, kCHAR, kDATE, kDOUBLE, kFLOAT, kINT, kLINESTRING, kMULTIPOLYGON, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, NULL_DOUBLE, NULL_FLOAT, import_export::NullArray(), set_replicate_count(), import_export::TDatumToArrayDatum(), and run_benchmark_import::type.

1272  {
1273  set_replicate_count(replicate_count);
1274  const auto type = cd->columnType.is_decimal() ? decimal_to_int_type(cd->columnType)
1275  : cd->columnType.get_type();
1276  switch (type) {
1277  case kBOOLEAN: {
1278  if (is_null) {
1279  if (cd->columnType.get_notnull()) {
1280  throw std::runtime_error("NULL for column " + cd->columnName);
1281  }
1283  } else {
1284  addBoolean((int8_t)datum.val.int_val);
1285  }
1286  break;
1287  }
1288  case kTINYINT:
1289  if (!is_null) {
1290  addTinyint((int8_t)datum.val.int_val);
1291  } else {
1292  if (cd->columnType.get_notnull()) {
1293  throw std::runtime_error("NULL for column " + cd->columnName);
1294  }
1296  }
1297  break;
1298  case kSMALLINT:
1299  if (!is_null) {
1300  addSmallint((int16_t)datum.val.int_val);
1301  } else {
1302  if (cd->columnType.get_notnull()) {
1303  throw std::runtime_error("NULL for column " + cd->columnName);
1304  }
1306  }
1307  break;
1308  case kINT:
1309  if (!is_null) {
1310  addInt((int32_t)datum.val.int_val);
1311  } else {
1312  if (cd->columnType.get_notnull()) {
1313  throw std::runtime_error("NULL for column " + cd->columnName);
1314  }
1316  }
1317  break;
1318  case kBIGINT:
1319  if (!is_null) {
1320  addBigint(datum.val.int_val);
1321  } else {
1322  if (cd->columnType.get_notnull()) {
1323  throw std::runtime_error("NULL for column " + cd->columnName);
1324  }
1326  }
1327  break;
1328  case kFLOAT:
1329  if (!is_null) {
1330  addFloat((float)datum.val.real_val);
1331  } else {
1332  if (cd->columnType.get_notnull()) {
1333  throw std::runtime_error("NULL for column " + cd->columnName);
1334  }
1336  }
1337  break;
1338  case kDOUBLE:
1339  if (!is_null) {
1340  addDouble(datum.val.real_val);
1341  } else {
1342  if (cd->columnType.get_notnull()) {
1343  throw std::runtime_error("NULL for column " + cd->columnName);
1344  }
1346  }
1347  break;
1348  case kTEXT:
1349  case kVARCHAR:
1350  case kCHAR: {
1351  // @TODO(wei) for now, use empty string for nulls
1352  if (is_null) {
1353  if (cd->columnType.get_notnull()) {
1354  throw std::runtime_error("NULL for column " + cd->columnName);
1355  }
1356  addString(std::string());
1357  } else {
1358  addString(datum.val.str_val);
1359  }
1360  break;
1361  }
1362  case kTIME:
1363  case kTIMESTAMP:
1364  case kDATE: {
1365  if (!is_null) {
1366  addBigint(datum.val.int_val);
1367  } else {
1368  if (cd->columnType.get_notnull()) {
1369  throw std::runtime_error("NULL for column " + cd->columnName);
1370  }
1372  }
1373  break;
1374  }
1375  case kARRAY:
1376  if (is_null && cd->columnType.get_notnull()) {
1377  throw std::runtime_error("NULL for column " + cd->columnName);
1378  }
1379  if (IS_STRING(cd->columnType.get_subtype())) {
1380  std::vector<std::string>& string_vec = addStringArray();
1381  addBinaryStringArray(datum, string_vec);
1382  } else {
1383  if (!is_null) {
1384  addArray(TDatumToArrayDatum(datum, cd->columnType));
1385  } else {
1387  }
1388  }
1389  break;
1390  case kPOINT:
1391  case kLINESTRING:
1392  case kPOLYGON:
1393  case kMULTIPOLYGON:
1394  if (is_null) {
1395  if (cd->columnType.get_notnull()) {
1396  throw std::runtime_error("NULL for column " + cd->columnName);
1397  }
1398  addGeoString(std::string());
1399  } else {
1400  addGeoString(datum.val.str_val);
1401  }
1402  break;
1403  default:
1404  CHECK(false) << "TypedImportBuffer::add_value() does not support type " << type;
1405  }
1406 }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:331
#define NULL_DOUBLE
Definition: sqltypes.h:257
void addBigint(const int64_t v)
Definition: Importer.h:231
void addSmallint(const int16_t v)
Definition: Importer.h:227
Definition: sqltypes.h:51
void addString(const std::string_view v)
Definition: Importer.h:237
void set_replicate_count(const int64_t replicate_count)
Definition: Importer.h:474
void addDouble(const double v)
Definition: Importer.h:235
ArrayDatum NullArray(const SQLTypeInfo &ti)
Definition: Importer.cpp:366
void addFloat(const float v)
Definition: Importer.h:233
void addGeoString(const std::string_view v)
Definition: Importer.h:239
ArrayDatum TDatumToArrayDatum(const TDatum &datum, const SQLTypeInfo &ti)
Definition: Importer.cpp:450
void addBoolean(const int8_t v)
Definition: Importer.h:223
void addTinyint(const int8_t v)
Definition: Importer.h:225
#define NULL_FLOAT
Definition: sqltypes.h:256
void addInt(const int32_t v)
Definition: Importer.h:229
SQLTypes decimal_to_int_type(const SQLTypeInfo &ti)
Definition: Datum.cpp:302
Definition: sqltypes.h:54
Definition: sqltypes.h:55
std::vector< std::string > & addStringArray()
Definition: Importer.h:243
bool is_null(const T &v, const SQLTypeInfo &t)
void addArray(const ArrayDatum &v)
Definition: Importer.h:241
Definition: sqltypes.h:43
#define IS_STRING(T)
Definition: sqltypes.h:244
#define CHECK(condition)
Definition: Logger.h:197
int64_t inline_fixed_encoding_null_val(const SQL_TYPE_INFO &ti)
Definition: sqltypes.h:47
SQLTypeInfo columnType
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:337
bool is_decimal() const
Definition: sqltypes.h:490
std::string columnName
void addBinaryStringArray(const TDatum &datum, std::vector< std::string > &string_vec)
Definition: Importer.cpp:398

+ Here is the call graph for this function:

size_t import_export::TypedImportBuffer::add_values ( const ColumnDescriptor cd,
const TColumn &  data 
)

Definition at line 948 of file Importer.cpp.

References addArray(), addStringArray(), bigint_buffer_, bool_buffer_, checked_malloc(), ColumnDescriptor::columnName, ColumnDescriptor::columnType, double_buffer_, float_buffer_, geo_string_buffer_, SQLTypeInfo::get_notnull(), SQLTypeInfo::get_subtype(), SQLTypeInfo::get_type(), inline_fixed_encoding_null_val(), int_buffer_, IS_STRING, kARRAY, kBIGINT, kBOOLEAN, kCHAR, kDATE, kDECIMAL, kDOUBLE, kFLOAT, kINT, kLINESTRING, kMULTIPOLYGON, kNUMERIC, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, NULL_DOUBLE, NULL_FLOAT, import_export::NullArray(), smallint_buffer_, string_buffer_, and tinyint_buffer_.

948  {
949  size_t dataSize = 0;
950  if (cd->columnType.get_notnull()) {
951  // We can't have any null values for this column; to have them is an error
952  if (std::any_of(col.nulls.begin(), col.nulls.end(), [](int i) { return i != 0; })) {
953  throw std::runtime_error("NULL for column " + cd->columnName);
954  }
955  }
956 
957  switch (cd->columnType.get_type()) {
958  case kBOOLEAN: {
959  dataSize = col.data.int_col.size();
960  bool_buffer_->reserve(dataSize);
961  for (size_t i = 0; i < dataSize; i++) {
962  if (col.nulls[i]) {
964  } else {
965  bool_buffer_->push_back((int8_t)col.data.int_col[i]);
966  }
967  }
968  break;
969  }
970  case kTINYINT: {
971  dataSize = col.data.int_col.size();
972  tinyint_buffer_->reserve(dataSize);
973  for (size_t i = 0; i < dataSize; i++) {
974  if (col.nulls[i]) {
976  } else {
977  tinyint_buffer_->push_back((int8_t)col.data.int_col[i]);
978  }
979  }
980  break;
981  }
982  case kSMALLINT: {
983  dataSize = col.data.int_col.size();
984  smallint_buffer_->reserve(dataSize);
985  for (size_t i = 0; i < dataSize; i++) {
986  if (col.nulls[i]) {
988  } else {
989  smallint_buffer_->push_back((int16_t)col.data.int_col[i]);
990  }
991  }
992  break;
993  }
994  case kINT: {
995  dataSize = col.data.int_col.size();
996  int_buffer_->reserve(dataSize);
997  for (size_t i = 0; i < dataSize; i++) {
998  if (col.nulls[i]) {
1000  } else {
1001  int_buffer_->push_back((int32_t)col.data.int_col[i]);
1002  }
1003  }
1004  break;
1005  }
1006  case kBIGINT:
1007  case kNUMERIC:
1008  case kDECIMAL: {
1009  dataSize = col.data.int_col.size();
1010  bigint_buffer_->reserve(dataSize);
1011  for (size_t i = 0; i < dataSize; i++) {
1012  if (col.nulls[i]) {
1014  } else {
1015  bigint_buffer_->push_back((int64_t)col.data.int_col[i]);
1016  }
1017  }
1018  break;
1019  }
1020  case kFLOAT: {
1021  dataSize = col.data.real_col.size();
1022  float_buffer_->reserve(dataSize);
1023  for (size_t i = 0; i < dataSize; i++) {
1024  if (col.nulls[i]) {
1025  float_buffer_->push_back(NULL_FLOAT);
1026  } else {
1027  float_buffer_->push_back((float)col.data.real_col[i]);
1028  }
1029  }
1030  break;
1031  }
1032  case kDOUBLE: {
1033  dataSize = col.data.real_col.size();
1034  double_buffer_->reserve(dataSize);
1035  for (size_t i = 0; i < dataSize; i++) {
1036  if (col.nulls[i]) {
1037  double_buffer_->push_back(NULL_DOUBLE);
1038  } else {
1039  double_buffer_->push_back((double)col.data.real_col[i]);
1040  }
1041  }
1042  break;
1043  }
1044  case kTEXT:
1045  case kVARCHAR:
1046  case kCHAR: {
1047  // TODO: for now, use empty string for nulls
1048  dataSize = col.data.str_col.size();
1049  string_buffer_->reserve(dataSize);
1050  for (size_t i = 0; i < dataSize; i++) {
1051  if (col.nulls[i]) {
1052  string_buffer_->push_back(std::string());
1053  } else {
1054  string_buffer_->push_back(col.data.str_col[i]);
1055  }
1056  }
1057  break;
1058  }
1059  case kTIME:
1060  case kTIMESTAMP:
1061  case kDATE: {
1062  dataSize = col.data.int_col.size();
1063  bigint_buffer_->reserve(dataSize);
1064  for (size_t i = 0; i < dataSize; i++) {
1065  if (col.nulls[i]) {
1067  } else {
1068  bigint_buffer_->push_back(static_cast<int64_t>(col.data.int_col[i]));
1069  }
1070  }
1071  break;
1072  }
1073  case kPOINT:
1074  case kLINESTRING:
1075  case kPOLYGON:
1076  case kMULTIPOLYGON: {
1077  dataSize = col.data.str_col.size();
1078  geo_string_buffer_->reserve(dataSize);
1079  for (size_t i = 0; i < dataSize; i++) {
1080  if (col.nulls[i]) {
1081  // TODO: add support for NULL geo
1082  geo_string_buffer_->push_back(std::string());
1083  } else {
1084  geo_string_buffer_->push_back(col.data.str_col[i]);
1085  }
1086  }
1087  break;
1088  }
1089  case kARRAY: {
1090  dataSize = col.data.arr_col.size();
1091  if (IS_STRING(cd->columnType.get_subtype())) {
1092  for (size_t i = 0; i < dataSize; i++) {
1093  std::vector<std::string>& string_vec = addStringArray();
1094  if (!col.nulls[i]) {
1095  size_t stringArrSize = col.data.arr_col[i].data.str_col.size();
1096  for (size_t str_idx = 0; str_idx != stringArrSize; ++str_idx) {
1097  string_vec.push_back(col.data.arr_col[i].data.str_col[str_idx]);
1098  }
1099  }
1100  }
1101  } else {
1102  auto elem_ti = cd->columnType.get_subtype();
1103  switch (elem_ti) {
1104  case kBOOLEAN: {
1105  for (size_t i = 0; i < dataSize; i++) {
1106  if (col.nulls[i]) {
1108  } else {
1109  size_t len = col.data.arr_col[i].data.int_col.size();
1110  size_t byteSize = len * sizeof(int8_t);
1111  int8_t* buf = (int8_t*)checked_malloc(len * byteSize);
1112  int8_t* p = buf;
1113  for (size_t j = 0; j < len; ++j) {
1114  *(bool*)p = static_cast<bool>(col.data.arr_col[i].data.int_col[j]);
1115  p += sizeof(bool);
1116  }
1117  addArray(ArrayDatum(byteSize, buf, false));
1118  }
1119  }
1120  break;
1121  }
1122  case kTINYINT: {
1123  for (size_t i = 0; i < dataSize; i++) {
1124  if (col.nulls[i]) {
1126  } else {
1127  size_t len = col.data.arr_col[i].data.int_col.size();
1128  size_t byteSize = len * sizeof(int8_t);
1129  int8_t* buf = (int8_t*)checked_malloc(len * byteSize);
1130  int8_t* p = buf;
1131  for (size_t j = 0; j < len; ++j) {
1132  *(int8_t*)p = static_cast<int8_t>(col.data.arr_col[i].data.int_col[j]);
1133  p += sizeof(int8_t);
1134  }
1135  addArray(ArrayDatum(byteSize, buf, false));
1136  }
1137  }
1138  break;
1139  }
1140  case kSMALLINT: {
1141  for (size_t i = 0; i < dataSize; i++) {
1142  if (col.nulls[i]) {
1144  } else {
1145  size_t len = col.data.arr_col[i].data.int_col.size();
1146  size_t byteSize = len * sizeof(int16_t);
1147  int8_t* buf = (int8_t*)checked_malloc(len * byteSize);
1148  int8_t* p = buf;
1149  for (size_t j = 0; j < len; ++j) {
1150  *(int16_t*)p =
1151  static_cast<int16_t>(col.data.arr_col[i].data.int_col[j]);
1152  p += sizeof(int16_t);
1153  }
1154  addArray(ArrayDatum(byteSize, buf, false));
1155  }
1156  }
1157  break;
1158  }
1159  case kINT: {
1160  for (size_t i = 0; i < dataSize; i++) {
1161  if (col.nulls[i]) {
1163  } else {
1164  size_t len = col.data.arr_col[i].data.int_col.size();
1165  size_t byteSize = len * sizeof(int32_t);
1166  int8_t* buf = (int8_t*)checked_malloc(len * byteSize);
1167  int8_t* p = buf;
1168  for (size_t j = 0; j < len; ++j) {
1169  *(int32_t*)p =
1170  static_cast<int32_t>(col.data.arr_col[i].data.int_col[j]);
1171  p += sizeof(int32_t);
1172  }
1173  addArray(ArrayDatum(byteSize, buf, false));
1174  }
1175  }
1176  break;
1177  }
1178  case kBIGINT:
1179  case kNUMERIC:
1180  case kDECIMAL: {
1181  for (size_t i = 0; i < dataSize; i++) {
1182  if (col.nulls[i]) {
1184  } else {
1185  size_t len = col.data.arr_col[i].data.int_col.size();
1186  size_t byteSize = len * sizeof(int64_t);
1187  int8_t* buf = (int8_t*)checked_malloc(len * byteSize);
1188  int8_t* p = buf;
1189  for (size_t j = 0; j < len; ++j) {
1190  *(int64_t*)p =
1191  static_cast<int64_t>(col.data.arr_col[i].data.int_col[j]);
1192  p += sizeof(int64_t);
1193  }
1194  addArray(ArrayDatum(byteSize, buf, false));
1195  }
1196  }
1197  break;
1198  }
1199  case kFLOAT: {
1200  for (size_t i = 0; i < dataSize; i++) {
1201  if (col.nulls[i]) {
1203  } else {
1204  size_t len = col.data.arr_col[i].data.real_col.size();
1205  size_t byteSize = len * sizeof(float);
1206  int8_t* buf = (int8_t*)checked_malloc(len * byteSize);
1207  int8_t* p = buf;
1208  for (size_t j = 0; j < len; ++j) {
1209  *(float*)p = static_cast<float>(col.data.arr_col[i].data.real_col[j]);
1210  p += sizeof(float);
1211  }
1212  addArray(ArrayDatum(byteSize, buf, false));
1213  }
1214  }
1215  break;
1216  }
1217  case kDOUBLE: {
1218  for (size_t i = 0; i < dataSize; i++) {
1219  if (col.nulls[i]) {
1221  } else {
1222  size_t len = col.data.arr_col[i].data.real_col.size();
1223  size_t byteSize = len * sizeof(double);
1224  int8_t* buf = (int8_t*)checked_malloc(len * byteSize);
1225  int8_t* p = buf;
1226  for (size_t j = 0; j < len; ++j) {
1227  *(double*)p = static_cast<double>(col.data.arr_col[i].data.real_col[j]);
1228  p += sizeof(double);
1229  }
1230  addArray(ArrayDatum(byteSize, buf, false));
1231  }
1232  }
1233  break;
1234  }
1235  case kTIME:
1236  case kTIMESTAMP:
1237  case kDATE: {
1238  for (size_t i = 0; i < dataSize; i++) {
1239  if (col.nulls[i]) {
1241  } else {
1242  size_t len = col.data.arr_col[i].data.int_col.size();
1243  size_t byteWidth = sizeof(int64_t);
1244  size_t byteSize = len * byteWidth;
1245  int8_t* buf = (int8_t*)checked_malloc(len * byteSize);
1246  int8_t* p = buf;
1247  for (size_t j = 0; j < len; ++j) {
1248  *reinterpret_cast<int64_t*>(p) =
1249  static_cast<int64_t>(col.data.arr_col[i].data.int_col[j]);
1250  p += sizeof(int64_t);
1251  }
1252  addArray(ArrayDatum(byteSize, buf, false));
1253  }
1254  }
1255  break;
1256  }
1257  default:
1258  throw std::runtime_error("Invalid Array Type");
1259  }
1260  }
1261  break;
1262  }
1263  default:
1264  throw std::runtime_error("Invalid Type");
1265  }
1266  return dataSize;
1267 }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:331
#define NULL_DOUBLE
Definition: sqltypes.h:257
Definition: sqltypes.h:51
std::vector< std::string > * string_buffer_
Definition: Importer.h:498
ArrayDatum NullArray(const SQLTypeInfo &ti)
Definition: Importer.cpp:366
std::vector< int16_t > * smallint_buffer_
Definition: Importer.h:493
std::vector< float > * float_buffer_
Definition: Importer.h:496
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:330
std::vector< double > * double_buffer_
Definition: Importer.h:497
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Definition: sqltypes.h:202
std::vector< int32_t > * int_buffer_
Definition: Importer.h:494
void * checked_malloc(const size_t size)
Definition: checked_alloc.h:44
std::vector< int64_t > * bigint_buffer_
Definition: Importer.h:495
#define NULL_FLOAT
Definition: sqltypes.h:256
std::vector< int8_t > * bool_buffer_
Definition: Importer.h:491
Definition: sqltypes.h:54
Definition: sqltypes.h:55
std::vector< std::string > & addStringArray()
Definition: Importer.h:243
void addArray(const ArrayDatum &v)
Definition: Importer.h:241
Definition: sqltypes.h:43
#define IS_STRING(T)
Definition: sqltypes.h:244
std::vector< int8_t > * tinyint_buffer_
Definition: Importer.h:492
int64_t inline_fixed_encoding_null_val(const SQL_TYPE_INFO &ti)
Definition: sqltypes.h:47
SQLTypeInfo columnType
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:337
std::string columnName
std::vector< std::string > * geo_string_buffer_
Definition: Importer.h:499

+ Here is the call graph for this function:

void import_export::TypedImportBuffer::addArray ( const ArrayDatum v)
inline

Definition at line 241 of file Importer.h.

References array_buffer_.

Referenced by add_value(), and add_values().

241 { array_buffer_->push_back(v); }
std::vector< ArrayDatum > * array_buffer_
Definition: Importer.h:500

+ Here is the caller graph for this function:

void import_export::TypedImportBuffer::addBigint ( const int64_t  v)
inline

Definition at line 231 of file Importer.h.

References bigint_buffer_.

Referenced by add_value().

231 { bigint_buffer_->push_back(v); }
std::vector< int64_t > * bigint_buffer_
Definition: Importer.h:495

+ Here is the caller graph for this function:

void import_export::TypedImportBuffer::addBoolean ( const int8_t  v)
inline

Definition at line 223 of file Importer.h.

References bool_buffer_.

Referenced by add_value().

223 { bool_buffer_->push_back(v); }
std::vector< int8_t > * bool_buffer_
Definition: Importer.h:491

+ Here is the caller graph for this function:

void import_export::TypedImportBuffer::addDictEncodedString ( const std::vector< std::string > &  string_vec)

Definition at line 469 of file Importer.cpp.

References CHECK, column_desc_, ColumnDescriptor::columnType, SQLTypeInfo::get_size(), StringDictionary::getOrAddBulk(), StringDictionary::MAX_STRLEN, string_dict_, string_dict_i16_buffer_, string_dict_i32_buffer_, and string_dict_i8_buffer_.

469  {
471  std::vector<std::string_view> string_view_vec;
472  string_view_vec.reserve(string_vec.size());
473  for (const auto& str : string_vec) {
474  if (str.size() > StringDictionary::MAX_STRLEN) {
475  throw std::runtime_error("String too long for dictionary encoding.");
476  }
477  string_view_vec.push_back(str);
478  }
479  switch (column_desc_->columnType.get_size()) {
480  case 1:
481  string_dict_i8_buffer_->resize(string_view_vec.size());
482  string_dict_->getOrAddBulk(string_view_vec, string_dict_i8_buffer_->data());
483  break;
484  case 2:
485  string_dict_i16_buffer_->resize(string_view_vec.size());
486  string_dict_->getOrAddBulk(string_view_vec, string_dict_i16_buffer_->data());
487  break;
488  case 4:
489  string_dict_i32_buffer_->resize(string_view_vec.size());
490  string_dict_->getOrAddBulk(string_view_vec, string_dict_i32_buffer_->data());
491  break;
492  default:
493  CHECK(false);
494  }
495 }
HOST DEVICE int get_size() const
Definition: sqltypes.h:340
StringDictionary * string_dict_
Definition: Importer.h:510
std::vector< uint8_t > * string_dict_i8_buffer_
Definition: Importer.h:504
void getOrAddBulk(const std::vector< String > &string_vec, T *encoded_vec)
std::vector< int32_t > * string_dict_i32_buffer_
Definition: Importer.h:506
const ColumnDescriptor * column_desc_
Definition: Importer.h:509
std::vector< uint16_t > * string_dict_i16_buffer_
Definition: Importer.h:505
#define CHECK(condition)
Definition: Logger.h:197
static constexpr size_t MAX_STRLEN
SQLTypeInfo columnType

+ Here is the call graph for this function:

void import_export::TypedImportBuffer::addDictEncodedStringArray ( const std::vector< std::vector< std::string >> &  string_array_vec)
inline

Definition at line 254 of file Importer.h.

References CHECK, checked_malloc(), StringDictionary::getOrAddBulkArray(), StringDictionary::MAX_STRLEN, string_array_dict_buffer_, and string_dict_.

255  {
257 
258  // first check data is ok
259  for (auto& p : string_array_vec) {
260  for (const auto& str : p) {
261  if (str.size() > StringDictionary::MAX_STRLEN) {
262  throw std::runtime_error("String too long for dictionary encoding.");
263  }
264  }
265  }
266 
267  std::vector<std::vector<int32_t>> ids_array(0);
268  string_dict_->getOrAddBulkArray(string_array_vec, ids_array);
269 
270  for (auto& p : ids_array) {
271  size_t len = p.size() * sizeof(int32_t);
272  auto a = static_cast<int32_t*>(checked_malloc(len));
273  memcpy(a, &p[0], len);
274  // TODO: distinguish between empty and NULL
275  string_array_dict_buffer_->push_back(
276  ArrayDatum(len, reinterpret_cast<int8_t*>(a), len == 0));
277  }
278  }
StringDictionary * string_dict_
Definition: Importer.h:510
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Definition: sqltypes.h:202
std::vector< ArrayDatum > * string_array_dict_buffer_
Definition: Importer.h:507
void * checked_malloc(const size_t size)
Definition: checked_alloc.h:44
void getOrAddBulkArray(const std::vector< std::vector< String >> &string_array_vec, std::vector< std::vector< int32_t >> &ids_array_vec)
#define CHECK(condition)
Definition: Logger.h:197
static constexpr size_t MAX_STRLEN

+ Here is the call graph for this function:

void import_export::TypedImportBuffer::addDouble ( const double  v)
inline

Definition at line 235 of file Importer.h.

References double_buffer_.

Referenced by add_value().

235 { double_buffer_->push_back(v); }
std::vector< double > * double_buffer_
Definition: Importer.h:497

+ Here is the caller graph for this function:

void import_export::TypedImportBuffer::addFloat ( const float  v)
inline

Definition at line 233 of file Importer.h.

References float_buffer_.

Referenced by add_value().

233 { float_buffer_->push_back(v); }
std::vector< float > * float_buffer_
Definition: Importer.h:496

+ Here is the caller graph for this function:

void import_export::TypedImportBuffer::addGeoString ( const std::string_view  v)
inline

Definition at line 239 of file Importer.h.

References geo_string_buffer_.

Referenced by add_value().

239 { geo_string_buffer_->emplace_back(v); }
std::vector< std::string > * geo_string_buffer_
Definition: Importer.h:499

+ Here is the caller graph for this function:

void import_export::TypedImportBuffer::addInt ( const int32_t  v)
inline

Definition at line 229 of file Importer.h.

References int_buffer_.

Referenced by add_value().

229 { int_buffer_->push_back(v); }
std::vector< int32_t > * int_buffer_
Definition: Importer.h:494

+ Here is the caller graph for this function:

void import_export::TypedImportBuffer::addSmallint ( const int16_t  v)
inline

Definition at line 227 of file Importer.h.

References smallint_buffer_.

Referenced by add_value().

227 { smallint_buffer_->push_back(v); }
std::vector< int16_t > * smallint_buffer_
Definition: Importer.h:493

+ Here is the caller graph for this function:

void import_export::TypedImportBuffer::addString ( const std::string_view  v)
inline

Definition at line 237 of file Importer.h.

References string_buffer_.

Referenced by add_value().

237 { string_buffer_->emplace_back(v); }
std::vector< std::string > * string_buffer_
Definition: Importer.h:498

+ Here is the caller graph for this function:

std::vector<std::string>& import_export::TypedImportBuffer::addStringArray ( )
inline

Definition at line 243 of file Importer.h.

References string_array_buffer_.

Referenced by add_value(), and add_values().

243  {
244  string_array_buffer_->emplace_back();
245  return string_array_buffer_->back();
246  }
std::vector< std::vector< std::string > > * string_array_buffer_
Definition: Importer.h:501

+ Here is the caller graph for this function:

void import_export::TypedImportBuffer::addStringArray ( const std::vector< std::string > &  arr)
inline

Definition at line 248 of file Importer.h.

References string_array_buffer_.

248  {
249  string_array_buffer_->push_back(arr);
250  }
std::vector< std::vector< std::string > > * string_array_buffer_
Definition: Importer.h:501
void import_export::TypedImportBuffer::addTinyint ( const int8_t  v)
inline

Definition at line 225 of file Importer.h.

References tinyint_buffer_.

Referenced by add_value().

225 { tinyint_buffer_->push_back(v); }
std::vector< int8_t > * tinyint_buffer_
Definition: Importer.h:492

+ Here is the caller graph for this function:

void import_export::TypedImportBuffer::clear ( )
inline

Definition at line 374 of file Importer.h.

References array_buffer_, bigint_buffer_, bool_buffer_, CHECK, column_desc_, ColumnDescriptor::columnType, double_buffer_, float_buffer_, geo_string_buffer_, SQLTypeInfo::get_compression(), SQLTypeInfo::get_size(), SQLTypeInfo::get_subtype(), SQLTypeInfo::get_type(), int_buffer_, IS_STRING, kARRAY, kBIGINT, kBOOLEAN, kCHAR, kDATE, kDECIMAL, kDOUBLE, kENCODING_DICT, kFLOAT, kINT, kLINESTRING, kMULTIPOLYGON, kNUMERIC, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, smallint_buffer_, string_array_buffer_, string_array_dict_buffer_, string_buffer_, string_dict_i16_buffer_, string_dict_i32_buffer_, string_dict_i8_buffer_, and tinyint_buffer_.

374  {
375  switch (column_desc_->columnType.get_type()) {
376  case kBOOLEAN: {
377  bool_buffer_->clear();
378  break;
379  }
380  case kTINYINT: {
381  tinyint_buffer_->clear();
382  break;
383  }
384  case kSMALLINT: {
385  smallint_buffer_->clear();
386  break;
387  }
388  case kINT: {
389  int_buffer_->clear();
390  break;
391  }
392  case kBIGINT:
393  case kNUMERIC:
394  case kDECIMAL: {
395  bigint_buffer_->clear();
396  break;
397  }
398  case kFLOAT: {
399  float_buffer_->clear();
400  break;
401  }
402  case kDOUBLE: {
403  double_buffer_->clear();
404  break;
405  }
406  case kTEXT:
407  case kVARCHAR:
408  case kCHAR: {
409  string_buffer_->clear();
411  switch (column_desc_->columnType.get_size()) {
412  case 1:
413  string_dict_i8_buffer_->clear();
414  break;
415  case 2:
416  string_dict_i16_buffer_->clear();
417  break;
418  case 4:
419  string_dict_i32_buffer_->clear();
420  break;
421  default:
422  CHECK(false);
423  }
424  }
425  break;
426  }
427  case kDATE:
428  case kTIME:
429  case kTIMESTAMP:
430  bigint_buffer_->clear();
431  break;
432  case kARRAY: {
434  string_array_buffer_->clear();
435  string_array_dict_buffer_->clear();
436  } else {
437  array_buffer_->clear();
438  }
439  break;
440  }
441  case kPOINT:
442  case kLINESTRING:
443  case kPOLYGON:
444  case kMULTIPOLYGON:
445  geo_string_buffer_->clear();
446  break;
447  default:
448  CHECK(false);
449  }
450  }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:331
HOST DEVICE int get_size() const
Definition: sqltypes.h:340
Definition: sqltypes.h:51
std::vector< std::string > * string_buffer_
Definition: Importer.h:498
std::vector< ArrayDatum > * array_buffer_
Definition: Importer.h:500
std::vector< int16_t > * smallint_buffer_
Definition: Importer.h:493
std::vector< float > * float_buffer_
Definition: Importer.h:496
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:330
std::vector< double > * double_buffer_
Definition: Importer.h:497
std::vector< int32_t > * int_buffer_
Definition: Importer.h:494
std::vector< ArrayDatum > * string_array_dict_buffer_
Definition: Importer.h:507
std::vector< uint8_t > * string_dict_i8_buffer_
Definition: Importer.h:504
std::vector< int64_t > * bigint_buffer_
Definition: Importer.h:495
std::vector< int8_t > * bool_buffer_
Definition: Importer.h:491
std::vector< std::vector< std::string > > * string_array_buffer_
Definition: Importer.h:501
Definition: sqltypes.h:54
Definition: sqltypes.h:55
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:338
std::vector< int32_t > * string_dict_i32_buffer_
Definition: Importer.h:506
Definition: sqltypes.h:43
#define IS_STRING(T)
Definition: sqltypes.h:244
const ColumnDescriptor * column_desc_
Definition: Importer.h:509
std::vector< uint16_t > * string_dict_i16_buffer_
Definition: Importer.h:505
std::vector< int8_t > * tinyint_buffer_
Definition: Importer.h:492
#define CHECK(condition)
Definition: Logger.h:197
Definition: sqltypes.h:47
SQLTypeInfo columnType
std::vector< std::string > * geo_string_buffer_
Definition: Importer.h:499

+ Here is the call graph for this function:

template<typename DATA_TYPE >
size_t import_export::TypedImportBuffer::convert_arrow_val_to_import_buffer ( const ColumnDescriptor cd,
const arrow::Array &  array,
std::vector< DATA_TYPE > &  buffer,
const ArraySliceRange slice_range,
BadRowsTracker *const  bad_rows_tracker 
)

Referenced by add_arrow_values().

+ Here is the caller graph for this function:

template<typename DATA_TYPE >
size_t import_export::TypedImportBuffer::convert_arrow_val_to_import_buffer ( const ColumnDescriptor cd,
const Array array,
std::vector< DATA_TYPE > &  buffer,
const ArraySliceRange slice_range,
import_export::BadRowsTracker *const  bad_rows_tracker 
)

Definition at line 762 of file Importer.cpp.

References col_idx, anonymous_namespace{ArrowImporter.h}::error_context(), geo_string_buffer_, SQLTypeInfo::get_type(), import_export::Importer::getCatalog(), Geospatial::GeoTypesFactory::getGeoColumns(), Geospatial::GeoTypesFactory::getNullGeoColumns(), import_buffers, import_export::BadRowsTracker::importer, import_export::BadRowsTracker::mutex, import_export::BadRowsTracker::rows, import_export::Importer::set_geo_physical_import_buffer(), and anonymous_namespace{ArrowImporter.h}::value_getter().

767  {
768  auto data =
769  std::make_unique<DataBuffer<DATA_TYPE>>(cd, array, buffer, bad_rows_tracker);
770  auto f_value_getter = value_getter(array, cd, bad_rows_tracker);
771  std::function<void(const int64_t)> f_add_geo_phy_cols = [&](const int64_t row) {};
772  if (bad_rows_tracker && cd->columnType.is_geometry()) {
773  f_add_geo_phy_cols = [&](const int64_t row) {
774  // Populate physical columns (ref. DBHandler::load_table)
775  std::vector<double> coords, bounds;
776  std::vector<int> ring_sizes, poly_rings;
777  int render_group = 0;
778  SQLTypeInfo ti;
779  // replace any unexpected exception from getGeoColumns or other
780  // on this path with a GeoImportException so that we wont over
781  // push a null to the logical column...
782  try {
783  SQLTypeInfo import_ti{ti};
784  if (array.IsNull(row)) {
786  import_ti, coords, bounds, ring_sizes, poly_rings, false);
787  } else {
788  arrow_throw_if<GeoImportException>(
790  ti,
791  coords,
792  bounds,
793  ring_sizes,
794  poly_rings,
795  false),
796  error_context(cd, bad_rows_tracker) + "Invalid geometry");
797  arrow_throw_if<GeoImportException>(
798  cd->columnType.get_type() != ti.get_type(),
799  error_context(cd, bad_rows_tracker) + "Geometry type mismatch");
800  }
801  auto col_idx_workpad = col_idx; // what a pitfall!!
803  bad_rows_tracker->importer->getCatalog(),
804  cd,
806  col_idx_workpad,
807  coords,
808  bounds,
809  ring_sizes,
810  poly_rings,
811  render_group);
812  } catch (GeoImportException&) {
813  throw;
814  } catch (std::runtime_error& e) {
815  throw GeoImportException(e.what());
816  } catch (const std::exception& e) {
817  throw GeoImportException(e.what());
818  } catch (...) {
819  throw GeoImportException("unknown exception");
820  }
821  };
822  }
823  auto f_mark_a_bad_row = [&](const auto row) {
824  std::unique_lock<std::mutex> lck(bad_rows_tracker->mutex);
825  bad_rows_tracker->rows.insert(row - slice_range.first);
826  };
827  buffer.reserve(slice_range.second - slice_range.first);
828  for (size_t row = slice_range.first; row < slice_range.second; ++row) {
829  try {
830  *data << (array.IsNull(row) ? nullptr : f_value_getter(array, row));
831  f_add_geo_phy_cols(row);
832  } catch (GeoImportException&) {
833  f_mark_a_bad_row(row);
834  } catch (ArrowImporterException&) {
835  // trace bad rows of each column; otherwise rethrow.
836  if (bad_rows_tracker) {
837  *data << nullptr;
838  f_mark_a_bad_row(row);
839  } else {
840  throw;
841  }
842  }
843  }
844  return buffer.size();
845 }
auto value_getter(const arrow::Array &array, const ColumnDescriptor *cd, import_export::BadRowsTracker *const bad_rows_tracker)
static void getNullGeoColumns(SQLTypeInfo &ti, std::vector< double > &coords, std::vector< double > &bounds, std::vector< int > &ring_sizes, std::vector< int > &poly_rings, const bool promote_poly_to_mpoly=false)
Definition: Types.cpp:1077
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:330
static void set_geo_physical_import_buffer(const Catalog_Namespace::Catalog &catalog, const ColumnDescriptor *cd, std::vector< std::unique_ptr< TypedImportBuffer >> &import_buffers, size_t &col_idx, std::vector< double > &coords, std::vector< double > &bounds, std::vector< int > &ring_sizes, std::vector< int > &poly_rings, int render_group, const int64_t replicate_count=0)
Definition: Importer.cpp:1420
Catalog_Namespace::Catalog & getCatalog()
Definition: Importer.h:786
std::set< int64_t > rows
Definition: Importer.h:76
std::vector< std::unique_ptr< TypedImportBuffer > > * import_buffers
Definition: Importer.h:486
static bool getGeoColumns(const std::string &wkt_or_wkb_hex, SQLTypeInfo &ti, std::vector< double > &coords, std::vector< double > &bounds, std::vector< int > &ring_sizes, std::vector< int > &poly_rings, const bool promote_poly_to_mpoly=false)
Definition: Types.cpp:870
std::string error_context(const ColumnDescriptor *cd, import_export::BadRowsTracker *const bad_rows_tracker)
Definition: ArrowImporter.h:76
std::vector< std::string > * geo_string_buffer_
Definition: Importer.h:499

+ Here is the call graph for this function:

template<typename DATA_TYPE >
auto import_export::TypedImportBuffer::del_values ( std::vector< DATA_TYPE > &  buffer,
BadRowsTracker *const  bad_rows_tracker 
)
auto import_export::TypedImportBuffer::del_values ( const SQLTypes  type,
BadRowsTracker *const  bad_rows_tracker 
)
int64_t import_export::TypedImportBuffer::get_replicate_count ( ) const
inline

Definition at line 473 of file Importer.h.

References replicate_count_.

473 { return replicate_count_; }
std::vector<ArrayDatum>* import_export::TypedImportBuffer::getArrayBuffer ( ) const
inline

Definition at line 344 of file Importer.h.

References array_buffer_.

344 { return array_buffer_; }
std::vector< ArrayDatum > * array_buffer_
Definition: Importer.h:500
int8_t* import_export::TypedImportBuffer::getAsBytes ( ) const
inline

Definition at line 286 of file Importer.h.

References column_desc_, ColumnDescriptor::columnType, SQLTypeInfo::get_type(), kBIGINT, kBOOLEAN, kDATE, kDECIMAL, kDOUBLE, kFLOAT, kINT, kNUMERIC, kSMALLINT, kTIME, kTIMESTAMP, and kTINYINT.

Referenced by import_export::anonymous_namespace{Importer.cpp}::double_value_at(), import_export::anonymous_namespace{Importer.cpp}::float_value_at(), and import_export::anonymous_namespace{Importer.cpp}::int_value_at().

286  {
287  switch (column_desc_->columnType.get_type()) {
288  case kBOOLEAN:
289  return reinterpret_cast<int8_t*>(&((*bool_buffer_)[0]));
290  case kTINYINT:
291  return reinterpret_cast<int8_t*>(&((*tinyint_buffer_)[0]));
292  case kSMALLINT:
293  return reinterpret_cast<int8_t*>(&((*smallint_buffer_)[0]));
294  case kINT:
295  return reinterpret_cast<int8_t*>(&((*int_buffer_)[0]));
296  case kBIGINT:
297  case kNUMERIC:
298  case kDECIMAL:
299  return reinterpret_cast<int8_t*>(&((*bigint_buffer_)[0]));
300  case kFLOAT:
301  return reinterpret_cast<int8_t*>(&((*float_buffer_)[0]));
302  case kDOUBLE:
303  return reinterpret_cast<int8_t*>(&((*double_buffer_)[0]));
304  case kDATE:
305  case kTIME:
306  case kTIMESTAMP:
307  return reinterpret_cast<int8_t*>(&((*bigint_buffer_)[0]));
308  default:
309  abort();
310  }
311  }
Definition: sqltypes.h:51
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:330
Definition: sqltypes.h:55
const ColumnDescriptor * column_desc_
Definition: Importer.h:509
Definition: sqltypes.h:47
SQLTypeInfo columnType

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const ColumnDescriptor* import_export::TypedImportBuffer::getColumnDesc ( ) const
inline

Definition at line 282 of file Importer.h.

References column_desc_.

282 { return column_desc_; }
const ColumnDescriptor * column_desc_
Definition: Importer.h:509
size_t import_export::TypedImportBuffer::getElementSize ( ) const
inline

Definition at line 313 of file Importer.h.

References column_desc_, ColumnDescriptor::columnType, SQLTypeInfo::get_type(), kBIGINT, kBOOLEAN, kDATE, kDECIMAL, kDOUBLE, kFLOAT, kINT, kNUMERIC, kSMALLINT, kTIME, kTIMESTAMP, and kTINYINT.

313  {
314  switch (column_desc_->columnType.get_type()) {
315  case kBOOLEAN:
316  return sizeof((*bool_buffer_)[0]);
317  case kTINYINT:
318  return sizeof((*tinyint_buffer_)[0]);
319  case kSMALLINT:
320  return sizeof((*smallint_buffer_)[0]);
321  case kINT:
322  return sizeof((*int_buffer_)[0]);
323  case kBIGINT:
324  case kNUMERIC:
325  case kDECIMAL:
326  return sizeof((*bigint_buffer_)[0]);
327  case kFLOAT:
328  return sizeof((*float_buffer_)[0]);
329  case kDOUBLE:
330  return sizeof((*double_buffer_)[0]);
331  case kDATE:
332  case kTIME:
333  case kTIMESTAMP:
334  return sizeof((*bigint_buffer_)[0]);
335  default:
336  abort();
337  }
338  }
Definition: sqltypes.h:51
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:330
Definition: sqltypes.h:55
const ColumnDescriptor * column_desc_
Definition: Importer.h:509
Definition: sqltypes.h:47
SQLTypeInfo columnType

+ Here is the call graph for this function:

std::vector<std::string>* import_export::TypedImportBuffer::getGeoStringBuffer ( ) const
inline

Definition at line 342 of file Importer.h.

References geo_string_buffer_.

342 { return geo_string_buffer_; }
std::vector< std::string > * geo_string_buffer_
Definition: Importer.h:499
std::vector<std::vector<std::string> >* import_export::TypedImportBuffer::getStringArrayBuffer ( ) const
inline

Definition at line 346 of file Importer.h.

References string_array_buffer_.

346  {
347  return string_array_buffer_;
348  }
std::vector< std::vector< std::string > > * string_array_buffer_
Definition: Importer.h:501
std::vector<ArrayDatum>* import_export::TypedImportBuffer::getStringArrayDictBuffer ( ) const
inline

Definition at line 350 of file Importer.h.

References string_array_dict_buffer_.

350  {
352  }
std::vector< ArrayDatum > * string_array_dict_buffer_
Definition: Importer.h:507
std::vector<std::string>* import_export::TypedImportBuffer::getStringBuffer ( ) const
inline

Definition at line 340 of file Importer.h.

References string_buffer_.

340 { return string_buffer_; }
std::vector< std::string > * string_buffer_
Definition: Importer.h:498
int8_t* import_export::TypedImportBuffer::getStringDictBuffer ( ) const
inline

Definition at line 354 of file Importer.h.

References column_desc_, ColumnDescriptor::columnType, and SQLTypeInfo::get_size().

Referenced by import_export::anonymous_namespace{Importer.cpp}::int_value_at().

354  {
355  switch (column_desc_->columnType.get_size()) {
356  case 1:
357  return reinterpret_cast<int8_t*>(&((*string_dict_i8_buffer_)[0]));
358  case 2:
359  return reinterpret_cast<int8_t*>(&((*string_dict_i16_buffer_)[0]));
360  case 4:
361  return reinterpret_cast<int8_t*>(&((*string_dict_i32_buffer_)[0]));
362  default:
363  abort();
364  }
365  }
HOST DEVICE int get_size() const
Definition: sqltypes.h:340
const ColumnDescriptor * column_desc_
Definition: Importer.h:509
SQLTypeInfo columnType

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

StringDictionary* import_export::TypedImportBuffer::getStringDictionary ( ) const
inline

Definition at line 284 of file Importer.h.

References string_dict_.

284 { return string_dict_; }
StringDictionary * string_dict_
Definition: Importer.h:510
const SQLTypeInfo& import_export::TypedImportBuffer::getTypeInfo ( ) const
inline

Definition at line 280 of file Importer.h.

References column_desc_, and ColumnDescriptor::columnType.

Referenced by import_export::anonymous_namespace{Importer.cpp}::double_value_at(), import_export::anonymous_namespace{Importer.cpp}::float_value_at(), and import_export::anonymous_namespace{Importer.cpp}::int_value_at().

280 { return column_desc_->columnType; }
const ColumnDescriptor * column_desc_
Definition: Importer.h:509
SQLTypeInfo columnType

+ Here is the caller graph for this function:

void import_export::TypedImportBuffer::pop_value ( )

Definition at line 702 of file Importer.cpp.

References array_buffer_, bigint_buffer_, bool_buffer_, CHECK, column_desc_, ColumnDescriptor::columnType, decimal_to_int_type(), double_buffer_, float_buffer_, geo_string_buffer_, SQLTypeInfo::get_subtype(), SQLTypeInfo::get_type(), int_buffer_, SQLTypeInfo::is_decimal(), IS_STRING, kARRAY, kBIGINT, kBOOLEAN, kCHAR, kDATE, kDOUBLE, kFLOAT, kINT, kLINESTRING, kMULTIPOLYGON, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, smallint_buffer_, string_array_buffer_, string_buffer_, tinyint_buffer_, and run_benchmark_import::type.

702  {
703  const auto type = column_desc_->columnType.is_decimal()
705  : column_desc_->columnType.get_type();
706  switch (type) {
707  case kBOOLEAN:
708  bool_buffer_->pop_back();
709  break;
710  case kTINYINT:
711  tinyint_buffer_->pop_back();
712  break;
713  case kSMALLINT:
714  smallint_buffer_->pop_back();
715  break;
716  case kINT:
717  int_buffer_->pop_back();
718  break;
719  case kBIGINT:
720  bigint_buffer_->pop_back();
721  break;
722  case kFLOAT:
723  float_buffer_->pop_back();
724  break;
725  case kDOUBLE:
726  double_buffer_->pop_back();
727  break;
728  case kTEXT:
729  case kVARCHAR:
730  case kCHAR:
731  string_buffer_->pop_back();
732  break;
733  case kDATE:
734  case kTIME:
735  case kTIMESTAMP:
736  bigint_buffer_->pop_back();
737  break;
738  case kARRAY:
740  string_array_buffer_->pop_back();
741  } else {
742  array_buffer_->pop_back();
743  }
744  break;
745  case kPOINT:
746  case kLINESTRING:
747  case kPOLYGON:
748  case kMULTIPOLYGON:
749  geo_string_buffer_->pop_back();
750  break;
751  default:
752  CHECK(false) << "TypedImportBuffer::pop_value() does not support type " << type;
753  }
754 }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:331
Definition: sqltypes.h:51
std::vector< std::string > * string_buffer_
Definition: Importer.h:498
std::vector< ArrayDatum > * array_buffer_
Definition: Importer.h:500
std::vector< int16_t > * smallint_buffer_
Definition: Importer.h:493
std::vector< float > * float_buffer_
Definition: Importer.h:496
std::vector< double > * double_buffer_
Definition: Importer.h:497
std::vector< int32_t > * int_buffer_
Definition: Importer.h:494
std::vector< int64_t > * bigint_buffer_
Definition: Importer.h:495
std::vector< int8_t > * bool_buffer_
Definition: Importer.h:491
std::vector< std::vector< std::string > > * string_array_buffer_
Definition: Importer.h:501
SQLTypes decimal_to_int_type(const SQLTypeInfo &ti)
Definition: Datum.cpp:302
Definition: sqltypes.h:54
Definition: sqltypes.h:55
Definition: sqltypes.h:43
#define IS_STRING(T)
Definition: sqltypes.h:244
const ColumnDescriptor * column_desc_
Definition: Importer.h:509
std::vector< int8_t > * tinyint_buffer_
Definition: Importer.h:492
#define CHECK(condition)
Definition: Logger.h:197
Definition: sqltypes.h:47
SQLTypeInfo columnType
bool is_decimal() const
Definition: sqltypes.h:490
std::vector< std::string > * geo_string_buffer_
Definition: Importer.h:499

+ Here is the call graph for this function:

void import_export::TypedImportBuffer::set_replicate_count ( const int64_t  replicate_count)
inline

Definition at line 474 of file Importer.h.

References replicate_count_.

Referenced by add_value().

474  {
475  replicate_count_ = replicate_count;
476  }

+ Here is the caller graph for this function:

bool import_export::TypedImportBuffer::stringDictCheckpoint ( )
inline

Definition at line 367 of file Importer.h.

References StringDictionary::checkpoint(), and string_dict_.

367  {
368  if (string_dict_ == nullptr) {
369  return true;
370  }
371  return string_dict_->checkpoint();
372  }
StringDictionary * string_dict_
Definition: Importer.h:510
bool checkpoint() noexcept

+ Here is the call graph for this function:

Member Data Documentation

union { ... }
union { ... }
std::vector<ArrayDatum>* import_export::TypedImportBuffer::array_buffer_
std::vector<int64_t>* import_export::TypedImportBuffer::bigint_buffer_
std::vector<int8_t>* import_export::TypedImportBuffer::bool_buffer_
size_t import_export::TypedImportBuffer::col_idx

Definition at line 487 of file Importer.h.

Referenced by convert_arrow_val_to_import_buffer().

const ColumnDescriptor* import_export::TypedImportBuffer::column_desc_
private
std::vector<double>* import_export::TypedImportBuffer::double_buffer_
std::vector<float>* import_export::TypedImportBuffer::float_buffer_
std::vector<std::string>* import_export::TypedImportBuffer::geo_string_buffer_
std::vector<std::unique_ptr<TypedImportBuffer> >* import_export::TypedImportBuffer::import_buffers

Definition at line 486 of file Importer.h.

Referenced by convert_arrow_val_to_import_buffer().

std::vector<int32_t>* import_export::TypedImportBuffer::int_buffer_
size_t import_export::TypedImportBuffer::replicate_count_ = 0
private

Definition at line 511 of file Importer.h.

Referenced by get_replicate_count(), and set_replicate_count().

std::vector<int16_t>* import_export::TypedImportBuffer::smallint_buffer_
std::vector<std::vector<std::string> >* import_export::TypedImportBuffer::string_array_buffer_
std::vector<ArrayDatum>* import_export::TypedImportBuffer::string_array_dict_buffer_
std::vector<std::string>* import_export::TypedImportBuffer::string_buffer_
StringDictionary* import_export::TypedImportBuffer::string_dict_
private
std::vector<uint16_t>* import_export::TypedImportBuffer::string_dict_i16_buffer_

Definition at line 505 of file Importer.h.

Referenced by addDictEncodedString(), clear(), TypedImportBuffer(), and ~TypedImportBuffer().

std::vector<int32_t>* import_export::TypedImportBuffer::string_dict_i32_buffer_

Definition at line 506 of file Importer.h.

Referenced by addDictEncodedString(), clear(), TypedImportBuffer(), and ~TypedImportBuffer().

std::vector<uint8_t>* import_export::TypedImportBuffer::string_dict_i8_buffer_

Definition at line 504 of file Importer.h.

Referenced by addDictEncodedString(), clear(), TypedImportBuffer(), and ~TypedImportBuffer().

std::vector<int8_t>* import_export::TypedImportBuffer::tinyint_buffer_

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