OmniSciDB  a987f07e93
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
foreign_storage::GeospatialEncoder Class Reference

#include <GeospatialEncoder.h>

+ Inheritance diagram for foreign_storage::GeospatialEncoder:
+ Collaboration diagram for foreign_storage::GeospatialEncoder:

Public Member Functions

virtual ~GeospatialEncoder ()=default
 
 GeospatialEncoder (const RenderGroupAnalyzerMap *render_group_analyzer_map)
 
 GeospatialEncoder (std::list< Chunk_NS::Chunk > &chunks, const RenderGroupAnalyzerMap *render_group_analyzer_map)
 
 GeospatialEncoder (std::list< Chunk_NS::Chunk > &chunks, std::list< std::unique_ptr< ChunkMetadata >> &chunk_metadata, const RenderGroupAnalyzerMap *render_group_analyzer_map)
 

Protected Types

enum  GeoColumnType {
  COORDS, BOUNDS, RING_OR_LINE_SIZES, POLY_RINGS,
  RENDER_GROUP
}
 

Protected Member Functions

void appendBaseAndRenderGroupDataAndUpdateMetadata (const int64_t row_count)
 
void validateChunksSizing (std::list< Chunk_NS::Chunk > &chunks) const
 
void validateMetadataSizing (std::list< std::unique_ptr< ChunkMetadata >> &chunk_metadata) const
 
void appendArrayDatumsToBufferAndUpdateMetadata ()
 
void appendToArrayEncoderAndUpdateMetadata (const std::vector< ArrayDatum > &datum_parse_buffer, Encoder *encoder, ChunkMetadata *chunk_metadata) const
 
void processGeoElement (std::string_view geo_string_view)
 
void processNullGeoElement ()
 
void clearParseBuffers ()
 
void clearDatumBuffers ()
 
template<typename T >
std::list< T >::iterator getIteratorForGeoColumnType (std::list< T > &list, const SQLTypes column_type, const GeoColumnType geo_column)
 
std::tuple< Encoder
*, ChunkMetadata *, const
ColumnDescriptor * > 
initEncoderAndGetEncoderAndMetadata (std::list< Chunk_NS::Chunk > &chunks, std::list< std::unique_ptr< ChunkMetadata >> &chunk_metadata, const SQLTypes sql_type, GeoColumnType geo_column_type)
 
const ColumnDescriptorgetColumnDescriptor (std::list< Chunk_NS::Chunk > &chunks, const SQLTypes sql_type, GeoColumnType geo_column_type)
 
bool hasBoundsColumn () const
 
bool hasRingOrLineSizesColumn () const
 
bool hasRenderGroupColumn () const
 
bool hasPolyRingsColumn () const
 

Static Protected Member Functions

static void throwMalformedGeoElement (const std::string &omnisci_column_name)
 
static void throwMismatchedGeoElement (const std::string &omnisci_column_name)
 

Protected Attributes

const ColumnDescriptorgeo_column_descriptor_
 
StringNoneEncoderbase_column_encoder_
 
Encodercoords_column_encoder_
 
Encoderbounds_column_encoder_
 
Encoderring_or_line_sizes_column_encoder_
 
Encoderpoly_rings_column_encoder_
 
Encoderrender_group_column_encoder_
 
ChunkMetadatabase_column_metadata_
 
ChunkMetadatacoords_column_metadata_
 
ChunkMetadatabounds_column_metadata_
 
ChunkMetadataring_or_line_sizes_column_metadata_
 
ChunkMetadatapoly_rings_column_metadata_
 
ChunkMetadatarender_group_column_metadata_
 
const ColumnDescriptorcoords_column_descriptor_
 
const ColumnDescriptorbounds_column_descriptor_
 
const ColumnDescriptorring_or_line_sizes_column_descriptor_
 
const ColumnDescriptorpoly_rings_column_descriptor_
 
const ColumnDescriptorrender_group_column_descriptor_
 
std::vector< std::string > base_values_
 
std::vector< double > coords_parse_buffer_
 
std::vector< double > bounds_parse_buffer_
 
std::vector< int > ring_or_line_sizes_parse_buffer_
 
std::vector< int > poly_rings_parse_buffer_
 
std::vector< ArrayDatumcoords_datum_buffer_
 
std::vector< ArrayDatumbounds_datum_buffer_
 
std::vector< ArrayDatumring_or_line_sizes_datum_buffer_
 
std::vector< ArrayDatumpoly_rings_datum_buffer_
 
std::vector< int32_t > render_group_value_buffer_
 
const RenderGroupAnalyzerMaprender_group_analyzer_map_
 

Static Protected Attributes

static constexpr bool PROMOTE_POLYGON_TO_MULTIPOLYGON = true
 

Detailed Description

Definition at line 40 of file GeospatialEncoder.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

virtual foreign_storage::GeospatialEncoder::~GeospatialEncoder ( )
virtualdefault
foreign_storage::GeospatialEncoder::GeospatialEncoder ( const RenderGroupAnalyzerMap render_group_analyzer_map)
inline

Definition at line 44 of file GeospatialEncoder.h.

45  : render_group_analyzer_map_{render_group_analyzer_map} {}
const RenderGroupAnalyzerMap * render_group_analyzer_map_
foreign_storage::GeospatialEncoder::GeospatialEncoder ( std::list< Chunk_NS::Chunk > &  chunks,
const RenderGroupAnalyzerMap render_group_analyzer_map 
)
inline

Definition at line 47 of file GeospatialEncoder.h.

49  : geo_column_descriptor_(chunks.begin()->getColumnDesc())
50  , base_column_encoder_(nullptr)
51  , coords_column_encoder_(nullptr)
52  , bounds_column_encoder_(nullptr)
56  , base_column_metadata_(nullptr)
57  , coords_column_metadata_(nullptr)
58  , bounds_column_metadata_(nullptr)
62  , render_group_analyzer_map_{render_group_analyzer_map} {
64  validateChunksSizing(chunks);
65  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
66 
67  // initialize coords column
68  coords_column_descriptor_ = getColumnDescriptor(chunks, geo_column_type, COORDS);
69 
70  // initialize bounds column
71  if (hasBoundsColumn()) {
72  bounds_column_descriptor_ = getColumnDescriptor(chunks, geo_column_type, BOUNDS);
73  }
74 
75  // initialize ring sizes column & render group column
78  getColumnDescriptor(chunks, geo_column_type, RING_OR_LINE_SIZES);
79  }
80  if (hasRenderGroupColumn()) {
82  getColumnDescriptor(chunks, geo_column_type, RENDER_GROUP);
83  }
84 
85  // initialize poly rings column
86  if (hasPolyRingsColumn()) {
88  getColumnDescriptor(chunks, geo_column_type, POLY_RINGS);
89  }
90  }
const ColumnDescriptor * poly_rings_column_descriptor_
const ColumnDescriptor * render_group_column_descriptor_
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380
void validateChunksSizing(std::list< Chunk_NS::Chunk > &chunks) const
const ColumnDescriptor * getColumnDescriptor(std::list< Chunk_NS::Chunk > &chunks, const SQLTypes sql_type, GeoColumnType geo_column_type)
const RenderGroupAnalyzerMap * render_group_analyzer_map_
ChunkMetadata * ring_or_line_sizes_column_metadata_
const ColumnDescriptor * coords_column_descriptor_
#define CHECK(condition)
Definition: Logger.h:289
bool is_geometry() const
Definition: sqltypes.h:588
const ColumnDescriptor * geo_column_descriptor_
const ColumnDescriptor * ring_or_line_sizes_column_descriptor_
SQLTypeInfo columnType
const ColumnDescriptor * bounds_column_descriptor_
foreign_storage::GeospatialEncoder::GeospatialEncoder ( std::list< Chunk_NS::Chunk > &  chunks,
std::list< std::unique_ptr< ChunkMetadata >> &  chunk_metadata,
const RenderGroupAnalyzerMap render_group_analyzer_map 
)
inline

Definition at line 92 of file GeospatialEncoder.h.

95  : geo_column_descriptor_(chunks.begin()->getColumnDesc())
96  , base_column_encoder_(nullptr)
97  , coords_column_encoder_(nullptr)
98  , bounds_column_encoder_(nullptr)
100  , poly_rings_column_encoder_(nullptr)
102  , base_column_metadata_(nullptr)
103  , coords_column_metadata_(nullptr)
104  , bounds_column_metadata_(nullptr)
106  , poly_rings_column_metadata_(nullptr)
108  , render_group_analyzer_map_{render_group_analyzer_map} {
110 
111  validateChunksSizing(chunks);
112  validateMetadataSizing(chunk_metadata);
113 
114  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
115 
116  // initialize base column encoder
117  auto base_chunk = chunks.begin();
118  base_chunk->initEncoder();
120  dynamic_cast<StringNoneEncoder*>(base_chunk->getBuffer()->getEncoder());
121  base_column_metadata_ = chunk_metadata.begin()->get();
123 
124  // initialize coords column
127  chunks, chunk_metadata, geo_column_type, COORDS);
128 
129  // initialize bounds column
130  if (hasBoundsColumn()) {
131  std::tie(
134  chunks, chunk_metadata, geo_column_type, BOUNDS);
135  }
136 
137  // initialize ring sizes column & render group column
138  if (hasRingOrLineSizesColumn()) {
143  chunks, chunk_metadata, geo_column_type, RING_OR_LINE_SIZES);
144  }
145  if (hasRenderGroupColumn()) {
150  chunks, chunk_metadata, geo_column_type, RENDER_GROUP);
151  }
152 
153  // initialize poly rings column
154  if (hasPolyRingsColumn()) {
159  chunks, chunk_metadata, geo_column_type, POLY_RINGS);
160  }
161  }
const ColumnDescriptor * poly_rings_column_descriptor_
const ColumnDescriptor * render_group_column_descriptor_
void validateMetadataSizing(std::list< std::unique_ptr< ChunkMetadata >> &chunk_metadata) const
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380
void validateChunksSizing(std::list< Chunk_NS::Chunk > &chunks) const
const RenderGroupAnalyzerMap * render_group_analyzer_map_
ChunkMetadata * ring_or_line_sizes_column_metadata_
const ColumnDescriptor * coords_column_descriptor_
#define CHECK(condition)
Definition: Logger.h:289
bool is_geometry() const
Definition: sqltypes.h:588
const ColumnDescriptor * geo_column_descriptor_
const ColumnDescriptor * ring_or_line_sizes_column_descriptor_
SQLTypeInfo columnType
std::tuple< Encoder *, ChunkMetadata *, const ColumnDescriptor * > initEncoderAndGetEncoderAndMetadata(std::list< Chunk_NS::Chunk > &chunks, std::list< std::unique_ptr< ChunkMetadata >> &chunk_metadata, const SQLTypes sql_type, GeoColumnType geo_column_type)
const ColumnDescriptor * bounds_column_descriptor_

Member Function Documentation

void foreign_storage::GeospatialEncoder::appendArrayDatumsToBufferAndUpdateMetadata ( )
inlineprotected

Definition at line 208 of file GeospatialEncoder.h.

References appendToArrayEncoderAndUpdateMetadata(), bounds_column_encoder_, bounds_column_metadata_, bounds_datum_buffer_, coords_column_encoder_, coords_column_metadata_, coords_datum_buffer_, poly_rings_column_encoder_, poly_rings_column_metadata_, poly_rings_datum_buffer_, ring_or_line_sizes_column_encoder_, ring_or_line_sizes_column_metadata_, and ring_or_line_sizes_datum_buffer_.

Referenced by foreign_storage::OdbcGeospatialEncoder::appendData(), and foreign_storage::ParquetGeospatialEncoder::appendData().

208  {
219  }
std::vector< ArrayDatum > coords_datum_buffer_
std::vector< ArrayDatum > ring_or_line_sizes_datum_buffer_
std::vector< ArrayDatum > bounds_datum_buffer_
void appendToArrayEncoderAndUpdateMetadata(const std::vector< ArrayDatum > &datum_parse_buffer, Encoder *encoder, ChunkMetadata *chunk_metadata) const
ChunkMetadata * ring_or_line_sizes_column_metadata_
std::vector< ArrayDatum > poly_rings_datum_buffer_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void foreign_storage::GeospatialEncoder::appendBaseAndRenderGroupDataAndUpdateMetadata ( const int64_t  row_count)
inlineprotected

Definition at line 164 of file GeospatialEncoder.h.

References StringNoneEncoder::appendData(), Encoder::appendData(), base_column_encoder_, base_column_metadata_, base_values_, CHECK_EQ, ColumnDescriptor::columnType, hasRenderGroupColumn(), render_group_column_descriptor_, render_group_column_encoder_, render_group_column_metadata_, and render_group_value_buffer_.

Referenced by foreign_storage::OdbcGeospatialEncoder::appendData(), and foreign_storage::ParquetGeospatialEncoder::appendData().

164  {
165  base_values_.resize(row_count);
167  *base_column_encoder_->appendData(&base_values_, 0, row_count);
168  if (hasRenderGroupColumn()) {
169  CHECK_EQ(render_group_value_buffer_.size(), static_cast<size_t>(row_count))
170  << "Render Group Values not generated correctly!";
171  auto data_ptr = reinterpret_cast<int8_t*>(render_group_value_buffer_.data());
173  data_ptr, row_count, render_group_column_descriptor_->columnType);
174  }
175  }
#define CHECK_EQ(x, y)
Definition: Logger.h:297
const ColumnDescriptor * render_group_column_descriptor_
std::vector< std::string > base_values_
std::shared_ptr< ChunkMetadata > appendData(int8_t *&src_data, const size_t num_elems_to_append, const SQLTypeInfo &ti, const bool replicating=false, const int64_t offset=-1) override
std::vector< int32_t > render_group_value_buffer_
SQLTypeInfo columnType
virtual std::shared_ptr< ChunkMetadata > appendData(int8_t *&src_data, const size_t num_elems_to_append, const SQLTypeInfo &ti, const bool replicating=false, const int64_t offset=-1)=0

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void foreign_storage::GeospatialEncoder::appendToArrayEncoderAndUpdateMetadata ( const std::vector< ArrayDatum > &  datum_parse_buffer,
Encoder encoder,
ChunkMetadata chunk_metadata 
) const
inlineprotected

Definition at line 221 of file GeospatialEncoder.h.

References CHECK, and UNREACHABLE.

Referenced by appendArrayDatumsToBufferAndUpdateMetadata().

224  {
225  if (!encoder) {
226  CHECK(!chunk_metadata);
227  return;
228  }
229  if (auto fixed_len_array_encoder =
230  dynamic_cast<FixedLengthArrayNoneEncoder*>(encoder)) {
231  auto new_chunk_metadata = fixed_len_array_encoder->appendData(
232  &datum_parse_buffer, 0, datum_parse_buffer.size());
233  *chunk_metadata = *new_chunk_metadata;
234  } else if (auto array_encoder = dynamic_cast<ArrayNoneEncoder*>(encoder)) {
235  auto new_chunk_metadata = array_encoder->appendData(
236  &datum_parse_buffer, 0, datum_parse_buffer.size(), false);
237  *chunk_metadata = *new_chunk_metadata;
238  } else {
239  UNREACHABLE();
240  }
241  }
#define UNREACHABLE()
Definition: Logger.h:333
#define CHECK(condition)
Definition: Logger.h:289

+ Here is the caller graph for this function:

void foreign_storage::GeospatialEncoder::clearDatumBuffers ( )
inlineprotected

Definition at line 350 of file GeospatialEncoder.h.

References bounds_datum_buffer_, coords_datum_buffer_, poly_rings_datum_buffer_, render_group_value_buffer_, and ring_or_line_sizes_datum_buffer_.

Referenced by foreign_storage::OdbcGeospatialEncoder::appendData(), foreign_storage::ParquetGeospatialEncoder::appendData(), and foreign_storage::ParquetGeospatialImportEncoder::appendData().

350  {
351  coords_datum_buffer_.clear();
352  bounds_datum_buffer_.clear();
354  poly_rings_datum_buffer_.clear();
356  }
std::vector< ArrayDatum > coords_datum_buffer_
std::vector< ArrayDatum > ring_or_line_sizes_datum_buffer_
std::vector< ArrayDatum > bounds_datum_buffer_
std::vector< int32_t > render_group_value_buffer_
std::vector< ArrayDatum > poly_rings_datum_buffer_

+ Here is the caller graph for this function:

void foreign_storage::GeospatialEncoder::clearParseBuffers ( )
inlineprotected

Definition at line 343 of file GeospatialEncoder.h.

References bounds_parse_buffer_, coords_parse_buffer_, poly_rings_parse_buffer_, and ring_or_line_sizes_parse_buffer_.

Referenced by foreign_storage::OdbcGeospatialEncoder::appendData(), foreign_storage::ParquetGeospatialEncoder::appendData(), and foreign_storage::ParquetGeospatialImportEncoder::appendData().

343  {
344  coords_parse_buffer_.clear();
345  bounds_parse_buffer_.clear();
347  poly_rings_parse_buffer_.clear();
348  }
std::vector< int > ring_or_line_sizes_parse_buffer_
std::vector< double > bounds_parse_buffer_
std::vector< double > coords_parse_buffer_

+ Here is the caller graph for this function:

const ColumnDescriptor* foreign_storage::GeospatialEncoder::getColumnDescriptor ( std::list< Chunk_NS::Chunk > &  chunks,
const SQLTypes  sql_type,
GeoColumnType  geo_column_type 
)
inlineprotected

Definition at line 460 of file GeospatialEncoder.h.

References getIteratorForGeoColumnType().

462  {
463  auto chunk = getIteratorForGeoColumnType(chunks, sql_type, geo_column_type);
464  auto column_descriptor = chunk->getColumnDesc();
465  return column_descriptor;
466  }
std::list< T >::iterator getIteratorForGeoColumnType(std::list< T > &list, const SQLTypes column_type, const GeoColumnType geo_column)

+ Here is the call graph for this function:

template<typename T >
std::list<T>::iterator foreign_storage::GeospatialEncoder::getIteratorForGeoColumnType ( std::list< T > &  list,
const SQLTypes  column_type,
const GeoColumnType  geo_column 
)
inlineprotected

Definition at line 361 of file GeospatialEncoder.h.

References BOUNDS, COORDS, kLINESTRING, kMULTILINESTRING, kMULTIPOINT, kMULTIPOLYGON, kPOINT, kPOLYGON, POLY_RINGS, RENDER_GROUP, RING_OR_LINE_SIZES, and UNREACHABLE.

Referenced by foreign_storage::ParquetGeospatialImportEncoder::getBuffer(), getColumnDescriptor(), and initEncoderAndGetEncoderAndMetadata().

364  {
365  auto list_iter = list.begin();
366  list_iter++; // skip base column
367  switch (column_type) {
368  case kPOINT: {
369  if (geo_column == COORDS) {
370  return list_iter;
371  }
372  UNREACHABLE();
373  }
374  case kMULTIPOINT:
375  case kLINESTRING: {
376  if (geo_column == COORDS) {
377  return list_iter;
378  }
379  list_iter++;
380  if (geo_column == BOUNDS) {
381  return list_iter;
382  }
383  UNREACHABLE();
384  }
385  case kMULTILINESTRING: {
386  if (geo_column == COORDS) {
387  return list_iter;
388  }
389  list_iter++;
390  if (geo_column == RING_OR_LINE_SIZES) {
391  return list_iter;
392  }
393  list_iter++;
394  if (geo_column == BOUNDS) {
395  return list_iter;
396  }
397  UNREACHABLE();
398  }
399  case kPOLYGON: {
400  if (geo_column == COORDS) {
401  return list_iter;
402  }
403  list_iter++;
404  if (geo_column == RING_OR_LINE_SIZES) {
405  return list_iter;
406  }
407  list_iter++;
408  if (geo_column == BOUNDS) {
409  return list_iter;
410  }
411  list_iter++;
412  if (geo_column == RENDER_GROUP) {
413  return list_iter;
414  }
415  UNREACHABLE();
416  }
417  case kMULTIPOLYGON: {
418  if (geo_column == COORDS) {
419  return list_iter;
420  }
421  list_iter++;
422  if (geo_column == RING_OR_LINE_SIZES) {
423  return list_iter;
424  }
425  list_iter++;
426  if (geo_column == POLY_RINGS) {
427  return list_iter;
428  }
429  list_iter++;
430  if (geo_column == BOUNDS) {
431  return list_iter;
432  }
433  list_iter++;
434  if (geo_column == RENDER_GROUP) {
435  return list_iter;
436  }
437  UNREACHABLE();
438  }
439  default:
440  UNREACHABLE();
441  }
442  return {};
443  }
#define UNREACHABLE()
Definition: Logger.h:333

+ Here is the caller graph for this function:

bool foreign_storage::GeospatialEncoder::hasBoundsColumn ( ) const
inlineprotected

Definition at line 481 of file GeospatialEncoder.h.

References ColumnDescriptor::columnType, geo_column_descriptor_, SQLTypeInfo::get_type(), kLINESTRING, kMULTILINESTRING, kMULTIPOINT, kMULTIPOLYGON, and kPOLYGON.

Referenced by foreign_storage::ParquetGeospatialImportEncoder::eraseInvalidIndicesInBuffer(), foreign_storage::ParquetGeospatialImportEncoder::ParquetGeospatialImportEncoder(), processGeoElement(), and processNullGeoElement().

481  {
482  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
483  return geo_column_type == kMULTIPOINT || geo_column_type == kLINESTRING ||
484  geo_column_type == kMULTILINESTRING || geo_column_type == kPOLYGON ||
485  geo_column_type == kMULTIPOLYGON;
486  }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380
const ColumnDescriptor * geo_column_descriptor_
SQLTypeInfo columnType

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool foreign_storage::GeospatialEncoder::hasPolyRingsColumn ( ) const
inlineprotected

Definition at line 499 of file GeospatialEncoder.h.

References ColumnDescriptor::columnType, geo_column_descriptor_, SQLTypeInfo::get_type(), and kMULTIPOLYGON.

Referenced by foreign_storage::ParquetGeospatialImportEncoder::eraseInvalidIndicesInBuffer(), foreign_storage::ParquetGeospatialImportEncoder::ParquetGeospatialImportEncoder(), processGeoElement(), and processNullGeoElement().

499  {
500  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
501  return geo_column_type == kMULTIPOLYGON;
502  }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380
const ColumnDescriptor * geo_column_descriptor_
SQLTypeInfo columnType

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool foreign_storage::GeospatialEncoder::hasRenderGroupColumn ( ) const
inlineprotected

Definition at line 494 of file GeospatialEncoder.h.

References ColumnDescriptor::columnType, geo_column_descriptor_, SQLTypeInfo::get_type(), kMULTIPOLYGON, and kPOLYGON.

Referenced by appendBaseAndRenderGroupDataAndUpdateMetadata(), foreign_storage::ParquetGeospatialImportEncoder::eraseInvalidIndicesInBuffer(), foreign_storage::ParquetGeospatialImportEncoder::ParquetGeospatialImportEncoder(), processGeoElement(), and processNullGeoElement().

494  {
495  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
496  return geo_column_type == kPOLYGON || geo_column_type == kMULTIPOLYGON;
497  }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380
const ColumnDescriptor * geo_column_descriptor_
SQLTypeInfo columnType

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool foreign_storage::GeospatialEncoder::hasRingOrLineSizesColumn ( ) const
inlineprotected

Definition at line 488 of file GeospatialEncoder.h.

References ColumnDescriptor::columnType, geo_column_descriptor_, SQLTypeInfo::get_type(), kMULTILINESTRING, kMULTIPOLYGON, and kPOLYGON.

Referenced by foreign_storage::ParquetGeospatialImportEncoder::eraseInvalidIndicesInBuffer(), foreign_storage::ParquetGeospatialImportEncoder::ParquetGeospatialImportEncoder(), processGeoElement(), and processNullGeoElement().

488  {
489  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
490  return geo_column_type == kPOLYGON || geo_column_type == kMULTIPOLYGON ||
491  geo_column_type == kMULTILINESTRING;
492  }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380
const ColumnDescriptor * geo_column_descriptor_
SQLTypeInfo columnType

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::tuple<Encoder*, ChunkMetadata*, const ColumnDescriptor*> foreign_storage::GeospatialEncoder::initEncoderAndGetEncoderAndMetadata ( std::list< Chunk_NS::Chunk > &  chunks,
std::list< std::unique_ptr< ChunkMetadata >> &  chunk_metadata,
const SQLTypes  sql_type,
GeoColumnType  geo_column_type 
)
inlineprotected

Definition at line 446 of file GeospatialEncoder.h.

References getIteratorForGeoColumnType().

450  {
451  auto chunk = getIteratorForGeoColumnType(chunks, sql_type, geo_column_type);
452  chunk->initEncoder();
453  auto encoder = chunk->getBuffer()->getEncoder();
454  auto metadata =
455  getIteratorForGeoColumnType(chunk_metadata, sql_type, geo_column_type)->get();
456  auto column_descriptor = chunk->getColumnDesc();
457  return {encoder, metadata, column_descriptor};
458  }
std::list< T >::iterator getIteratorForGeoColumnType(std::list< T > &list, const SQLTypes column_type, const GeoColumnType geo_column)

+ Here is the call graph for this function:

void foreign_storage::GeospatialEncoder::processGeoElement ( std::string_view  geo_string_view)
inlineprotected

Definition at line 243 of file GeospatialEncoder.h.

References bounds_datum_buffer_, bounds_parse_buffer_, CHECK_EQ, ColumnDescriptor::columnId, ColumnDescriptor::columnName, ColumnDescriptor::columnType, Geospatial::compress_coords(), coords_datum_buffer_, coords_parse_buffer_, foreign_storage::encode_as_array_datum(), geo_column_descriptor_, SQLTypeInfo::get_type(), Geospatial::GeoTypesFactory::getGeoColumns(), hasBoundsColumn(), hasPolyRingsColumn(), hasRenderGroupColumn(), hasRingOrLineSizesColumn(), IS_GEO_POLY, kMULTIPOLYGON, kPOLYGON, poly_rings_datum_buffer_, poly_rings_parse_buffer_, PROMOTE_POLYGON_TO_MULTIPOLYGON, render_group_analyzer_map_, render_group_value_buffer_, ring_or_line_sizes_datum_buffer_, ring_or_line_sizes_parse_buffer_, throwMalformedGeoElement(), and throwMismatchedGeoElement().

Referenced by foreign_storage::OdbcGeospatialEncoder::appendData(), foreign_storage::ParquetGeospatialEncoder::appendData(), and foreign_storage::ParquetGeospatialImportEncoder::appendData().

243  {
245  if (!Geospatial::GeoTypesFactory::getGeoColumns(std::string(geo_string_view),
246  import_ti,
253  }
254 
255  // validate types
256  if (geo_column_descriptor_->columnType.get_type() != import_ti.get_type()) {
258  !(import_ti.get_type() == SQLTypes::kPOLYGON &&
261  }
262  }
263 
264  // append coords
265  std::vector<uint8_t> compressed_coords = Geospatial::compress_coords(
267  coords_datum_buffer_.emplace_back(encode_as_array_datum(compressed_coords));
268 
269  // append bounds
270  if (hasBoundsColumn()) {
272  }
273 
274  // append ring sizes
275  if (hasRingOrLineSizesColumn()) {
278  }
279 
280  // append poly rings
281  if (hasPolyRingsColumn()) {
282  poly_rings_datum_buffer_.emplace_back(
284  }
285 
286  if (hasRenderGroupColumn()) {
287  if (IS_GEO_POLY(import_ti.get_type()) && render_group_analyzer_map_ &&
288  render_group_analyzer_map_->size()) {
289  CHECK_EQ(bounds_parse_buffer_.size(), 4u);
290  auto const itr =
292  int render_group{0};
293  if (itr != render_group_analyzer_map_->end()) {
294  auto& render_group_analyzer = *itr->second;
295  render_group = render_group_analyzer.insertBoundsAndReturnRenderGroup(
297  }
298  render_group_value_buffer_.emplace_back(render_group);
299  } else {
300  render_group_value_buffer_.emplace_back(0);
301  }
302  }
303  }
static void throwMismatchedGeoElement(const std::string &omnisci_column_name)
#define CHECK_EQ(x, y)
Definition: Logger.h:297
static constexpr bool PROMOTE_POLYGON_TO_MULTIPOLYGON
std::vector< ArrayDatum > coords_datum_buffer_
std::vector< ArrayDatum > ring_or_line_sizes_datum_buffer_
std::vector< int > ring_or_line_sizes_parse_buffer_
std::vector< ArrayDatum > bounds_datum_buffer_
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380
static void throwMalformedGeoElement(const std::string &omnisci_column_name)
std::vector< int32_t > render_group_value_buffer_
std::vector< uint8_t > compress_coords(const std::vector< double > &coords, const SQLTypeInfo &ti)
Definition: Compression.cpp:52
const RenderGroupAnalyzerMap * render_group_analyzer_map_
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:1079
std::vector< double > bounds_parse_buffer_
std::vector< double > coords_parse_buffer_
ArrayDatum encode_as_array_datum(const std::vector< T > &data)
const ColumnDescriptor * geo_column_descriptor_
SQLTypeInfo columnType
std::vector< ArrayDatum > poly_rings_datum_buffer_
std::string columnName
#define IS_GEO_POLY(T)
Definition: sqltypes.h:303

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void foreign_storage::GeospatialEncoder::processNullGeoElement ( )
inlineprotected

Definition at line 305 of file GeospatialEncoder.h.

References bounds_column_descriptor_, bounds_datum_buffer_, bounds_parse_buffer_, ColumnDescriptor::columnType, import_export::ImporterUtils::composeNullArray(), Geospatial::compress_coords(), coords_column_descriptor_, coords_datum_buffer_, coords_parse_buffer_, foreign_storage::encode_as_array_datum(), geo_column_descriptor_, SQLTypeInfo::get_type(), Geospatial::GeoTypesFactory::getNullGeoColumns(), hasBoundsColumn(), hasPolyRingsColumn(), hasRenderGroupColumn(), hasRingOrLineSizesColumn(), kPOINT, poly_rings_column_descriptor_, poly_rings_datum_buffer_, poly_rings_parse_buffer_, PROMOTE_POLYGON_TO_MULTIPOLYGON, render_group_value_buffer_, ring_or_line_sizes_column_descriptor_, ring_or_line_sizes_datum_buffer_, and ring_or_line_sizes_parse_buffer_.

Referenced by foreign_storage::OdbcGeospatialEncoder::appendData(), foreign_storage::ParquetGeospatialEncoder::appendData(), and foreign_storage::ParquetGeospatialImportEncoder::appendData().

305  {
313  // POINT columns are represented using fixed length arrays and need
314  // special treatment of nulls
316  std::vector<uint8_t> compressed_coords = Geospatial::compress_coords(
318  coords_datum_buffer_.emplace_back(encode_as_array_datum(compressed_coords));
319  } else {
322  }
323  if (hasBoundsColumn()) {
326  }
327  if (hasRingOrLineSizesColumn()) {
331  }
332  if (hasPolyRingsColumn()) {
333  poly_rings_datum_buffer_.emplace_back(
336  }
337  if (hasRenderGroupColumn()) {
338  static constexpr int32_t kNullRenderGroupValue = -1;
339  render_group_value_buffer_.emplace_back(kNullRenderGroupValue);
340  }
341  }
static constexpr bool PROMOTE_POLYGON_TO_MULTIPOLYGON
const ColumnDescriptor * poly_rings_column_descriptor_
std::vector< ArrayDatum > coords_datum_buffer_
static ArrayDatum composeNullArray(const SQLTypeInfo &ti)
Definition: Importer.cpp:394
std::vector< ArrayDatum > ring_or_line_sizes_datum_buffer_
std::vector< int > ring_or_line_sizes_parse_buffer_
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:1309
std::vector< ArrayDatum > bounds_datum_buffer_
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380
std::vector< int32_t > render_group_value_buffer_
std::vector< uint8_t > compress_coords(const std::vector< double > &coords, const SQLTypeInfo &ti)
Definition: Compression.cpp:52
const ColumnDescriptor * coords_column_descriptor_
std::vector< double > bounds_parse_buffer_
std::vector< double > coords_parse_buffer_
ArrayDatum encode_as_array_datum(const std::vector< T > &data)
const ColumnDescriptor * geo_column_descriptor_
const ColumnDescriptor * ring_or_line_sizes_column_descriptor_
SQLTypeInfo columnType
std::vector< ArrayDatum > poly_rings_datum_buffer_
const ColumnDescriptor * bounds_column_descriptor_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void foreign_storage::GeospatialEncoder::throwMalformedGeoElement ( const std::string &  omnisci_column_name)
inlinestaticprotected

Definition at line 468 of file GeospatialEncoder.h.

Referenced by processGeoElement().

468  {
469  std::string error_message = "Failed to extract valid geometry in HeavyDB column '" +
470  omnisci_column_name + "'.";
471  throw foreign_storage::ForeignStorageException(error_message);
472  }

+ Here is the caller graph for this function:

static void foreign_storage::GeospatialEncoder::throwMismatchedGeoElement ( const std::string &  omnisci_column_name)
inlinestaticprotected

Definition at line 474 of file GeospatialEncoder.h.

Referenced by processGeoElement().

474  {
476  "Imported geometry"
477  " doesn't match the geospatial type of HeavyDB column '" +
478  omnisci_column_name + "'.");
479  }

+ Here is the caller graph for this function:

void foreign_storage::GeospatialEncoder::validateChunksSizing ( std::list< Chunk_NS::Chunk > &  chunks) const
inlineprotected

Definition at line 177 of file GeospatialEncoder.h.

References CHECK, ColumnDescriptor::columnType, geo_column_descriptor_, SQLTypeInfo::get_type(), kLINESTRING, kMULTILINESTRING, kMULTIPOINT, kMULTIPOLYGON, kPOINT, and kPOLYGON.

177  {
178  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
179  if (geo_column_type == kPOINT) {
180  CHECK(chunks.size() == 2);
181  } else if (geo_column_type == kLINESTRING || geo_column_type == kMULTIPOINT) {
182  CHECK(chunks.size() == 3);
183  } else if (geo_column_type == kMULTILINESTRING) {
184  CHECK(chunks.size() == 4);
185  } else if (geo_column_type == kPOLYGON) {
186  CHECK(chunks.size() == 5);
187  } else if (geo_column_type == kMULTIPOLYGON) {
188  CHECK(chunks.size() == 6);
189  }
190  }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380
#define CHECK(condition)
Definition: Logger.h:289
const ColumnDescriptor * geo_column_descriptor_
SQLTypeInfo columnType

+ Here is the call graph for this function:

void foreign_storage::GeospatialEncoder::validateMetadataSizing ( std::list< std::unique_ptr< ChunkMetadata >> &  chunk_metadata) const
inlineprotected

Definition at line 192 of file GeospatialEncoder.h.

References CHECK, ColumnDescriptor::columnType, geo_column_descriptor_, SQLTypeInfo::get_type(), kLINESTRING, kMULTILINESTRING, kMULTIPOINT, kMULTIPOLYGON, kPOINT, and kPOLYGON.

193  {
194  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
195  if (geo_column_type == kPOINT) {
196  CHECK(chunk_metadata.size() == 2);
197  } else if (geo_column_type == kLINESTRING || geo_column_type == kMULTIPOINT) {
198  CHECK(chunk_metadata.size() == 3);
199  } else if (geo_column_type == kMULTILINESTRING) {
200  CHECK(chunk_metadata.size() == 4);
201  } else if (geo_column_type == kPOLYGON) {
202  CHECK(chunk_metadata.size() == 5);
203  } else if (geo_column_type == kMULTIPOLYGON) {
204  CHECK(chunk_metadata.size() == 6);
205  }
206  }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380
#define CHECK(condition)
Definition: Logger.h:289
const ColumnDescriptor * geo_column_descriptor_
SQLTypeInfo columnType

+ Here is the call graph for this function:

Member Data Documentation

StringNoneEncoder* foreign_storage::GeospatialEncoder::base_column_encoder_
protected

Definition at line 508 of file GeospatialEncoder.h.

Referenced by appendBaseAndRenderGroupDataAndUpdateMetadata().

ChunkMetadata* foreign_storage::GeospatialEncoder::base_column_metadata_
protected

Definition at line 515 of file GeospatialEncoder.h.

Referenced by appendBaseAndRenderGroupDataAndUpdateMetadata().

std::vector<std::string> foreign_storage::GeospatialEncoder::base_values_
protected

Definition at line 528 of file GeospatialEncoder.h.

Referenced by appendBaseAndRenderGroupDataAndUpdateMetadata().

const ColumnDescriptor* foreign_storage::GeospatialEncoder::bounds_column_descriptor_
protected

Definition at line 523 of file GeospatialEncoder.h.

Referenced by processNullGeoElement().

Encoder* foreign_storage::GeospatialEncoder::bounds_column_encoder_
protected

Definition at line 510 of file GeospatialEncoder.h.

Referenced by appendArrayDatumsToBufferAndUpdateMetadata().

ChunkMetadata* foreign_storage::GeospatialEncoder::bounds_column_metadata_
protected

Definition at line 517 of file GeospatialEncoder.h.

Referenced by appendArrayDatumsToBufferAndUpdateMetadata().

std::vector<double> foreign_storage::GeospatialEncoder::bounds_parse_buffer_
protected
const ColumnDescriptor* foreign_storage::GeospatialEncoder::coords_column_descriptor_
protected

Definition at line 522 of file GeospatialEncoder.h.

Referenced by processNullGeoElement().

Encoder* foreign_storage::GeospatialEncoder::coords_column_encoder_
protected

Definition at line 509 of file GeospatialEncoder.h.

Referenced by appendArrayDatumsToBufferAndUpdateMetadata().

ChunkMetadata* foreign_storage::GeospatialEncoder::coords_column_metadata_
protected

Definition at line 516 of file GeospatialEncoder.h.

Referenced by appendArrayDatumsToBufferAndUpdateMetadata().

std::vector<double> foreign_storage::GeospatialEncoder::coords_parse_buffer_
protected
const ColumnDescriptor* foreign_storage::GeospatialEncoder::poly_rings_column_descriptor_
protected

Definition at line 525 of file GeospatialEncoder.h.

Referenced by processNullGeoElement().

Encoder* foreign_storage::GeospatialEncoder::poly_rings_column_encoder_
protected

Definition at line 512 of file GeospatialEncoder.h.

Referenced by appendArrayDatumsToBufferAndUpdateMetadata().

ChunkMetadata* foreign_storage::GeospatialEncoder::poly_rings_column_metadata_
protected

Definition at line 519 of file GeospatialEncoder.h.

Referenced by appendArrayDatumsToBufferAndUpdateMetadata().

std::vector<ArrayDatum> foreign_storage::GeospatialEncoder::poly_rings_datum_buffer_
protected
std::vector<int> foreign_storage::GeospatialEncoder::poly_rings_parse_buffer_
protected
constexpr bool foreign_storage::GeospatialEncoder::PROMOTE_POLYGON_TO_MULTIPOLYGON = true
staticprotected

Definition at line 506 of file GeospatialEncoder.h.

Referenced by processGeoElement(), and processNullGeoElement().

const RenderGroupAnalyzerMap* foreign_storage::GeospatialEncoder::render_group_analyzer_map_
protected

Definition at line 544 of file GeospatialEncoder.h.

Referenced by processGeoElement().

const ColumnDescriptor* foreign_storage::GeospatialEncoder::render_group_column_descriptor_
protected

Definition at line 526 of file GeospatialEncoder.h.

Referenced by appendBaseAndRenderGroupDataAndUpdateMetadata().

Encoder* foreign_storage::GeospatialEncoder::render_group_column_encoder_
protected

Definition at line 513 of file GeospatialEncoder.h.

Referenced by appendBaseAndRenderGroupDataAndUpdateMetadata().

ChunkMetadata* foreign_storage::GeospatialEncoder::render_group_column_metadata_
protected

Definition at line 520 of file GeospatialEncoder.h.

Referenced by appendBaseAndRenderGroupDataAndUpdateMetadata().

std::vector<int32_t> foreign_storage::GeospatialEncoder::render_group_value_buffer_
protected
const ColumnDescriptor* foreign_storage::GeospatialEncoder::ring_or_line_sizes_column_descriptor_
protected

Definition at line 524 of file GeospatialEncoder.h.

Referenced by processNullGeoElement().

Encoder* foreign_storage::GeospatialEncoder::ring_or_line_sizes_column_encoder_
protected

Definition at line 511 of file GeospatialEncoder.h.

Referenced by appendArrayDatumsToBufferAndUpdateMetadata().

ChunkMetadata* foreign_storage::GeospatialEncoder::ring_or_line_sizes_column_metadata_
protected

Definition at line 518 of file GeospatialEncoder.h.

Referenced by appendArrayDatumsToBufferAndUpdateMetadata().

std::vector<ArrayDatum> foreign_storage::GeospatialEncoder::ring_or_line_sizes_datum_buffer_
protected
std::vector<int> foreign_storage::GeospatialEncoder::ring_or_line_sizes_parse_buffer_
protected

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