OmniSciDB  ca0c39ec8f
 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_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 hasRingSizesColumn () 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_sizes_column_encoder_
 
Encoderpoly_rings_column_encoder_
 
Encoderrender_group_column_encoder_
 
ChunkMetadatabase_column_metadata_
 
ChunkMetadatacoords_column_metadata_
 
ChunkMetadatabounds_column_metadata_
 
ChunkMetadataring_sizes_column_metadata_
 
ChunkMetadatapoly_rings_column_metadata_
 
ChunkMetadatarender_group_column_metadata_
 
const ColumnDescriptorcoords_column_descriptor_
 
const ColumnDescriptorbounds_column_descriptor_
 
const ColumnDescriptorring_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_sizes_parse_buffer_
 
std::vector< int > poly_rings_parse_buffer_
 
std::vector< ArrayDatumcoords_datum_buffer_
 
std::vector< ArrayDatumbounds_datum_buffer_
 
std::vector< ArrayDatumring_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
76  if (hasRingSizesColumn()) {
78  getColumnDescriptor(chunks, geo_column_type, RING_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:379
void validateChunksSizing(std::list< Chunk_NS::Chunk > &chunks) const
const ColumnDescriptor * ring_sizes_column_descriptor_
const ColumnDescriptor * getColumnDescriptor(std::list< Chunk_NS::Chunk > &chunks, const SQLTypes sql_type, GeoColumnType geo_column_type)
const RenderGroupAnalyzerMap * render_group_analyzer_map_
const ColumnDescriptor * coords_column_descriptor_
#define CHECK(condition)
Definition: Logger.h:222
bool is_geometry() const
Definition: sqltypes.h:587
const ColumnDescriptor * geo_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)
105  , ring_sizes_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 (hasRingSizesColumn()) {
143  chunks, chunk_metadata, geo_column_type, RING_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:379
void validateChunksSizing(std::list< Chunk_NS::Chunk > &chunks) const
const ColumnDescriptor * ring_sizes_column_descriptor_
const RenderGroupAnalyzerMap * render_group_analyzer_map_
const ColumnDescriptor * coords_column_descriptor_
#define CHECK(condition)
Definition: Logger.h:222
bool is_geometry() const
Definition: sqltypes.h:587
const ColumnDescriptor * geo_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 204 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_sizes_column_encoder_, ring_sizes_column_metadata_, and ring_sizes_datum_buffer_.

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

204  {
215  }
std::vector< ArrayDatum > coords_datum_buffer_
std::vector< ArrayDatum > bounds_datum_buffer_
void appendToArrayEncoderAndUpdateMetadata(const std::vector< ArrayDatum > &datum_parse_buffer, Encoder *encoder, ChunkMetadata *chunk_metadata) const
std::vector< ArrayDatum > ring_sizes_datum_buffer_
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:230
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 217 of file GeospatialEncoder.h.

References CHECK, and UNREACHABLE.

Referenced by appendArrayDatumsToBufferAndUpdateMetadata().

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

+ Here is the caller graph for this function:

void foreign_storage::GeospatialEncoder::clearDatumBuffers ( )
inlineprotected

Definition at line 346 of file GeospatialEncoder.h.

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

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

346  {
347  coords_datum_buffer_.clear();
348  bounds_datum_buffer_.clear();
349  ring_sizes_datum_buffer_.clear();
350  poly_rings_datum_buffer_.clear();
352  }
std::vector< ArrayDatum > coords_datum_buffer_
std::vector< ArrayDatum > bounds_datum_buffer_
std::vector< int32_t > render_group_value_buffer_
std::vector< ArrayDatum > ring_sizes_datum_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 339 of file GeospatialEncoder.h.

References bounds_parse_buffer_, coords_parse_buffer_, poly_rings_parse_buffer_, and ring_sizes_parse_buffer_.

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

339  {
340  coords_parse_buffer_.clear();
341  bounds_parse_buffer_.clear();
342  ring_sizes_parse_buffer_.clear();
343  poly_rings_parse_buffer_.clear();
344  }
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 441 of file GeospatialEncoder.h.

References getIteratorForGeoColumnType().

443  {
444  auto chunk = getIteratorForGeoColumnType(chunks, sql_type, geo_column_type);
445  auto column_descriptor = chunk->getColumnDesc();
446  return column_descriptor;
447  }
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 357 of file GeospatialEncoder.h.

References BOUNDS, COORDS, kLINESTRING, kMULTIPOLYGON, kPOINT, kPOLYGON, POLY_RINGS, RENDER_GROUP, RING_SIZES, and UNREACHABLE.

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

360  {
361  auto list_iter = list.begin();
362  list_iter++; // skip base column
363  switch (column_type) {
364  case kPOINT: {
365  if (geo_column == COORDS) {
366  return list_iter;
367  }
368  UNREACHABLE();
369  }
370  case kLINESTRING: {
371  if (geo_column == COORDS) {
372  return list_iter;
373  }
374  list_iter++;
375  if (geo_column == BOUNDS) {
376  return list_iter;
377  }
378  UNREACHABLE();
379  }
380  case kPOLYGON: {
381  if (geo_column == COORDS) {
382  return list_iter;
383  }
384  list_iter++;
385  if (geo_column == RING_SIZES) {
386  return list_iter;
387  }
388  list_iter++;
389  if (geo_column == BOUNDS) {
390  return list_iter;
391  }
392  list_iter++;
393  if (geo_column == RENDER_GROUP) {
394  return list_iter;
395  }
396  UNREACHABLE();
397  }
398  case kMULTIPOLYGON: {
399  if (geo_column == COORDS) {
400  return list_iter;
401  }
402  list_iter++;
403  if (geo_column == RING_SIZES) {
404  return list_iter;
405  }
406  list_iter++;
407  if (geo_column == POLY_RINGS) {
408  return list_iter;
409  }
410  list_iter++;
411  if (geo_column == BOUNDS) {
412  return list_iter;
413  }
414  list_iter++;
415  if (geo_column == RENDER_GROUP) {
416  return list_iter;
417  }
418  UNREACHABLE();
419  }
420  default:
421  UNREACHABLE();
422  }
423  return {};
424  }
#define UNREACHABLE()
Definition: Logger.h:266

+ Here is the caller graph for this function:

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

Definition at line 462 of file GeospatialEncoder.h.

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

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

462  {
463  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
464  return geo_column_type == kLINESTRING || geo_column_type == kPOLYGON ||
465  geo_column_type == kMULTIPOLYGON;
466  }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:379
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 478 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().

478  {
479  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
480  return geo_column_type == kMULTIPOLYGON;
481  }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:379
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 473 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().

473  {
474  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
475  return geo_column_type == kPOLYGON || geo_column_type == kMULTIPOLYGON;
476  }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:379
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::hasRingSizesColumn ( ) const
inlineprotected

Definition at line 468 of file GeospatialEncoder.h.

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

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

468  {
469  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
470  return geo_column_type == kPOLYGON || geo_column_type == kMULTIPOLYGON;
471  }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:379
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 427 of file GeospatialEncoder.h.

References getIteratorForGeoColumnType().

431  {
432  auto chunk = getIteratorForGeoColumnType(chunks, sql_type, geo_column_type);
433  chunk->initEncoder();
434  auto encoder = chunk->getBuffer()->getEncoder();
435  auto metadata =
436  getIteratorForGeoColumnType(chunk_metadata, sql_type, geo_column_type)->get();
437  auto column_descriptor = chunk->getColumnDesc();
438  return {encoder, metadata, column_descriptor};
439  }
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 239 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(), hasRingSizesColumn(), 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_sizes_datum_buffer_, ring_sizes_parse_buffer_, throwMalformedGeoElement(), and throwMismatchedGeoElement().

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

239  {
241  if (!Geospatial::GeoTypesFactory::getGeoColumns(std::string(geo_string_view),
242  import_ti,
249  }
250 
251  // validate types
252  if (geo_column_descriptor_->columnType.get_type() != import_ti.get_type()) {
254  !(import_ti.get_type() == SQLTypes::kPOLYGON &&
257  }
258  }
259 
260  // append coords
261  std::vector<uint8_t> compressed_coords = Geospatial::compress_coords(
263  coords_datum_buffer_.emplace_back(encode_as_array_datum(compressed_coords));
264 
265  // append bounds
266  if (hasBoundsColumn()) {
268  }
269 
270  // append ring sizes
271  if (hasRingSizesColumn()) {
272  ring_sizes_datum_buffer_.emplace_back(
274  }
275 
276  // append poly rings
277  if (hasPolyRingsColumn()) {
278  poly_rings_datum_buffer_.emplace_back(
280  }
281 
282  if (hasRenderGroupColumn()) {
283  if (IS_GEO_POLY(import_ti.get_type()) && render_group_analyzer_map_ &&
284  render_group_analyzer_map_->size()) {
285  CHECK_EQ(bounds_parse_buffer_.size(), 4u);
286  auto const itr =
288  int render_group{0};
289  if (itr != render_group_analyzer_map_->end()) {
290  auto& render_group_analyzer = *itr->second;
291  render_group = render_group_analyzer.insertBoundsAndReturnRenderGroup(
293  }
294  render_group_value_buffer_.emplace_back(render_group);
295  } else {
296  render_group_value_buffer_.emplace_back(0);
297  }
298  }
299  }
static void throwMismatchedGeoElement(const std::string &omnisci_column_name)
#define CHECK_EQ(x, y)
Definition: Logger.h:230
static constexpr bool PROMOTE_POLYGON_TO_MULTIPOLYGON
std::vector< ArrayDatum > coords_datum_buffer_
std::vector< ArrayDatum > bounds_datum_buffer_
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:379
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_
std::vector< ArrayDatum > ring_sizes_datum_buffer_
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 301 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(), hasRingSizesColumn(), kPOINT, poly_rings_column_descriptor_, poly_rings_datum_buffer_, poly_rings_parse_buffer_, PROMOTE_POLYGON_TO_MULTIPOLYGON, render_group_value_buffer_, ring_sizes_column_descriptor_, ring_sizes_datum_buffer_, and ring_sizes_parse_buffer_.

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

301  {
309  // POINT columns are represented using fixed length arrays and need
310  // special treatment of nulls
312  std::vector<uint8_t> compressed_coords = Geospatial::compress_coords(
314  coords_datum_buffer_.emplace_back(encode_as_array_datum(compressed_coords));
315  } else {
318  }
319  if (hasBoundsColumn()) {
322  }
323  if (hasRingSizesColumn()) {
324  ring_sizes_datum_buffer_.emplace_back(
327  }
328  if (hasPolyRingsColumn()) {
329  poly_rings_datum_buffer_.emplace_back(
332  }
333  if (hasRenderGroupColumn()) {
334  static constexpr int32_t kNullRenderGroupValue = -1;
335  render_group_value_buffer_.emplace_back(kNullRenderGroupValue);
336  }
337  }
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:390
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:379
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 * ring_sizes_column_descriptor_
const ColumnDescriptor * coords_column_descriptor_
std::vector< ArrayDatum > ring_sizes_datum_buffer_
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_
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 449 of file GeospatialEncoder.h.

Referenced by processGeoElement().

449  {
450  std::string error_message = "Failed to extract valid geometry in HeavyDB column '" +
451  omnisci_column_name + "'.";
452  throw foreign_storage::ForeignStorageException(error_message);
453  }

+ Here is the caller graph for this function:

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

Definition at line 455 of file GeospatialEncoder.h.

Referenced by processGeoElement().

455  {
457  "Imported geometry"
458  " doesn't match the geospatial type of HeavyDB column '" +
459  omnisci_column_name + "'.");
460  }

+ 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, 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) {
182  CHECK(chunks.size() == 3);
183  } else if (geo_column_type == kPOLYGON) {
184  CHECK(chunks.size() == 5);
185  } else if (geo_column_type == kMULTIPOLYGON) {
186  CHECK(chunks.size() == 6);
187  }
188  }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:379
#define CHECK(condition)
Definition: Logger.h:222
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 190 of file GeospatialEncoder.h.

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

191  {
192  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
193  if (geo_column_type == kPOINT) {
194  CHECK(chunk_metadata.size() == 2);
195  } else if (geo_column_type == kLINESTRING) {
196  CHECK(chunk_metadata.size() == 3);
197  } else if (geo_column_type == kPOLYGON) {
198  CHECK(chunk_metadata.size() == 5);
199  } else if (geo_column_type == kMULTIPOLYGON) {
200  CHECK(chunk_metadata.size() == 6);
201  }
202  }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:379
#define CHECK(condition)
Definition: Logger.h:222
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 487 of file GeospatialEncoder.h.

Referenced by appendBaseAndRenderGroupDataAndUpdateMetadata().

ChunkMetadata* foreign_storage::GeospatialEncoder::base_column_metadata_
protected

Definition at line 494 of file GeospatialEncoder.h.

Referenced by appendBaseAndRenderGroupDataAndUpdateMetadata().

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

Definition at line 507 of file GeospatialEncoder.h.

Referenced by appendBaseAndRenderGroupDataAndUpdateMetadata().

const ColumnDescriptor* foreign_storage::GeospatialEncoder::bounds_column_descriptor_
protected

Definition at line 502 of file GeospatialEncoder.h.

Referenced by processNullGeoElement().

Encoder* foreign_storage::GeospatialEncoder::bounds_column_encoder_
protected

Definition at line 489 of file GeospatialEncoder.h.

Referenced by appendArrayDatumsToBufferAndUpdateMetadata().

ChunkMetadata* foreign_storage::GeospatialEncoder::bounds_column_metadata_
protected

Definition at line 496 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 501 of file GeospatialEncoder.h.

Referenced by processNullGeoElement().

Encoder* foreign_storage::GeospatialEncoder::coords_column_encoder_
protected

Definition at line 488 of file GeospatialEncoder.h.

Referenced by appendArrayDatumsToBufferAndUpdateMetadata().

ChunkMetadata* foreign_storage::GeospatialEncoder::coords_column_metadata_
protected

Definition at line 495 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 504 of file GeospatialEncoder.h.

Referenced by processNullGeoElement().

Encoder* foreign_storage::GeospatialEncoder::poly_rings_column_encoder_
protected

Definition at line 491 of file GeospatialEncoder.h.

Referenced by appendArrayDatumsToBufferAndUpdateMetadata().

ChunkMetadata* foreign_storage::GeospatialEncoder::poly_rings_column_metadata_
protected

Definition at line 498 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 485 of file GeospatialEncoder.h.

Referenced by processGeoElement(), and processNullGeoElement().

const RenderGroupAnalyzerMap* foreign_storage::GeospatialEncoder::render_group_analyzer_map_
protected

Definition at line 523 of file GeospatialEncoder.h.

Referenced by processGeoElement().

const ColumnDescriptor* foreign_storage::GeospatialEncoder::render_group_column_descriptor_
protected

Definition at line 505 of file GeospatialEncoder.h.

Referenced by appendBaseAndRenderGroupDataAndUpdateMetadata().

Encoder* foreign_storage::GeospatialEncoder::render_group_column_encoder_
protected

Definition at line 492 of file GeospatialEncoder.h.

Referenced by appendBaseAndRenderGroupDataAndUpdateMetadata().

ChunkMetadata* foreign_storage::GeospatialEncoder::render_group_column_metadata_
protected

Definition at line 499 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_sizes_column_descriptor_
protected

Definition at line 503 of file GeospatialEncoder.h.

Referenced by processNullGeoElement().

Encoder* foreign_storage::GeospatialEncoder::ring_sizes_column_encoder_
protected

Definition at line 490 of file GeospatialEncoder.h.

Referenced by appendArrayDatumsToBufferAndUpdateMetadata().

ChunkMetadata* foreign_storage::GeospatialEncoder::ring_sizes_column_metadata_
protected

Definition at line 497 of file GeospatialEncoder.h.

Referenced by appendArrayDatumsToBufferAndUpdateMetadata().

std::vector<ArrayDatum> foreign_storage::GeospatialEncoder::ring_sizes_datum_buffer_
protected
std::vector<int> foreign_storage::GeospatialEncoder::ring_sizes_parse_buffer_
protected

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