OmniSciDB  94e8789169
 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:312
HOST DEVICE int get_size() const
Definition: sqltypes.h:321
Definition: sqltypes.h:48
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:311
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:51
Definition: sqltypes.h:52
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:319
std::vector< int32_t > * string_dict_i32_buffer_
Definition: Importer.h:506
Definition: sqltypes.h:40
#define IS_STRING(T)
Definition: sqltypes.h:241
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:44
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:312
HOST DEVICE int get_size() const
Definition: sqltypes.h:321
Definition: sqltypes.h:48
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:311
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:51
Definition: sqltypes.h:52
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:319
std::vector< int32_t > * string_dict_i32_buffer_
Definition: Importer.h:506
Definition: sqltypes.h:40
#define IS_STRING(T)
Definition: sqltypes.h:241
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:44
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 853 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.

857  {
858  const auto type = cd->columnType.get_type();
859  if (cd->columnType.get_notnull()) {
860  // We can't have any null values for this column; to have them is an error
861  arrow_throw_if(col.null_count() > 0, "NULL not allowed for column " + cd->columnName);
862  }
863 
864  switch (type) {
865  case kBOOLEAN:
866  if (exact_type_match) {
867  arrow_throw_if(col.type_id() != Type::BOOL, "Expected boolean type");
868  }
870  cd, col, *bool_buffer_, slice_range, bad_rows_tracker);
871  case kTINYINT:
872  if (exact_type_match) {
873  arrow_throw_if(col.type_id() != Type::INT8, "Expected int8 type");
874  }
876  cd, col, *tinyint_buffer_, slice_range, bad_rows_tracker);
877  case kSMALLINT:
878  if (exact_type_match) {
879  arrow_throw_if(col.type_id() != Type::INT16, "Expected int16 type");
880  }
882  cd, col, *smallint_buffer_, slice_range, bad_rows_tracker);
883  case kINT:
884  if (exact_type_match) {
885  arrow_throw_if(col.type_id() != Type::INT32, "Expected int32 type");
886  }
888  cd, col, *int_buffer_, slice_range, bad_rows_tracker);
889  case kBIGINT:
890  case kNUMERIC:
891  case kDECIMAL:
892  if (exact_type_match) {
893  arrow_throw_if(col.type_id() != Type::INT64, "Expected int64 type");
894  }
896  cd, col, *bigint_buffer_, slice_range, bad_rows_tracker);
897  case kFLOAT:
898  if (exact_type_match) {
899  arrow_throw_if(col.type_id() != Type::FLOAT, "Expected float type");
900  }
902  cd, col, *float_buffer_, slice_range, bad_rows_tracker);
903  case kDOUBLE:
904  if (exact_type_match) {
905  arrow_throw_if(col.type_id() != Type::DOUBLE, "Expected double type");
906  }
908  cd, col, *double_buffer_, slice_range, bad_rows_tracker);
909  case kTEXT:
910  case kVARCHAR:
911  case kCHAR:
912  if (exact_type_match) {
913  arrow_throw_if(col.type_id() != Type::BINARY && col.type_id() != Type::STRING,
914  "Expected string type");
915  }
917  cd, col, *string_buffer_, slice_range, bad_rows_tracker);
918  case kTIME:
919  if (exact_type_match) {
920  arrow_throw_if(col.type_id() != Type::TIME32 && col.type_id() != Type::TIME64,
921  "Expected time32 or time64 type");
922  }
924  cd, col, *bigint_buffer_, slice_range, bad_rows_tracker);
925  case kTIMESTAMP:
926  if (exact_type_match) {
927  arrow_throw_if(col.type_id() != Type::TIMESTAMP, "Expected timestamp type");
928  }
930  cd, col, *bigint_buffer_, slice_range, bad_rows_tracker);
931  case kDATE:
932  if (exact_type_match) {
933  arrow_throw_if(col.type_id() != Type::DATE32 && col.type_id() != Type::DATE64,
934  "Expected date32 or date64 type");
935  }
937  cd, col, *bigint_buffer_, slice_range, bad_rows_tracker);
938  case kPOINT:
939  case kLINESTRING:
940  case kPOLYGON:
941  case kMULTIPOLYGON:
942  arrow_throw_if(col.type_id() != Type::BINARY && col.type_id() != Type::STRING,
943  "Expected string type");
945  cd, col, *geo_string_buffer_, slice_range, bad_rows_tracker);
946  case kARRAY:
947  throw std::runtime_error("Arrow array appends not yet supported");
948  default:
949  throw std::runtime_error("Invalid Type");
950  }
951 }
Definition: sqltypes.h:48
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:311
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:51
Definition: sqltypes.h:52
Definition: sqltypes.h:40
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:44
SQLTypeInfo columnType
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:318
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 503 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.

507  {
508  set_replicate_count(replicate_count);
509  const auto type = cd->columnType.get_type();
510  switch (type) {
511  case kBOOLEAN: {
512  if (is_null) {
513  if (cd->columnType.get_notnull()) {
514  throw std::runtime_error("NULL for column " + cd->columnName);
515  }
517  } else {
518  auto ti = cd->columnType;
519  Datum d = StringToDatum(val, ti);
520  addBoolean(static_cast<int8_t>(d.boolval));
521  }
522  break;
523  }
524  case kTINYINT: {
525  if (!is_null && (isdigit(val[0]) || val[0] == '-')) {
526  auto ti = cd->columnType;
527  Datum d = StringToDatum(val, ti);
529  } else {
530  if (cd->columnType.get_notnull()) {
531  throw std::runtime_error("NULL for column " + cd->columnName);
532  }
534  }
535  break;
536  }
537  case kSMALLINT: {
538  if (!is_null && (isdigit(val[0]) || val[0] == '-')) {
539  auto ti = cd->columnType;
540  Datum d = StringToDatum(val, ti);
542  } else {
543  if (cd->columnType.get_notnull()) {
544  throw std::runtime_error("NULL for column " + cd->columnName);
545  }
547  }
548  break;
549  }
550  case kINT: {
551  if (!is_null && (isdigit(val[0]) || val[0] == '-')) {
552  auto ti = cd->columnType;
553  Datum d = StringToDatum(val, ti);
554  addInt(d.intval);
555  } else {
556  if (cd->columnType.get_notnull()) {
557  throw std::runtime_error("NULL for column " + cd->columnName);
558  }
560  }
561  break;
562  }
563  case kBIGINT: {
564  if (!is_null && (isdigit(val[0]) || val[0] == '-')) {
565  auto ti = cd->columnType;
566  Datum d = StringToDatum(val, ti);
567  addBigint(d.bigintval);
568  } else {
569  if (cd->columnType.get_notnull()) {
570  throw std::runtime_error("NULL for column " + cd->columnName);
571  }
573  }
574  break;
575  }
576  case kDECIMAL:
577  case kNUMERIC: {
578  if (!is_null) {
579  SQLTypeInfo ti(kNUMERIC, 0, 0, false);
580  Datum d = StringToDatum(val, ti);
581  const auto converted_decimal_value =
583  addBigint(converted_decimal_value);
584  } else {
585  if (cd->columnType.get_notnull()) {
586  throw std::runtime_error("NULL for column " + cd->columnName);
587  }
589  }
590  break;
591  }
592  case kFLOAT:
593  if (!is_null && (val[0] == '.' || isdigit(val[0]) || val[0] == '-')) {
594  addFloat(static_cast<float>(std::atof(std::string(val).c_str())));
595  } else {
596  if (cd->columnType.get_notnull()) {
597  throw std::runtime_error("NULL for column " + cd->columnName);
598  }
600  }
601  break;
602  case kDOUBLE:
603  if (!is_null && (val[0] == '.' || isdigit(val[0]) || val[0] == '-')) {
604  addDouble(std::atof(std::string(val).c_str()));
605  } else {
606  if (cd->columnType.get_notnull()) {
607  throw std::runtime_error("NULL for column " + cd->columnName);
608  }
610  }
611  break;
612  case kTEXT:
613  case kVARCHAR:
614  case kCHAR: {
615  // @TODO(wei) for now, use empty string for nulls
616  if (is_null) {
617  if (cd->columnType.get_notnull()) {
618  throw std::runtime_error("NULL for column " + cd->columnName);
619  }
620  addString(std::string());
621  } else {
622  if (val.length() > StringDictionary::MAX_STRLEN) {
623  throw std::runtime_error("String too long for column " + cd->columnName +
624  " was " + std::to_string(val.length()) + " max is " +
626  }
627  addString(val);
628  }
629  break;
630  }
631  case kTIME:
632  case kTIMESTAMP:
633  case kDATE:
634  if (!is_null && (isdigit(val[0]) || val[0] == '-')) {
635  SQLTypeInfo ti = cd->columnType;
636  Datum d = StringToDatum(val, ti);
637  addBigint(d.bigintval);
638  } else {
639  if (cd->columnType.get_notnull()) {
640  throw std::runtime_error("NULL for column " + cd->columnName);
641  }
643  }
644  break;
645  case kARRAY: {
646  if (is_null && cd->columnType.get_notnull()) {
647  throw std::runtime_error("NULL for column " + cd->columnName);
648  }
649  SQLTypeInfo ti = cd->columnType;
650  if (IS_STRING(ti.get_subtype())) {
651  std::vector<std::string> string_vec;
652  // Just parse string array, don't push it to buffer yet as we might throw
654  std::string(val), copy_params, string_vec);
655  if (!is_null) {
656  // TODO: add support for NULL string arrays
657  if (ti.get_size() > 0) {
658  auto sti = ti.get_elem_type();
659  size_t expected_size = ti.get_size() / sti.get_size();
660  size_t actual_size = string_vec.size();
661  if (actual_size != expected_size) {
662  throw std::runtime_error("Fixed length array column " + cd->columnName +
663  " expects " + std::to_string(expected_size) +
664  " values, received " +
665  std::to_string(actual_size));
666  }
667  }
668  addStringArray(string_vec);
669  } else {
670  if (ti.get_size() > 0) {
671  // TODO: remove once NULL fixlen arrays are allowed
672  throw std::runtime_error("Fixed length array column " + cd->columnName +
673  " currently cannot accept NULL arrays");
674  }
675  // TODO: add support for NULL string arrays, replace with addStringArray(),
676  // for now add whatever parseStringArray() outputs for NULLs ("NULL")
677  addStringArray(string_vec);
678  }
679  } else {
680  if (!is_null) {
681  ArrayDatum d = StringToArray(std::string(val), ti, copy_params);
682  if (d.is_null) { // val could be "NULL"
683  addArray(NullArray(ti));
684  } else {
685  if (ti.get_size() > 0 && static_cast<size_t>(ti.get_size()) != d.length) {
686  throw std::runtime_error("Fixed length array for column " + cd->columnName +
687  " has incorrect length: " + std::string(val));
688  }
689  addArray(d);
690  }
691  } else {
692  addArray(NullArray(ti));
693  }
694  }
695  break;
696  }
697  case kPOINT:
698  case kLINESTRING:
699  case kPOLYGON:
700  case kMULTIPOLYGON:
701  addGeoString(val);
702  break;
703  default:
704  CHECK(false) << "TypedImportBuffer::add_value() does not support type " << type;
705  }
706 }
int8_t tinyintval
Definition: sqltypes.h:203
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:312
#define NULL_DOUBLE
HOST DEVICE int get_size() const
Definition: sqltypes.h:321
void addBigint(const int64_t v)
Definition: Importer.h:231
void addSmallint(const int16_t v)
Definition: Importer.h:227
Definition: sqltypes.h:48
#define NULL_FLOAT
void addString(const std::string_view v)
Definition: Importer.h:237
bool boolval
Definition: sqltypes.h:202
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:372
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:311
int32_t intval
Definition: sqltypes.h:205
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:199
void addGeoString(const std::string_view v)
Definition: Importer.h:239
CONSTEXPR DEVICE bool is_null(const T &value)
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:206
void addInt(const int32_t v)
Definition: Importer.h:229
int16_t smallintval
Definition: sqltypes.h:204
Datum StringToDatum(std::string_view s, SQLTypeInfo &ti)
Definition: Datum.cpp:124
Definition: sqltypes.h:51
Definition: sqltypes.h:52
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:319
int64_t convert_decimal_value_to_scale(const int64_t decimal_value, const SQLTypeInfo &type_info, const SQLTypeInfo &new_type_info)
Definition: Datum.cpp:319
void addArray(const ArrayDatum &v)
Definition: Importer.h:241
Definition: sqltypes.h:40
#define IS_STRING(T)
Definition: sqltypes.h:241
#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:44
SQLTypeInfo columnType
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:318
SQLTypeInfo get_elem_type() const
Definition: sqltypes.h:697
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 1275 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.

1278  {
1279  set_replicate_count(replicate_count);
1280  const auto type = cd->columnType.is_decimal() ? decimal_to_int_type(cd->columnType)
1281  : cd->columnType.get_type();
1282  switch (type) {
1283  case kBOOLEAN: {
1284  if (is_null) {
1285  if (cd->columnType.get_notnull()) {
1286  throw std::runtime_error("NULL for column " + cd->columnName);
1287  }
1289  } else {
1290  addBoolean((int8_t)datum.val.int_val);
1291  }
1292  break;
1293  }
1294  case kTINYINT:
1295  if (!is_null) {
1296  addTinyint((int8_t)datum.val.int_val);
1297  } else {
1298  if (cd->columnType.get_notnull()) {
1299  throw std::runtime_error("NULL for column " + cd->columnName);
1300  }
1302  }
1303  break;
1304  case kSMALLINT:
1305  if (!is_null) {
1306  addSmallint((int16_t)datum.val.int_val);
1307  } else {
1308  if (cd->columnType.get_notnull()) {
1309  throw std::runtime_error("NULL for column " + cd->columnName);
1310  }
1312  }
1313  break;
1314  case kINT:
1315  if (!is_null) {
1316  addInt((int32_t)datum.val.int_val);
1317  } else {
1318  if (cd->columnType.get_notnull()) {
1319  throw std::runtime_error("NULL for column " + cd->columnName);
1320  }
1322  }
1323  break;
1324  case kBIGINT:
1325  if (!is_null) {
1326  addBigint(datum.val.int_val);
1327  } else {
1328  if (cd->columnType.get_notnull()) {
1329  throw std::runtime_error("NULL for column " + cd->columnName);
1330  }
1332  }
1333  break;
1334  case kFLOAT:
1335  if (!is_null) {
1336  addFloat((float)datum.val.real_val);
1337  } else {
1338  if (cd->columnType.get_notnull()) {
1339  throw std::runtime_error("NULL for column " + cd->columnName);
1340  }
1342  }
1343  break;
1344  case kDOUBLE:
1345  if (!is_null) {
1346  addDouble(datum.val.real_val);
1347  } else {
1348  if (cd->columnType.get_notnull()) {
1349  throw std::runtime_error("NULL for column " + cd->columnName);
1350  }
1352  }
1353  break;
1354  case kTEXT:
1355  case kVARCHAR:
1356  case kCHAR: {
1357  // @TODO(wei) for now, use empty string for nulls
1358  if (is_null) {
1359  if (cd->columnType.get_notnull()) {
1360  throw std::runtime_error("NULL for column " + cd->columnName);
1361  }
1362  addString(std::string());
1363  } else {
1364  addString(datum.val.str_val);
1365  }
1366  break;
1367  }
1368  case kTIME:
1369  case kTIMESTAMP:
1370  case kDATE: {
1371  if (!is_null) {
1372  addBigint(datum.val.int_val);
1373  } else {
1374  if (cd->columnType.get_notnull()) {
1375  throw std::runtime_error("NULL for column " + cd->columnName);
1376  }
1378  }
1379  break;
1380  }
1381  case kARRAY:
1382  if (is_null && cd->columnType.get_notnull()) {
1383  throw std::runtime_error("NULL for column " + cd->columnName);
1384  }
1385  if (IS_STRING(cd->columnType.get_subtype())) {
1386  std::vector<std::string>& string_vec = addStringArray();
1387  addBinaryStringArray(datum, string_vec);
1388  } else {
1389  if (!is_null) {
1390  addArray(TDatumToArrayDatum(datum, cd->columnType));
1391  } else {
1393  }
1394  }
1395  break;
1396  case kPOINT:
1397  case kLINESTRING:
1398  case kPOLYGON:
1399  case kMULTIPOLYGON:
1400  if (is_null) {
1401  if (cd->columnType.get_notnull()) {
1402  throw std::runtime_error("NULL for column " + cd->columnName);
1403  }
1404  addGeoString(std::string());
1405  } else {
1406  addGeoString(datum.val.str_val);
1407  }
1408  break;
1409  default:
1410  CHECK(false) << "TypedImportBuffer::add_value() does not support type " << type;
1411  }
1412 }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:312
#define NULL_DOUBLE
void addBigint(const int64_t v)
Definition: Importer.h:231
void addSmallint(const int16_t v)
Definition: Importer.h:227
Definition: sqltypes.h:48
#define NULL_FLOAT
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:372
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:456
CONSTEXPR DEVICE bool is_null(const T &value)
void addBoolean(const int8_t v)
Definition: Importer.h:223
void addTinyint(const int8_t v)
Definition: Importer.h:225
void addInt(const int32_t v)
Definition: Importer.h:229
SQLTypes decimal_to_int_type(const SQLTypeInfo &ti)
Definition: Datum.cpp:303
Definition: sqltypes.h:51
Definition: sqltypes.h:52
std::vector< std::string > & addStringArray()
Definition: Importer.h:243
void addArray(const ArrayDatum &v)
Definition: Importer.h:241
Definition: sqltypes.h:40
#define IS_STRING(T)
Definition: sqltypes.h:241
#define CHECK(condition)
Definition: Logger.h:197
int64_t inline_fixed_encoding_null_val(const SQL_TYPE_INFO &ti)
Definition: sqltypes.h:44
SQLTypeInfo columnType
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:318
bool is_decimal() const
Definition: sqltypes.h:481
std::string columnName
void addBinaryStringArray(const TDatum &datum, std::vector< std::string > &string_vec)
Definition: Importer.cpp:404

+ Here is the call graph for this function:

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

Definition at line 954 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(), generate_TableFunctionsFactory_init::i, inline_fixed_encoding_null_val(), int_buffer_, IS_STRING, generate_TableFunctionsFactory_init::j, 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_.

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

475  {
477  std::vector<std::string_view> string_view_vec;
478  string_view_vec.reserve(string_vec.size());
479  for (const auto& str : string_vec) {
480  if (str.size() > StringDictionary::MAX_STRLEN) {
481  throw std::runtime_error("String too long for dictionary encoding.");
482  }
483  string_view_vec.push_back(str);
484  }
485  switch (column_desc_->columnType.get_size()) {
486  case 1:
487  string_dict_i8_buffer_->resize(string_view_vec.size());
488  string_dict_->getOrAddBulk(string_view_vec, string_dict_i8_buffer_->data());
489  break;
490  case 2:
491  string_dict_i16_buffer_->resize(string_view_vec.size());
492  string_dict_->getOrAddBulk(string_view_vec, string_dict_i16_buffer_->data());
493  break;
494  case 4:
495  string_dict_i32_buffer_->resize(string_view_vec.size());
496  string_dict_->getOrAddBulk(string_view_vec, string_dict_i32_buffer_->data());
497  break;
498  default:
499  CHECK(false);
500  }
501 }
HOST DEVICE int get_size() const
Definition: sqltypes.h:321
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:199
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:312
HOST DEVICE int get_size() const
Definition: sqltypes.h:321
Definition: sqltypes.h:48
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:311
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:51
Definition: sqltypes.h:52
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:319
std::vector< int32_t > * string_dict_i32_buffer_
Definition: Importer.h:506
Definition: sqltypes.h:40
#define IS_STRING(T)
Definition: sqltypes.h:241
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:44
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 768 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().

773  {
774  auto data =
775  std::make_unique<DataBuffer<DATA_TYPE>>(cd, array, buffer, bad_rows_tracker);
776  auto f_value_getter = value_getter(array, cd, bad_rows_tracker);
777  std::function<void(const int64_t)> f_add_geo_phy_cols = [&](const int64_t row) {};
778  if (bad_rows_tracker && cd->columnType.is_geometry()) {
779  f_add_geo_phy_cols = [&](const int64_t row) {
780  // Populate physical columns (ref. DBHandler::load_table)
781  std::vector<double> coords, bounds;
782  std::vector<int> ring_sizes, poly_rings;
783  int render_group = 0;
784  SQLTypeInfo ti;
785  // replace any unexpected exception from getGeoColumns or other
786  // on this path with a GeoImportException so that we wont over
787  // push a null to the logical column...
788  try {
789  SQLTypeInfo import_ti{ti};
790  if (array.IsNull(row)) {
792  import_ti, coords, bounds, ring_sizes, poly_rings, false);
793  } else {
794  arrow_throw_if<GeoImportException>(
796  ti,
797  coords,
798  bounds,
799  ring_sizes,
800  poly_rings,
801  false),
802  error_context(cd, bad_rows_tracker) + "Invalid geometry");
803  arrow_throw_if<GeoImportException>(
804  cd->columnType.get_type() != ti.get_type(),
805  error_context(cd, bad_rows_tracker) + "Geometry type mismatch");
806  }
807  auto col_idx_workpad = col_idx; // what a pitfall!!
809  bad_rows_tracker->importer->getCatalog(),
810  cd,
812  col_idx_workpad,
813  coords,
814  bounds,
815  ring_sizes,
816  poly_rings,
817  render_group);
818  } catch (GeoImportException&) {
819  throw;
820  } catch (std::runtime_error& e) {
821  throw GeoImportException(e.what());
822  } catch (const std::exception& e) {
823  throw GeoImportException(e.what());
824  } catch (...) {
825  throw GeoImportException("unknown exception");
826  }
827  };
828  }
829  auto f_mark_a_bad_row = [&](const auto row) {
830  std::unique_lock<std::mutex> lck(bad_rows_tracker->mutex);
831  bad_rows_tracker->rows.insert(row - slice_range.first);
832  };
833  buffer.reserve(slice_range.second - slice_range.first);
834  for (size_t row = slice_range.first; row < slice_range.second; ++row) {
835  try {
836  *data << (array.IsNull(row) ? nullptr : f_value_getter(array, row));
837  f_add_geo_phy_cols(row);
838  } catch (GeoImportException&) {
839  f_mark_a_bad_row(row);
840  } catch (ArrowImporterException&) {
841  // trace bad rows of each column; otherwise rethrow.
842  if (bad_rows_tracker) {
843  *data << nullptr;
844  f_mark_a_bad_row(row);
845  } else {
846  throw;
847  }
848  }
849  }
850  return buffer.size();
851 }
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:1114
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:311
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:1434
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:907
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:48
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:311
Definition: sqltypes.h:52
const ColumnDescriptor * column_desc_
Definition: Importer.h:509
Definition: sqltypes.h:44
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:48
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:311
Definition: sqltypes.h:52
const ColumnDescriptor * column_desc_
Definition: Importer.h:509
Definition: sqltypes.h:44
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:321
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 708 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.

708  {
709  const auto type = column_desc_->columnType.is_decimal()
711  : column_desc_->columnType.get_type();
712  switch (type) {
713  case kBOOLEAN:
714  bool_buffer_->pop_back();
715  break;
716  case kTINYINT:
717  tinyint_buffer_->pop_back();
718  break;
719  case kSMALLINT:
720  smallint_buffer_->pop_back();
721  break;
722  case kINT:
723  int_buffer_->pop_back();
724  break;
725  case kBIGINT:
726  bigint_buffer_->pop_back();
727  break;
728  case kFLOAT:
729  float_buffer_->pop_back();
730  break;
731  case kDOUBLE:
732  double_buffer_->pop_back();
733  break;
734  case kTEXT:
735  case kVARCHAR:
736  case kCHAR:
737  string_buffer_->pop_back();
738  break;
739  case kDATE:
740  case kTIME:
741  case kTIMESTAMP:
742  bigint_buffer_->pop_back();
743  break;
744  case kARRAY:
746  string_array_buffer_->pop_back();
747  } else {
748  array_buffer_->pop_back();
749  }
750  break;
751  case kPOINT:
752  case kLINESTRING:
753  case kPOLYGON:
754  case kMULTIPOLYGON:
755  geo_string_buffer_->pop_back();
756  break;
757  default:
758  CHECK(false) << "TypedImportBuffer::pop_value() does not support type " << type;
759  }
760 }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:312
Definition: sqltypes.h:48
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:303
Definition: sqltypes.h:51
Definition: sqltypes.h:52
Definition: sqltypes.h:40
#define IS_STRING(T)
Definition: sqltypes.h:241
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:44
SQLTypeInfo columnType
bool is_decimal() const
Definition: sqltypes.h:481
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: