OmniSciDB  c0231cc57d
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TargetValueConvertersImpl.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef TARGET_VALUE_CONVERTERS_IMPL_H_
18 #define TARGET_VALUE_CONVERTERS_IMPL_H_
19 
21 #include "Geospatial/Compression.h"
23 #include "Shared/checked_alloc.h"
26 
27 #include <atomic>
28 #include <future>
29 #include <thread>
30 
31 template <typename T>
33  if (std::is_floating_point<T>::value) {
34  return static_cast<T>(inline_fp_null_array_value<T>());
35  } else {
36  return static_cast<T>(inline_int_null_array_value<T>());
37  }
38 }
39 
40 template <typename SOURCE_TYPE, typename RETURN_TYPE, typename CHECKED_CAST_TYPE>
41 RETURN_TYPE checked_cast(SOURCE_TYPE val, bool check_null, RETURN_TYPE null_value) {
42  if (!std::is_same<SOURCE_TYPE, CHECKED_CAST_TYPE>::value) {
43  // do an overflow check
44  try {
45  CHECKED_CAST_TYPE castedVal = boost::numeric_cast<CHECKED_CAST_TYPE>(val);
46  if (check_null && castedVal == null_value) {
47  throw std::runtime_error("Overflow or underflow");
48  }
49  } catch (...) {
50  throw std::runtime_error("Overflow or underflow");
51  }
52  }
53 
54  return static_cast<RETURN_TYPE>(val);
55 }
56 
57 template <typename SOURCE_TYPE, typename TARGET_TYPE>
59  using ColumnDataPtr = std::unique_ptr<TARGET_TYPE, CheckedMallocDeleter<TARGET_TYPE>>;
61  using CasterFunc = std::function<TARGET_TYPE(SOURCE_TYPE, bool, TARGET_TYPE)>;
62 
64  TARGET_TYPE null_value_;
65  SOURCE_TYPE null_check_value_;
69 
71 
73  size_t num_rows,
74  TARGET_TYPE nullValue,
75  SOURCE_TYPE nullCheckValue,
76  bool doNullCheck)
78  , null_value_(nullValue)
79  , null_check_value_(nullCheckValue)
80  , do_null_check_(doNullCheck) {
81  fixed_array_null_value_ = get_fixed_array_null_value<TARGET_TYPE>();
82  if (num_rows) {
83  allocateColumnarData(num_rows);
84  }
85  }
86 
87  ~NumericValueConverter() override {}
88 
89  void setValueCaster(CasterFunc caster) { checked_caster_ = caster; }
90 
91  void populateFixedArrayNullSentinel(size_t num_rows) {
92  allocateColumnarData(num_rows);
95  }
96 
97  void allocateColumnarData(size_t num_rows) override {
98  CHECK(num_rows > 0);
100  reinterpret_cast<TARGET_TYPE*>(checked_malloc(num_rows * sizeof(TARGET_TYPE))));
101  }
102 
104  CHECK(num_rows > 0);
106  reinterpret_cast<TARGET_TYPE*>(checked_malloc(num_rows * sizeof(TARGET_TYPE))));
107  }
108 
110  size_t row,
111  typename ElementsBufferColumnPtr::pointer columnData,
112  const ScalarTargetValue* scalarValue) {
113  auto db_p = checked_get<SOURCE_TYPE>(row, scalarValue, SOURCE_TYPE_ACCESSOR);
114  auto val = *db_p;
115 
116  if (do_null_check_ && null_check_value_ == val) {
117  columnData[row] = null_value_;
118  } else {
119  if (checked_caster_) {
120  columnData[row] = checked_caster_(val, do_null_check_, null_value_);
121  } else {
122  columnData[row] = static_cast<TARGET_TYPE>(val);
123  }
124  }
125  }
126 
127  void convertToColumnarFormat(size_t row, const ScalarTargetValue* scalarValue) {
128  convertElementToColumnarFormat(row, column_data_.get(), scalarValue);
129  }
130 
131  void convertToColumnarFormat(size_t row, const TargetValue* value) override {
132  auto scalarValue =
133  checked_get<ScalarTargetValue>(row, value, SCALAR_TARGET_VALUE_ACCESSOR);
134  convertToColumnarFormat(row, scalarValue);
135  }
136 
138  std::unique_ptr<std::vector<std::pair<size_t, ElementsBufferColumnPtr>>>&
139  array_buffer,
140  std::unique_ptr<std::vector<ArrayDatum>>::pointer arrayData) {
141  for (size_t row = 0; row < array_buffer->size(); row++) {
142  auto& element = (array_buffer->at(row));
143  bool is_null = false;
144  if (element.second) {
145  ColumnDataPtr& data = element.second;
146  int8_t* arrayDataPtr = reinterpret_cast<int8_t*>(data.release());
147  (*arrayData)[row] =
148  ArrayDatum(element.first * sizeof(TARGET_TYPE), arrayDataPtr, is_null);
149  }
150  }
151  }
152 
154  DataBlockPtr dataBlock;
155  dataBlock.numbersPtr = reinterpret_cast<int8_t*>(column_data_.get());
156  insertData.data.push_back(dataBlock);
157  insertData.columnIds.push_back(column_descriptor_->columnId);
158  }
159 };
160 
161 template <typename TARGET_TYPE>
162 struct DictionaryValueConverter : public NumericValueConverter<int64_t, TARGET_TYPE> {
163  using ElementsDataColumnPtr =
165 
166  using ElementsBufferColumnPtr = std::unique_ptr<std::vector<int32_t>>;
167 
169 
172 
174 
175  const int32_t buffer_null_sentinal_ = std::numeric_limits<int32_t>::min();
176 
178 
179  std::unordered_map<int32_t, int32_t> literals_lookup_;
181 
183  int32_t sourceDictId,
184  const ColumnDescriptor* targetDescriptor,
185  size_t num_rows,
186  TARGET_TYPE nullValue,
187  int64_t nullCheckValue,
188  bool doNullCheck,
189  StringDictionaryProxy* literals_dict,
190  StringDictionaryProxy* source_dict_proxy)
191  : NumericValueConverter<int64_t, TARGET_TYPE>(targetDescriptor,
192  num_rows,
193  nullValue,
194  nullCheckValue,
195  doNullCheck) {
196  literals_dict_ = literals_dict;
198  cat.getMetadataForDict(targetDescriptor->columnType.get_comp_param(), true);
199 
200  source_dict_desc_ = nullptr;
201  source_dict_proxy_ = source_dict_proxy;
202 
203  use_literals_ = 0 == sourceDictId;
204  if (!use_literals_) {
205  source_dict_desc_ = cat.getMetadataForDict(std::abs(sourceDictId), true);
207  } else {
208  if (literals_dict) {
209  auto const& transient_vecmap = literals_dict->getTransientVector();
210  for (unsigned index = 0; index < transient_vecmap.size(); ++index) {
211  auto const old_id = StringDictionaryProxy::transientIndexToId(index);
212  std::string const& str = *transient_vecmap[index];
213  auto const new_id = target_dict_desc_->stringDict->getOrAdd(str);
214  literals_lookup_[old_id] = new_id;
215  }
216  }
217 
219  }
220 
222 
223  if (num_rows) {
225  }
226  }
227 
229 
231  CHECK(num_rows > 0);
232  return std::make_unique<std::vector<int32_t>>(num_rows);
233  }
234 
236  size_t row,
237  typename ElementsBufferColumnPtr::pointer columnBuffer,
238  const ScalarTargetValue* scalarValue) {
239  auto db_p = checked_get<int64_t>(row, scalarValue, this->SOURCE_TYPE_ACCESSOR);
240  auto val = *db_p;
241 
242  if (this->do_null_check_ && this->null_check_value_ == val) {
243  (*columnBuffer)[row] = this->buffer_null_sentinal_;
244  } else {
245  (*columnBuffer)[row] = (int32_t)val;
246  }
247  }
248 
249  void convertToColumnarFormat(size_t row, const ScalarTargetValue* scalarValue) {
250  convertElementToColumnarFormat(row, this->column_buffer_.get(), scalarValue);
251  }
252 
253  void convertToColumnarFormat(size_t row, const TargetValue* value) override {
254  auto scalarValue =
255  checked_get<ScalarTargetValue>(row, value, this->SCALAR_TARGET_VALUE_ACCESSOR);
256 
257  convertToColumnarFormat(row, scalarValue);
258  }
259 
260  inline int32_t convertTransientStringIdToPermanentId(int32_t& transient_string_id) {
261  if (source_dict_proxy_) {
262  auto str = source_dict_proxy_->getString(transient_string_id);
263  return source_dict_proxy_->getOrAdd(str);
264  } else {
265  throw std::runtime_error("Unexpected negative source ID");
266  }
267  }
268 
270  ElementsBufferColumnPtr buffer) {
273  reinterpret_cast<TARGET_TYPE*>(
274  checked_malloc(buffer->size() * sizeof(TARGET_TYPE))));
275 
276  std::vector<int32_t>* bufferPtr =
277  reinterpret_cast<std::vector<int32_t>*>(buffer.get());
278  TARGET_TYPE* columnDataPtr = reinterpret_cast<TARGET_TYPE*>(data.get());
279  if (use_literals_) {
280  for (size_t i = 0; i < bufferPtr->size(); i++) {
281  auto id = literals_lookup_[(*bufferPtr)[i]];
282  if (id == buffer_null_sentinal_) {
283  columnDataPtr[i] = this->null_value_;
284  } else {
285  columnDataPtr[i] = static_cast<TARGET_TYPE>(id);
286  }
287  }
288  } else {
290  // special case, where source and target dict are the same
291  // mostly in update
292  for (size_t i = 0; i < bufferPtr->size(); i++) {
293  auto src_id = (*bufferPtr)[i];
294  if (src_id == buffer_null_sentinal_) {
295  columnDataPtr[i] = this->null_value_;
296  } else if (src_id < 0) {
297  columnDataPtr[i] = convertTransientStringIdToPermanentId(src_id);
298  } else {
299  columnDataPtr[i] = static_cast<TARGET_TYPE>(src_id);
300  }
301  }
302 
303  } else {
304  std::vector<int32_t> dest_ids;
305  dest_ids.resize(bufferPtr->size());
306 
307  if (source_dict_proxy_) {
310  *bufferPtr,
313  } else {
316  *bufferPtr,
318  }
319 
320  // fixup NULL sentinel
321  for (size_t i = 0; i < dest_ids.size(); i++) {
322  auto id = dest_ids[i];
323  if (id == buffer_null_sentinal_) {
324  columnDataPtr[i] = this->null_value_;
325  } else {
326  if (std::is_signed<TARGET_TYPE>::value) {
327  if (id < 0) {
328  throw std::runtime_error(
329  "Maximum number of unique strings (" +
330  std::to_string(std::numeric_limits<TARGET_TYPE>::max()) +
331  ") reached in target dictionary");
332  }
333  } else {
334  if (id >= std::numeric_limits<TARGET_TYPE>::max()) {
335  throw std::runtime_error(
336  "Maximum number of unique strings (" +
337  std::to_string(std::numeric_limits<TARGET_TYPE>::max()) +
338  ") reached in target column's dict encoding");
339  }
340  }
341  columnDataPtr[i] = static_cast<TARGET_TYPE>(id);
342  }
343  }
344  }
345  }
346 
347  return data;
348  }
349 
351  std::unique_ptr<std::vector<std::pair<size_t, ElementsBufferColumnPtr>>>&
352  array_buffer,
353  std::unique_ptr<std::vector<ArrayDatum>>::pointer arrayData) {
354  if (use_literals_) {
355  for (size_t row = 0; row < array_buffer->size(); row++) {
356  auto& element = (array_buffer->at(row));
357  bool is_null = false;
358  if (element.second) {
360  processBuffer(std::move(element.second));
361  int8_t* arrayDataPtr = reinterpret_cast<int8_t*>(data.release());
362  (*arrayData)[row] =
363  ArrayDatum(element.first * sizeof(TARGET_TYPE), arrayDataPtr, is_null);
364  }
365  }
366  } else {
367  std::vector<std::vector<int32_t>> srcArrayIds(array_buffer->size());
368  std::vector<std::vector<int32_t>> destArrayIds(0);
369 
370  for (size_t row = 0; row < array_buffer->size(); row++) {
371  auto& element = (array_buffer->at(row));
372  if (element.second) {
373  srcArrayIds[row] = *(element.second.get());
374  }
375  }
376 
379  srcArrayIds,
381 
382  for (size_t row = 0; row < array_buffer->size(); row++) {
383  auto& element = (array_buffer->at(row));
384  bool is_null = false;
385  if (element.second) {
386  *(element.second.get()) = destArrayIds[row];
387  int8_t* arrayDataPtr = reinterpret_cast<int8_t*>(&(element.second->at(0)));
388  (*arrayData)[row] = ArrayDatum(element.first * sizeof(TARGET_TYPE),
389  arrayDataPtr,
390  is_null,
391  DoNothingDeleter());
392  }
393  }
394  }
395  }
396 
398  if (column_buffer_) {
399  this->column_data_ = processBuffer(std::move(column_buffer_));
400  column_buffer_ = nullptr;
401  }
402  }
403 
406  DataBlockPtr dataBlock;
407  dataBlock.numbersPtr = reinterpret_cast<int8_t*>(this->column_data_.get());
408  insertData.data.push_back(dataBlock);
409  insertData.columnIds.push_back(this->column_descriptor_->columnId);
410  }
411 };
412 
414  std::unique_ptr<std::vector<std::string>> column_data_;
415 
417 
421 
423  const ColumnDescriptor* cd,
424  size_t num_rows,
425  bool dictEncoded,
426  int32_t sourceDictId,
427  StringDictionaryProxy* literals_dict)
428  : TargetValueConverter(cd) {
429  source_dict_ = nullptr;
430  literals_source_dict_ = nullptr;
431  dict_encoded_ = dictEncoded;
432  if (dictEncoded) {
433  if (0 != sourceDictId) {
434  auto source_dict_desc = cat.getMetadataForDict(std::abs(sourceDictId), true);
435  CHECK(source_dict_desc);
436  source_dict_ = source_dict_desc->stringDict.get();
438  } else {
439  literals_source_dict_ = literals_dict;
440  }
441  }
442  if (num_rows) {
443  allocateColumnarData(num_rows);
444  }
445  }
446 
447  ~StringValueConverter() override {}
448 
449  void allocateColumnarData(size_t num_rows) override {
450  CHECK(num_rows > 0);
451  column_data_ = std::make_unique<std::vector<std::string>>(num_rows);
452  }
453 
454  void convertToColumnarFormatFromDict(size_t row, const TargetValue* value) {
455  auto scalarValue =
456  checked_get<ScalarTargetValue>(row, value, SCALAR_TARGET_VALUE_ACCESSOR);
457  auto db_p = checked_get<int64_t>(row, scalarValue, this->SOURCE_TYPE_ACCESSOR);
458  auto val = *db_p;
459 
460  if (std::numeric_limits<int32_t>::min() == val) {
461  (*column_data_)[row] = std::string("");
462  } else {
463  if (source_dict_) {
464  std::string strVal = source_dict_->getString(val);
465  (*column_data_)[row] = strVal;
466  } else if (literals_source_dict_) {
467  std::string strVal = literals_source_dict_->getString(val);
468  (*column_data_)[row] = strVal;
469  } else {
470  CHECK_EQ(val, inline_int_null_value<int32_t>());
471  std::string nullStr = "";
472  (*column_data_)[row] = nullStr;
473  }
474  }
475  }
476 
477  void convertToColumnarFormatFromString(size_t row, const TargetValue* value) {
478  auto scalarValue =
479  checked_get<ScalarTargetValue>(row, value, SCALAR_TARGET_VALUE_ACCESSOR);
480  auto db_p = checked_get<NullableString>(row, scalarValue, NULLABLE_STRING_ACCESSOR);
481  const auto db_str_p = checked_get<std::string>(row, db_p, STRING_ACCESSOR);
482 
483  if (nullptr != db_str_p) {
484  (*column_data_)[row] = *db_str_p;
485  } else {
486  (*column_data_)[row] = std::string("");
487  }
488  }
489 
490  void convertToColumnarFormat(size_t row, const TargetValue* value) override {
491  if (dict_encoded_) {
493  } else {
495  }
496  }
497 
499  DataBlockPtr dataBlock;
500  dataBlock.stringsPtr = column_data_.get();
501  insertData.data.push_back(dataBlock);
502  insertData.columnIds.push_back(column_descriptor_->columnId);
503  }
504 };
505 
506 template <typename ELEMENT_CONVERTER>
508  std::unique_ptr<
509  std::vector<std::pair<size_t, typename ELEMENT_CONVERTER::ElementsBufferColumnPtr>>>
511  std::unique_ptr<std::vector<ArrayDatum>> column_data_;
512  std::unique_ptr<ELEMENT_CONVERTER> element_converter_;
515  bool data_finalized_ = false;
519 
521 
523  size_t num_rows,
524  std::unique_ptr<ELEMENT_CONVERTER> element_converter,
525  bool do_check_null)
527  , element_converter_(std::move(element_converter))
528  , element_type_info_(cd->columnType.get_elem_type())
529  , do_check_null_(do_check_null) {
530  if (num_rows) {
531  allocateColumnarData(num_rows);
532  }
533 
534  if (cd->columnType.get_size() > 0) {
537  fixed_array_size_ / sizeof(ELEMENT_CONVERTER::fixed_array_null_value_);
538  element_converter_->populateFixedArrayNullSentinel(fixed_array_elements_count_);
540  reinterpret_cast<int8_t*>(element_converter_->column_data_.get());
541  } else {
542  fixed_array_size_ = 0;
544  fixed_array_null_sentinel_ = nullptr;
545  }
546  }
547 
548  ~ArrayValueConverter() override {}
549 
550  void allocateColumnarData(size_t num_rows) override {
551  CHECK(num_rows > 0);
552  column_data_ = std::make_unique<std::vector<ArrayDatum>>(num_rows);
553  column_buffer_ = std::make_unique<std::vector<
554  std::pair<size_t, typename ELEMENT_CONVERTER::ElementsBufferColumnPtr>>>(
555  num_rows);
556  }
557 
558  void convertToColumnarFormat(size_t row, const TargetValue* value) override {
559  const auto arrayValue =
560  checked_get<ArrayTargetValue>(row, value, ARRAY_VALUE_ACCESSOR);
561  CHECK(arrayValue);
562  if (arrayValue->is_initialized()) {
563  const auto& vec = arrayValue->get();
564  bool is_null = false;
565 
567  if (fixed_array_elements_count_ != vec.size()) {
568  throw std::runtime_error(
569  "Incorrect number of array elements for fixed length array column");
570  }
571  }
572 
573  if (vec.size()) {
574  typename ELEMENT_CONVERTER::ElementsBufferColumnPtr elementBuffer =
575  element_converter_->allocateColumnarBuffer(vec.size());
576 
577  int elementIndex = 0;
578  for (const auto& scalarValue : vec) {
579  element_converter_->convertElementToColumnarFormat(
580  elementIndex++, elementBuffer.get(), &scalarValue);
581  }
582 
583  column_buffer_->at(row) = {vec.size(), std::move(elementBuffer)};
584 
585  } else {
586  // Empty, not NULL
587  (*column_data_)[row] = ArrayDatum(0, nullptr, is_null, DoNothingDeleter());
588  }
589  } else {
590  if (!do_check_null_) {
591  throw std::runtime_error("NULL assignment of non null column not allowed");
592  }
593 
594  bool is_null = true; // do_check_null_;
595  (*column_data_)[row] = ArrayDatum(
597  (*column_data_)[row].is_null = is_null;
598  }
599  }
600 
602  if (!data_finalized_) {
603  element_converter_->processArrayBuffer(column_buffer_, column_data_.get());
604  data_finalized_ = true;
605  }
606  }
607 
610  DataBlockPtr dataBlock;
611  dataBlock.arraysPtr = column_data_.get();
612  insertData.data.push_back(dataBlock);
613  insertData.columnIds.push_back(column_descriptor_->columnId);
614  }
615 };
616 
619 
620  std::unique_ptr<std::vector<std::string>> column_data_;
621  std::unique_ptr<std::vector<ArrayDatum>> signed_compressed_coords_data_;
622 
624  size_t num_rows,
625  const ColumnDescriptor* logicalColumnDescriptor)
626  : TargetValueConverter(logicalColumnDescriptor) {
630 
631  if (num_rows) {
632  allocateColumnarData(num_rows);
633  }
634  }
635 
637 
638  void allocateColumnarData(size_t num_rows) override {
639  CHECK(num_rows > 0);
640  column_data_ = std::make_unique<std::vector<std::string>>(num_rows);
641  signed_compressed_coords_data_ = std::make_unique<std::vector<ArrayDatum>>(num_rows);
642  }
643 
646 
648  const std::shared_ptr<std::vector<double>>& coords) {
649  const auto compressed_coords_vector =
651 
652  uint8_t* compressed_coords_array = reinterpret_cast<uint8_t*>(
653  checked_malloc(sizeof(uint8_t) * compressed_coords_vector.size()));
654  memcpy(compressed_coords_array,
655  &compressed_coords_vector[0],
656  compressed_coords_vector.size());
657 
658  return ArrayDatum((int)compressed_coords_vector.size(),
659  reinterpret_cast<int8_t*>(compressed_coords_array),
660  false);
661  }
662 
663  void convertToColumnarFormat(size_t row, const TargetValue* value) override {
664  const auto geoValue = checked_get<GeoTargetValue>(row, value, GEO_VALUE_ACCESSOR);
665  CHECK(geoValue);
666  if (geoValue->is_initialized()) {
667  const auto geo = geoValue->get();
668  const auto geoPoint =
669  checked_get<GeoPointTargetValue>(row, &geo, GEO_POINT_VALUE_ACCESSOR);
670  CHECK(geoPoint);
671  (*column_data_)[row] = "";
672  (*signed_compressed_coords_data_)[row] = toCompressedCoords(geoPoint->coords);
673  } else {
674  // NULL point
675  (*column_data_)[row] = "";
676  auto coords = std::make_shared<std::vector<double>>();
677  coords->push_back(NULL_ARRAY_DOUBLE);
678  coords->push_back(NULL_DOUBLE);
679  auto coords_datum = toCompressedCoords(coords);
680  coords_datum.is_null = true;
681  (*signed_compressed_coords_data_)[row] = coords_datum;
682  }
683  }
684 
686  DataBlockPtr logical, coords;
687 
688  logical.stringsPtr = column_data_.get();
690 
691  insertData.data.emplace_back(logical);
692  insertData.columnIds.emplace_back(column_descriptor_->columnId);
693 
694  insertData.data.emplace_back(coords);
695  insertData.columnIds.emplace_back(coords_column_descriptor_->columnId);
696  }
697 };
698 
699 inline std::vector<double> compute_bounds_of_coords(
700  const std::shared_ptr<std::vector<double>>& coords) {
701  std::vector<double> bounds(4);
702  constexpr auto DOUBLE_MAX = std::numeric_limits<double>::max();
703  constexpr auto DOUBLE_MIN = std::numeric_limits<double>::lowest();
704  bounds[0] = DOUBLE_MAX;
705  bounds[1] = DOUBLE_MAX;
706  bounds[2] = DOUBLE_MIN;
707  bounds[3] = DOUBLE_MIN;
708  auto size_coords = coords->size();
709 
710  for (size_t i = 0; i < size_coords; i += 2) {
711  double x = (*coords)[i];
712  double y = (*coords)[i + 1];
713 
714  bounds[0] = std::min(bounds[0], x);
715  bounds[1] = std::min(bounds[1], y);
716  bounds[2] = std::max(bounds[2], x);
717  bounds[3] = std::max(bounds[3], y);
718  }
719  return bounds;
720 }
721 
722 template <typename ELEM_TYPE>
723 inline ArrayDatum to_array_datum(const std::vector<ELEM_TYPE>& vector) {
724  ELEM_TYPE* array =
725  reinterpret_cast<ELEM_TYPE*>(checked_malloc(sizeof(ELEM_TYPE) * vector.size()));
726  memcpy(array, vector.data(), vector.size() * sizeof(ELEM_TYPE));
727 
728  return ArrayDatum(
729  (int)(vector.size() * sizeof(ELEM_TYPE)), reinterpret_cast<int8_t*>(array), false);
730 }
731 
732 template <typename ELEM_TYPE>
733 inline ArrayDatum to_array_datum(const std::shared_ptr<std::vector<ELEM_TYPE>>& vector) {
734  return to_array_datum(*vector.get());
735 }
736 
739 
740  std::unique_ptr<std::vector<ArrayDatum>> bounds_data_;
741 
743  size_t num_rows,
744  const ColumnDescriptor* logicalColumnDescriptor)
745  : GeoPointValueConverter(cat, num_rows, logicalColumnDescriptor) {
749 
750  if (num_rows) {
751  allocateColumnarData(num_rows);
752  }
753  }
754 
756 
757  void allocateColumnarData(size_t num_rows) override {
758  CHECK(num_rows > 0);
760  bounds_data_ = std::make_unique<std::vector<ArrayDatum>>(num_rows);
761  }
762 
764 
765  void convertToColumnarFormat(size_t row, const TargetValue* value) override {
766  const auto geoValue =
767  checked_get<GeoTargetValue>(row, value, GEO_TARGET_VALUE_ACCESSOR);
768  CHECK(geoValue);
769  if (geoValue->is_initialized()) {
770  const auto geo = geoValue->get();
771  const auto geoMultiPoint =
772  checked_get<GeoMultiPointTargetValue>(row, &geo, GEO_MULTIPOINT_VALUE_ACCESSOR);
773 
774  (*column_data_)[row] = "";
775  (*signed_compressed_coords_data_)[row] = toCompressedCoords(geoMultiPoint->coords);
776  auto bounds = compute_bounds_of_coords(geoMultiPoint->coords);
777  (*bounds_data_)[row] = to_array_datum(bounds);
778  } else {
779  // NULL MultiPoint
780  (*column_data_)[row] = "";
781  (*signed_compressed_coords_data_)[row] = ArrayDatum(0, nullptr, true);
782  std::vector<double> bounds = {
783  NULL_ARRAY_DOUBLE, NULL_DOUBLE, NULL_DOUBLE, NULL_DOUBLE};
784  auto bounds_datum = to_array_datum(bounds);
785  bounds_datum.is_null = true;
786  (*bounds_data_)[row] = bounds_datum;
787  }
788  }
789 
792 
793  DataBlockPtr bounds;
794 
795  bounds.arraysPtr = bounds_data_.get();
796 
797  insertData.data.emplace_back(bounds);
798  insertData.columnIds.emplace_back(bounds_column_descriptor_->columnId);
799  }
800 };
801 
804 
805  std::unique_ptr<std::vector<ArrayDatum>> bounds_data_;
806 
808  size_t num_rows,
809  const ColumnDescriptor* logicalColumnDescriptor)
810  : GeoPointValueConverter(cat, num_rows, logicalColumnDescriptor) {
814 
815  if (num_rows) {
816  allocateColumnarData(num_rows);
817  }
818  }
819 
821 
822  void allocateColumnarData(size_t num_rows) override {
823  CHECK(num_rows > 0);
825  bounds_data_ = std::make_unique<std::vector<ArrayDatum>>(num_rows);
826  }
827 
829 
830  void convertToColumnarFormat(size_t row, const TargetValue* value) override {
831  const auto geoValue =
832  checked_get<GeoTargetValue>(row, value, GEO_TARGET_VALUE_ACCESSOR);
833  CHECK(geoValue);
834  if (geoValue->is_initialized()) {
835  const auto geo = geoValue->get();
836  const auto geoLinestring =
837  checked_get<GeoLineStringTargetValue>(row, &geo, GEO_LINESTRING_VALUE_ACCESSOR);
838 
839  (*column_data_)[row] = "";
840  (*signed_compressed_coords_data_)[row] = toCompressedCoords(geoLinestring->coords);
841  auto bounds = compute_bounds_of_coords(geoLinestring->coords);
842  (*bounds_data_)[row] = to_array_datum(bounds);
843  } else {
844  // NULL Linestring
845  (*column_data_)[row] = "";
846  (*signed_compressed_coords_data_)[row] = ArrayDatum(0, nullptr, true);
847  std::vector<double> bounds = {
848  NULL_ARRAY_DOUBLE, NULL_DOUBLE, NULL_DOUBLE, NULL_DOUBLE};
849  auto bounds_datum = to_array_datum(bounds);
850  bounds_datum.is_null = true;
851  (*bounds_data_)[row] = bounds_datum;
852  }
853  }
854 
857 
858  DataBlockPtr bounds;
859 
860  bounds.arraysPtr = bounds_data_.get();
861 
862  insertData.data.emplace_back(bounds);
863  insertData.columnIds.emplace_back(bounds_column_descriptor_->columnId);
864  }
865 };
866 
870 
871  std::unique_ptr<std::vector<ArrayDatum>> linestring_sizes_data_;
872  std::unique_ptr<std::vector<ArrayDatum>> bounds_data_;
873 
875  size_t num_rows,
876  const ColumnDescriptor* logicalColumnDescriptor)
877  : GeoPointValueConverter(cat, num_rows, logicalColumnDescriptor) {
884 
885  if (num_rows) {
886  allocateColumnarData(num_rows);
887  }
888  }
889 
891 
892  void allocateColumnarData(size_t num_rows) override {
893  CHECK(num_rows > 0);
895  linestring_sizes_data_ = std::make_unique<std::vector<ArrayDatum>>(num_rows);
896  bounds_data_ = std::make_unique<std::vector<ArrayDatum>>(num_rows);
897  }
898 
901 
902  void convertToColumnarFormat(size_t row, const TargetValue* value) override {
903  const auto geoValue =
904  checked_get<GeoTargetValue>(row, value, GEO_TARGET_VALUE_ACCESSOR);
905  CHECK(geoValue);
906  if (geoValue->is_initialized()) {
907  const auto geo = geoValue->get();
908  const auto geoMultiLinestring = checked_get<GeoMultiLineStringTargetValue>(
910 
911  (*column_data_)[row] = "";
912  (*signed_compressed_coords_data_)[row] =
913  toCompressedCoords(geoMultiLinestring->coords);
914  (*linestring_sizes_data_)[row] =
915  to_array_datum(geoMultiLinestring->linestring_sizes);
916  auto bounds = compute_bounds_of_coords(geoMultiLinestring->coords);
917  (*bounds_data_)[row] = to_array_datum(bounds);
918  } else {
919  // NULL MultiLinestring
920  (*column_data_)[row] = "";
921  (*signed_compressed_coords_data_)[row] = ArrayDatum(0, nullptr, true);
922  (*linestring_sizes_data_)[row] = ArrayDatum(0, nullptr, true);
923  std::vector<double> bounds = {
924  NULL_ARRAY_DOUBLE, NULL_DOUBLE, NULL_DOUBLE, NULL_DOUBLE};
925  auto bounds_datum = to_array_datum(bounds);
926  bounds_datum.is_null = true;
927  (*bounds_data_)[row] = bounds_datum;
928  }
929  }
930 
933 
934  DataBlockPtr linestringSizes, bounds;
935 
936  linestringSizes.arraysPtr = linestring_sizes_data_.get();
937  bounds.arraysPtr = bounds_data_.get();
938 
939  insertData.data.emplace_back(linestringSizes);
940  insertData.columnIds.emplace_back(linestring_sizes_column_descriptor_->columnId);
941 
942  insertData.data.emplace_back(bounds);
943  insertData.columnIds.emplace_back(bounds_column_descriptor_->columnId);
944  }
945 };
946 
948  protected:
950  const int column_id)
951  : render_group_analyzer_{nullptr} {
952  if (render_group_analyzer_map) {
953  // NOTE: this is not thread safe
954  auto itr = render_group_analyzer_map->try_emplace(column_id).first;
955  render_group_analyzer_ = &itr->second;
956  }
957  }
958 
960 };
961 
967 
968  std::unique_ptr<std::vector<ArrayDatum>> ring_sizes_data_;
969  std::unique_ptr<std::vector<ArrayDatum>> bounds_data_;
970  std::unique_ptr<int32_t[]> render_group_data_;
971 
973  size_t num_rows,
974  const ColumnDescriptor* logicalColumnDescriptor,
975  RenderGroupAnalyzerMap* render_group_analyzer_map)
976  : GeoPointValueConverter(cat, num_rows, logicalColumnDescriptor)
977  , GeoPolygonRenderGroupManager(render_group_analyzer_map,
978  logicalColumnDescriptor->columnId) {
988 
989  if (num_rows) {
990  allocateColumnarData(num_rows);
991  }
992  }
993 
995 
996  void allocateColumnarData(size_t num_rows) override {
998  ring_sizes_data_ = std::make_unique<std::vector<ArrayDatum>>(num_rows);
999  bounds_data_ = std::make_unique<std::vector<ArrayDatum>>(num_rows);
1000  render_group_data_ = std::make_unique<int32_t[]>(num_rows);
1001  }
1002 
1004 
1005  void convertToColumnarFormat(size_t row, const TargetValue* value) override {
1006  const auto geoValue =
1007  checked_get<GeoTargetValue>(row, value, GEO_TARGET_VALUE_ACCESSOR);
1008  CHECK(geoValue);
1009  if (geoValue->is_initialized()) {
1010  const auto geo = geoValue->get();
1011  const auto geoPoly =
1012  checked_get<GeoPolyTargetValue>(row, &geo, GEO_POLY_VALUE_ACCESSOR);
1013 
1014  (*column_data_)[row] = "";
1015  (*signed_compressed_coords_data_)[row] = toCompressedCoords(geoPoly->coords);
1016  (*ring_sizes_data_)[row] = to_array_datum(geoPoly->ring_sizes);
1017  auto bounds = compute_bounds_of_coords(geoPoly->coords);
1018  (*bounds_data_)[row] = to_array_datum(bounds);
1019  if (render_group_analyzer_) {
1020  render_group_data_[row] =
1022  } else {
1023  render_group_data_[row] = 0;
1024  }
1025  } else {
1026  // NULL Polygon
1027  (*column_data_)[row] = "";
1028  (*signed_compressed_coords_data_)[row] = ArrayDatum(0, nullptr, true);
1029  (*ring_sizes_data_)[row] = ArrayDatum(0, nullptr, true);
1030  std::vector<double> bounds = {
1031  NULL_ARRAY_DOUBLE, NULL_DOUBLE, NULL_DOUBLE, NULL_DOUBLE};
1032  auto bounds_datum = to_array_datum(bounds);
1033  bounds_datum.is_null = true;
1034  (*bounds_data_)[row] = bounds_datum;
1036  }
1037  }
1038 
1041 
1042  DataBlockPtr ringSizes, bounds, renderGroup;
1043 
1044  ringSizes.arraysPtr = ring_sizes_data_.get();
1045  bounds.arraysPtr = bounds_data_.get();
1046  renderGroup.numbersPtr = reinterpret_cast<int8_t*>(render_group_data_.get());
1047 
1048  insertData.data.emplace_back(ringSizes);
1049  insertData.columnIds.emplace_back(ring_sizes_column_descriptor_->columnId);
1050 
1051  insertData.data.emplace_back(bounds);
1052  insertData.columnIds.emplace_back(bounds_column_descriptor_->columnId);
1053 
1054  insertData.data.emplace_back(renderGroup);
1055  insertData.columnIds.emplace_back(render_group_column_descriptor_->columnId);
1056  }
1057 };
1058 
1065 
1066  std::unique_ptr<std::vector<ArrayDatum>> ring_sizes_data_;
1067  std::unique_ptr<std::vector<ArrayDatum>> poly_rings_data_;
1068  std::unique_ptr<std::vector<ArrayDatum>> bounds_data_;
1069  std::unique_ptr<int32_t[]> render_group_data_;
1070 
1072  size_t num_rows,
1073  const ColumnDescriptor* logicalColumnDescriptor,
1074  RenderGroupAnalyzerMap* render_group_analyzer_map)
1075  : GeoPointValueConverter(cat, num_rows, logicalColumnDescriptor)
1076  , GeoPolygonRenderGroupManager(render_group_analyzer_map,
1077  logicalColumnDescriptor->columnId) {
1090 
1091  if (num_rows) {
1092  allocateColumnarData(num_rows);
1093  }
1094  }
1095 
1097 
1098  void allocateColumnarData(size_t num_rows) override {
1100  ring_sizes_data_ = std::make_unique<std::vector<ArrayDatum>>(num_rows);
1101  poly_rings_data_ = std::make_unique<std::vector<ArrayDatum>>(num_rows);
1102  bounds_data_ = std::make_unique<std::vector<ArrayDatum>>(num_rows);
1103  render_group_data_ = std::make_unique<int32_t[]>(num_rows);
1104  }
1105 
1107 
1108  void convertToColumnarFormat(size_t row, const TargetValue* value) override {
1109  const auto geoValue =
1110  checked_get<GeoTargetValue>(row, value, GEO_TARGET_VALUE_ACCESSOR);
1111  CHECK(geoValue);
1112  if (geoValue->is_initialized()) {
1113  const auto geo = geoValue->get();
1114  const auto geoMultiPoly =
1115  checked_get<GeoMultiPolyTargetValue>(row, &geo, GEO_MULTI_POLY_VALUE_ACCESSOR);
1116 
1117  (*column_data_)[row] = "";
1118  (*signed_compressed_coords_data_)[row] = toCompressedCoords(geoMultiPoly->coords);
1119  (*ring_sizes_data_)[row] = to_array_datum(geoMultiPoly->ring_sizes);
1120  (*poly_rings_data_)[row] = to_array_datum(geoMultiPoly->poly_rings);
1121  auto bounds = compute_bounds_of_coords(geoMultiPoly->coords);
1122  (*bounds_data_)[row] = to_array_datum(bounds);
1123  if (render_group_analyzer_) {
1124  render_group_data_[row] =
1126  } else {
1127  render_group_data_[row] = 0;
1128  }
1129  } else {
1130  // NULL MultiPolygon
1131  (*column_data_)[row] = "";
1132  (*signed_compressed_coords_data_)[row] = ArrayDatum(0, nullptr, true);
1133  (*ring_sizes_data_)[row] = ArrayDatum(0, nullptr, true);
1134  (*poly_rings_data_)[row] = ArrayDatum(0, nullptr, true);
1135  std::vector<double> bounds = {
1136  NULL_ARRAY_DOUBLE, NULL_DOUBLE, NULL_DOUBLE, NULL_DOUBLE};
1137  auto bounds_datum = to_array_datum(bounds);
1138  bounds_datum.is_null = true;
1139  (*bounds_data_)[row] = bounds_datum;
1141  }
1142  }
1143 
1146 
1147  DataBlockPtr ringSizes, polyRings, bounds, renderGroup;
1148 
1149  ringSizes.arraysPtr = ring_sizes_data_.get();
1150  polyRings.arraysPtr = poly_rings_data_.get();
1151  bounds.arraysPtr = bounds_data_.get();
1152  renderGroup.numbersPtr = reinterpret_cast<int8_t*>(render_group_data_.get());
1153 
1154  insertData.data.emplace_back(ringSizes);
1155  insertData.columnIds.emplace_back(ring_sizes_column_descriptor_->columnId);
1156 
1157  insertData.data.emplace_back(polyRings);
1158  insertData.columnIds.emplace_back(ring_sizes_solumn_descriptor_->columnId);
1159 
1160  insertData.data.emplace_back(bounds);
1161  insertData.columnIds.emplace_back(bounds_column_descriptor_->columnId);
1162 
1163  insertData.data.emplace_back(renderGroup);
1164  insertData.columnIds.emplace_back(render_group_column_descriptor_->columnId);
1165  }
1166 };
1167 
1168 #endif
std::unique_ptr< std::vector< ArrayDatum > > ring_sizes_data_
ArrayDatum to_array_datum(const std::vector< ELEM_TYPE > &vector)
std::unique_ptr< std::vector< ArrayDatum > > bounds_data_
std::unique_ptr< TARGET_TYPE, CheckedMallocDeleter< TARGET_TYPE >> ColumnDataPtr
std::unique_ptr< std::vector< int32_t >> ElementsBufferColumnPtr
StringDictionaryProxy * literals_source_dict_
#define CHECK_EQ(x, y)
Definition: Logger.h:230
void convertToColumnarFormatFromDict(size_t row, const TargetValue *value)
void allocateColumnarData(size_t num_rows) override
std::unique_ptr< std::vector< ArrayDatum > > bounds_data_
#define NULL_DOUBLE
HOST DEVICE int get_size() const
Definition: sqltypes.h:414
const std::vector< std::string const * > & getTransientVector() const
std::string cat(Ts &&...args)
void addDataBlocksToInsertData(Fragmenter_Namespace::InsertData &insertData) override
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:132
std::vector< std::string > * stringsPtr
Definition: sqltypes.h:247
const ColumnDescriptor * ring_sizes_solumn_descriptor_
import_export::RenderGroupAnalyzer * render_group_analyzer_
std::vector< ArrayDatum > * arraysPtr
Definition: sqltypes.h:248
std::unique_ptr< int32_t[]> render_group_data_
constexpr auto DOUBLE_MAX
Definition: Types.cpp:40
void allocateColumnarData(size_t num_rows) override
void processArrayBuffer(std::unique_ptr< std::vector< std::pair< size_t, ElementsBufferColumnPtr >>> &array_buffer, std::unique_ptr< std::vector< ArrayDatum >>::pointer arrayData)
boost_variant_accessor< int64_t > SOURCE_TYPE_ACCESSOR
const ColumnDescriptor * bounds_column_descriptor_
ArrayValueConverter(const ColumnDescriptor *cd, size_t num_rows, std::unique_ptr< ELEMENT_CONVERTER > element_converter, bool do_check_null)
void populateFixedArrayNullSentinel(size_t num_rows)
const DictDescriptor * source_dict_desc_
const ColumnDescriptor * bounds_column_descriptor_
const ColumnDescriptor * linestring_sizes_column_descriptor_
void convertToColumnarFormat(size_t row, const TargetValue *value) override
void convertToColumnarFormat(size_t row, const ScalarTargetValue *scalarValue)
void convertToColumnarFormat(size_t row, const TargetValue *value) override
std::unique_ptr< std::vector< ArrayDatum > > bounds_data_
void allocateColumnarData(size_t num_rows) override
const ColumnDescriptor * column_descriptor_
std::string getString(int32_t string_id) const
ArrayDatum toCompressedCoords(const std::shared_ptr< std::vector< double >> &coords)
ElementsBufferColumnPtr column_buffer_
std::vector< double > compute_bounds_of_coords(const std::shared_ptr< std::vector< double >> &coords)
std::unique_ptr< std::vector< ArrayDatum > > poly_rings_data_
static void populate_string_ids(std::vector< int32_t > &dest_ids, StringDictionary *dest_dict, const std::vector< int32_t > &source_ids, const StringDictionary *source_dict, const std::vector< std::string const * > &transient_string_vec={})
Populates provided dest_ids vector with string ids corresponding to given source strings.
void processArrayBuffer(std::unique_ptr< std::vector< std::pair< size_t, ElementsBufferColumnPtr >>> &array_buffer, std::unique_ptr< std::vector< ArrayDatum >>::pointer arrayData)
std::function< TARGET_TYPE(int64_t, bool, TARGET_TYPE)> CasterFunc
const ColumnDescriptor * bounds_column_descriptor_
ElementsBufferColumnPtr allocateColumnarBuffer(size_t num_rows)
void convertElementToColumnarFormat(size_t row, typename ElementsBufferColumnPtr::pointer columnData, const ScalarTargetValue *scalarValue)
std::string to_string(char const *&&v)
const DictDescriptor * target_dict_desc_
void addDataBlocksToInsertData(Fragmenter_Namespace::InsertData &insertData) override
void addDataBlocksToInsertData(Fragmenter_Namespace::InsertData &insertData) override
const StringDictionaryProxy * literals_dict_
#define NULL_INT
void convertToColumnarFormat(size_t row, const ScalarTargetValue *scalarValue)
void allocateColumnarData(size_t num_rows) override
std::shared_ptr< StringDictionary > stringDict
boost_variant_accessor< GeoMultiPointTargetValue > GEO_MULTIPOINT_VALUE_ACCESSOR
boost_variant_accessor< ScalarTargetValue > SCALAR_TARGET_VALUE_ACCESSOR
boost_variant_accessor< GeoLineStringTargetValue > GEO_LINESTRING_VALUE_ACCESSOR
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Definition: sqltypes.h:228
GeoPointValueConverter(const Catalog_Namespace::Catalog &cat, size_t num_rows, const ColumnDescriptor *logicalColumnDescriptor)
std::vector< uint8_t > compress_coords(const std::vector< double > &coords, const SQLTypeInfo &ti)
Definition: Compression.cpp:52
boost_variant_accessor< NullableString > NULLABLE_STRING_ACCESSOR
std::unique_ptr< std::vector< std::string > > column_data_
CONSTEXPR DEVICE bool is_null(const T &value)
void addDataBlocksToInsertData(Fragmenter_Namespace::InsertData &insertData) override
void convertToColumnarFormatFromString(size_t row, const TargetValue *value)
void * checked_malloc(const size_t size)
Definition: checked_alloc.h:45
boost_variant_accessor< GeoMultiPolyTargetValue > GEO_MULTI_POLY_VALUE_ACCESSOR
const ColumnDescriptor * bounds_column_descriptor_
boost_variant_accessor< GeoPolyTargetValue > GEO_POLY_VALUE_ACCESSOR
boost_variant_accessor< std::string > STRING_ACCESSOR
const ColumnDescriptor * ring_sizes_column_descriptor_
std::unique_ptr< std::vector< ArrayDatum > > ring_sizes_data_
void finalizeDataBlocksForInsertData() override
GeoLinestringValueConverter(const Catalog_Namespace::Catalog &cat, size_t num_rows, const ColumnDescriptor *logicalColumnDescriptor)
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
static int32_t transientIndexToId(unsigned const index)
std::unique_ptr< std::vector< ArrayDatum > > linestring_sizes_data_
GeoMultiPointValueConverter(const Catalog_Namespace::Catalog &cat, size_t num_rows, const ColumnDescriptor *logicalColumnDescriptor)
const DictDescriptor * getMetadataForDict(int dict_ref, bool loadDict=true) const
Definition: Catalog.cpp:1960
specifies the content in-memory of a row in the column metadata table
GeoPolygonRenderGroupManager(RenderGroupAnalyzerMap *render_group_analyzer_map, const int column_id)
void addDataBlocksToInsertData(Fragmenter_Namespace::InsertData &insertData) override
void convertToColumnarFormat(size_t row, const TargetValue *value) override
Global bool for controlling render group assignment, remove along with legacy poly rendering...
std::unique_ptr< ELEMENT_CONVERTER > element_converter_
T get_fixed_array_null_value()
void convertToColumnarFormat(size_t row, const TargetValue *value) override
std::unique_ptr< int32_t[]> render_group_data_
StringValueConverter(const Catalog_Namespace::Catalog &cat, const ColumnDescriptor *cd, size_t num_rows, bool dictEncoded, int32_t sourceDictId, StringDictionaryProxy *literals_dict)
void finalizeDataBlocksForInsertData() override
void addDataBlocksToInsertData(Fragmenter_Namespace::InsertData &insertData) override
void setValueCaster(CasterFunc caster)
std::vector< DataBlockPtr > data
the number of rows being inserted
Definition: Fragmenter.h:73
int32_t getOrAdd(const std::string &str) noexcept
boost_variant_accessor< GeoMultiLineStringTargetValue > GEO_MULTILINESTRING_VALUE_ACCESSOR
void allocateColumnarData(size_t num_rows) override
int32_t convertTransientStringIdToPermanentId(int32_t &transient_string_id)
void convertToColumnarFormat(size_t row, const TargetValue *value) override
std::unique_ptr< std::vector< std::string > > column_data_
const ColumnDescriptor * render_group_column_descriptor_
typename NumericValueConverter< int64_t, TARGET_TYPE >::ColumnDataPtr ElementsDataColumnPtr
std::unordered_map< int32_t, int32_t > literals_lookup_
RETURN_TYPE checked_cast(SOURCE_TYPE val, bool check_null, RETURN_TYPE null_value)
const ColumnDescriptor * coords_column_descriptor_
void allocateColumnarData(size_t num_rows) override
std::string getString(int32_t string_id) const
GeoMultiPolygonValueConverter(const Catalog_Namespace::Catalog &cat, size_t num_rows, const ColumnDescriptor *logicalColumnDescriptor, RenderGroupAnalyzerMap *render_group_analyzer_map)
constexpr auto DOUBLE_MIN
Definition: Types.cpp:41
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:413
std::unique_ptr< std::vector< ArrayDatum > > bounds_data_
void allocateColumnarData(size_t num_rows) override
boost_variant_accessor< GeoTargetValue > GEO_VALUE_ACCESSOR
#define NULL_ARRAY_DOUBLE
const ColumnDescriptor * render_group_column_descriptor_
void addDataBlocksToInsertData(Fragmenter_Namespace::InsertData &insertData) override
static void populate_string_array_ids(std::vector< std::vector< int32_t >> &dest_array_ids, StringDictionary *dest_dict, const std::vector< std::vector< int32_t >> &source_array_ids, const StringDictionary *source_dict)
#define CHECK(condition)
Definition: Logger.h:222
NumericValueConverter< int64_t, TARGET_TYPE >::ColumnDataPtr processBuffer(ElementsBufferColumnPtr buffer)
std::unique_ptr< std::vector< std::pair< size_t, typename ELEMENT_CONVERTER::ElementsBufferColumnPtr > > > column_buffer_
boost_variant_accessor< GeoTargetValue > GEO_TARGET_VALUE_ACCESSOR
GeoMultiLinestringValueConverter(const Catalog_Namespace::Catalog &cat, size_t num_rows, const ColumnDescriptor *logicalColumnDescriptor)
Descriptor for a dictionary for a string columne.
const ColumnDescriptor * bounds_column_descriptor_
void convertToColumnarFormat(size_t row, const TargetValue *value) override
void convertToColumnarFormat(size_t row, const TargetValue *value) override
The data to be inserted using the fragment manager.
Definition: Fragmenter.h:68
std::map< int, import_export::RenderGroupAnalyzer > RenderGroupAnalyzerMap
boost::variant< ScalarTargetValue, ArrayTargetValue, GeoTargetValue, GeoTargetValuePtr > TargetValue
Definition: TargetValue.h:195
std::unique_ptr< std::vector< ArrayDatum > > column_data_
SQLTypeInfo columnType
void convertElementToColumnarFormat(size_t row, typename ElementsBufferColumnPtr::pointer columnBuffer, const ScalarTargetValue *scalarValue)
void allocateColumnarData(size_t num_rows) override
void allocateColumnarData(size_t num_rows) override
void convertToColumnarFormat(size_t row, const TargetValue *value) override
int8_t * numbersPtr
Definition: sqltypes.h:246
ElementsBufferColumnPtr allocateColumnarBuffer(size_t num_rows)
void convertToColumnarFormat(size_t row, const TargetValue *value) override
std::unique_ptr< std::vector< ArrayDatum > > bounds_data_
boost_variant_accessor< ArrayTargetValue > ARRAY_VALUE_ACCESSOR
void convertToColumnarFormat(size_t row, const TargetValue *value) override
boost_variant_accessor< GeoPointTargetValue > GEO_POINT_VALUE_ACCESSOR
const ColumnDescriptor * ring_sizes_column_descriptor_
boost_variant_accessor< SOURCE_TYPE > SOURCE_TYPE_ACCESSOR
std::vector< int > columnIds
identifies the table into which the data is being inserted
Definition: Fragmenter.h:71
void addDataBlocksToInsertData(Fragmenter_Namespace::InsertData &insertData) override
GeoPolygonValueConverter(const Catalog_Namespace::Catalog &cat, size_t num_rows, const ColumnDescriptor *logicalColumnDescriptor, RenderGroupAnalyzerMap *render_group_analyzer_map)
void addDataBlocksToInsertData(Fragmenter_Namespace::InsertData &insertData) override
int insertBoundsAndReturnRenderGroup(const std::vector< double > &bounds)
std::unique_ptr< std::vector< ArrayDatum > > signed_compressed_coords_data_
void addDataBlocksToInsertData(Fragmenter_Namespace::InsertData &insertData) override
StringDictionaryProxy * source_dict_proxy_
NumericValueConverter(const ColumnDescriptor *cd, size_t num_rows, TARGET_TYPE nullValue, SOURCE_TYPE nullCheckValue, bool doNullCheck)
DictionaryValueConverter(const Catalog_Namespace::Catalog &cat, int32_t sourceDictId, const ColumnDescriptor *targetDescriptor, size_t num_rows, TARGET_TYPE nullValue, int64_t nullCheckValue, bool doNullCheck, StringDictionaryProxy *literals_dict, StringDictionaryProxy *source_dict_proxy)
boost::variant< int64_t, double, float, NullableString > ScalarTargetValue
Definition: TargetValue.h:180