OmniSciDB  6686921089
 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 ()
 
 GeospatialEncoder (std::list< Chunk_NS::Chunk > &chunks)
 
 GeospatialEncoder (std::list< Chunk_NS::Chunk > &chunks, std::list< std::unique_ptr< ChunkMetadata >> &chunk_metadata)
 

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< int32_t > render_group_values_
 
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_
 

Static Protected Attributes

static constexpr bool PROMOTE_POLYGON_TO_MULTIPOLYGON = true
 

Detailed Description

Definition at line 39 of file GeospatialEncoder.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

virtual foreign_storage::GeospatialEncoder::~GeospatialEncoder ( )
virtualdefault
foreign_storage::GeospatialEncoder::GeospatialEncoder ( )
inline

Definition at line 43 of file GeospatialEncoder.h.

43 {}
foreign_storage::GeospatialEncoder::GeospatialEncoder ( std::list< Chunk_NS::Chunk > &  chunks)
inline

Definition at line 45 of file GeospatialEncoder.h.

References BOUNDS, bounds_column_descriptor_, CHECK, ColumnDescriptor::columnType, COORDS, coords_column_descriptor_, geo_column_descriptor_, SQLTypeInfo::get_type(), getColumnDescriptor(), hasBoundsColumn(), hasPolyRingsColumn(), hasRenderGroupColumn(), hasRingSizesColumn(), SQLTypeInfo::is_geometry(), POLY_RINGS, poly_rings_column_descriptor_, RENDER_GROUP, render_group_column_descriptor_, RING_SIZES, ring_sizes_column_descriptor_, and validateChunksSizing().

46  : geo_column_descriptor_(chunks.begin()->getColumnDesc())
47  , base_column_encoder_(nullptr)
48  , coords_column_encoder_(nullptr)
49  , bounds_column_encoder_(nullptr)
53  , base_column_metadata_(nullptr)
54  , coords_column_metadata_(nullptr)
55  , bounds_column_metadata_(nullptr)
60  validateChunksSizing(chunks);
61  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
62 
63  // initialize coords column
64  coords_column_descriptor_ = getColumnDescriptor(chunks, geo_column_type, COORDS);
65 
66  // initialize bounds column
67  if (hasBoundsColumn()) {
68  bounds_column_descriptor_ = getColumnDescriptor(chunks, geo_column_type, BOUNDS);
69  }
70 
71  // initialize ring sizes column & render group column
72  if (hasRingSizesColumn()) {
74  getColumnDescriptor(chunks, geo_column_type, RING_SIZES);
75  }
76  if (hasRenderGroupColumn()) {
78  getColumnDescriptor(chunks, geo_column_type, RENDER_GROUP);
79  }
80 
81  // initialize poly rings column
82  if (hasPolyRingsColumn()) {
84  getColumnDescriptor(chunks, geo_column_type, POLY_RINGS);
85  }
86  }
const ColumnDescriptor * poly_rings_column_descriptor_
const ColumnDescriptor * render_group_column_descriptor_
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
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 ColumnDescriptor * coords_column_descriptor_
#define CHECK(condition)
Definition: Logger.h:209
bool is_geometry() const
Definition: sqltypes.h:521
const ColumnDescriptor * geo_column_descriptor_
SQLTypeInfo columnType
const ColumnDescriptor * bounds_column_descriptor_

+ Here is the call graph for this function:

foreign_storage::GeospatialEncoder::GeospatialEncoder ( std::list< Chunk_NS::Chunk > &  chunks,
std::list< std::unique_ptr< ChunkMetadata >> &  chunk_metadata 
)
inline

Definition at line 88 of file GeospatialEncoder.h.

References base_column_encoder_, base_column_metadata_, BOUNDS, bounds_column_descriptor_, bounds_column_encoder_, bounds_column_metadata_, CHECK, ColumnDescriptor::columnType, COORDS, coords_column_descriptor_, coords_column_encoder_, coords_column_metadata_, geo_column_descriptor_, SQLTypeInfo::get_type(), hasBoundsColumn(), hasPolyRingsColumn(), hasRenderGroupColumn(), hasRingSizesColumn(), initEncoderAndGetEncoderAndMetadata(), SQLTypeInfo::is_geometry(), POLY_RINGS, poly_rings_column_descriptor_, poly_rings_column_encoder_, poly_rings_column_metadata_, RENDER_GROUP, render_group_column_descriptor_, render_group_column_encoder_, render_group_column_metadata_, RING_SIZES, ring_sizes_column_descriptor_, ring_sizes_column_encoder_, ring_sizes_column_metadata_, validateChunksSizing(), and validateMetadataSizing().

90  : geo_column_descriptor_(chunks.begin()->getColumnDesc())
91  , base_column_encoder_(nullptr)
92  , coords_column_encoder_(nullptr)
93  , bounds_column_encoder_(nullptr)
97  , base_column_metadata_(nullptr)
98  , coords_column_metadata_(nullptr)
99  , bounds_column_metadata_(nullptr)
100  , ring_sizes_column_metadata_(nullptr)
101  , poly_rings_column_metadata_(nullptr)
102  , render_group_column_metadata_(nullptr) {
104 
105  validateChunksSizing(chunks);
106  validateMetadataSizing(chunk_metadata);
107 
108  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
109 
110  // initialize base column encoder
111  auto base_chunk = chunks.begin();
112  base_chunk->initEncoder();
114  dynamic_cast<StringNoneEncoder*>(base_chunk->getBuffer()->getEncoder());
115  base_column_metadata_ = chunk_metadata.begin()->get();
117 
118  // initialize coords column
121  chunks, chunk_metadata, geo_column_type, COORDS);
122 
123  // initialize bounds column
124  if (hasBoundsColumn()) {
125  std::tie(
128  chunks, chunk_metadata, geo_column_type, BOUNDS);
129  }
130 
131  // initialize ring sizes column & render group column
132  if (hasRingSizesColumn()) {
137  chunks, chunk_metadata, geo_column_type, RING_SIZES);
138  }
139  if (hasRenderGroupColumn()) {
144  chunks, chunk_metadata, geo_column_type, RENDER_GROUP);
145  }
146 
147  // initialize poly rings column
148  if (hasPolyRingsColumn()) {
153  chunks, chunk_metadata, geo_column_type, POLY_RINGS);
154  }
155  }
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:329
void validateChunksSizing(std::list< Chunk_NS::Chunk > &chunks) const
const ColumnDescriptor * ring_sizes_column_descriptor_
const ColumnDescriptor * coords_column_descriptor_
#define CHECK(condition)
Definition: Logger.h:209
bool is_geometry() const
Definition: sqltypes.h:521
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_

+ Here is the call graph for this function:

Member Function Documentation

void foreign_storage::GeospatialEncoder::appendArrayDatumsToBufferAndUpdateMetadata ( )
inlineprotected

Definition at line 198 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().

198  {
209  }
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 158 of file GeospatialEncoder.h.

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

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

158  {
159  // add nulls to base column & zeros to render group (if applicable)
160  render_group_values_.resize(row_count, 0);
161  base_values_.resize(row_count);
163  *base_column_encoder_->appendData(&base_values_, 0, row_count);
164  if (hasRenderGroupColumn()) {
165  auto data_ptr = reinterpret_cast<int8_t*>(render_group_values_.data());
167  data_ptr, row_count, render_group_column_descriptor_->columnType);
168  }
169  }
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
SQLTypeInfo columnType
std::vector< int32_t > render_group_values_
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 211 of file GeospatialEncoder.h.

References CHECK, and UNREACHABLE.

Referenced by appendArrayDatumsToBufferAndUpdateMetadata().

214  {
215  if (!encoder) {
216  CHECK(!chunk_metadata);
217  return;
218  }
219  if (auto fixed_len_array_encoder =
220  dynamic_cast<FixedLengthArrayNoneEncoder*>(encoder)) {
221  auto new_chunk_metadata = fixed_len_array_encoder->appendData(
222  &datum_parse_buffer, 0, datum_parse_buffer.size());
223  *chunk_metadata = *new_chunk_metadata;
224  } else if (auto array_encoder = dynamic_cast<ArrayNoneEncoder*>(encoder)) {
225  auto new_chunk_metadata = array_encoder->appendData(
226  &datum_parse_buffer, 0, datum_parse_buffer.size(), false);
227  *chunk_metadata = *new_chunk_metadata;
228  } else {
229  UNREACHABLE();
230  }
231  }
#define UNREACHABLE()
Definition: Logger.h:253
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the caller graph for this function:

void foreign_storage::GeospatialEncoder::clearDatumBuffers ( )
inlineprotected

Definition at line 318 of file GeospatialEncoder.h.

References bounds_datum_buffer_, coords_datum_buffer_, poly_rings_datum_buffer_, and ring_sizes_datum_buffer_.

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

318  {
319  coords_datum_buffer_.clear();
320  bounds_datum_buffer_.clear();
321  ring_sizes_datum_buffer_.clear();
322  poly_rings_datum_buffer_.clear();
323  }
std::vector< ArrayDatum > coords_datum_buffer_
std::vector< ArrayDatum > bounds_datum_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 311 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().

311  {
312  coords_parse_buffer_.clear();
313  bounds_parse_buffer_.clear();
314  ring_sizes_parse_buffer_.clear();
315  poly_rings_parse_buffer_.clear();
316  }
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 412 of file GeospatialEncoder.h.

References getIteratorForGeoColumnType().

Referenced by GeospatialEncoder().

414  {
415  auto chunk = getIteratorForGeoColumnType(chunks, sql_type, geo_column_type);
416  auto column_descriptor = chunk->getColumnDesc();
417  return column_descriptor;
418  }
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:

+ Here is the caller 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 328 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().

331  {
332  auto list_iter = list.begin();
333  list_iter++; // skip base column
334  switch (column_type) {
335  case kPOINT: {
336  if (geo_column == COORDS) {
337  return list_iter;
338  }
339  UNREACHABLE();
340  }
341  case kLINESTRING: {
342  if (geo_column == COORDS) {
343  return list_iter;
344  }
345  list_iter++;
346  if (geo_column == BOUNDS) {
347  return list_iter;
348  }
349  UNREACHABLE();
350  }
351  case kPOLYGON: {
352  if (geo_column == COORDS) {
353  return list_iter;
354  }
355  list_iter++;
356  if (geo_column == RING_SIZES) {
357  return list_iter;
358  }
359  list_iter++;
360  if (geo_column == BOUNDS) {
361  return list_iter;
362  }
363  list_iter++;
364  if (geo_column == RENDER_GROUP) {
365  return list_iter;
366  }
367  UNREACHABLE();
368  }
369  case kMULTIPOLYGON: {
370  if (geo_column == COORDS) {
371  return list_iter;
372  }
373  list_iter++;
374  if (geo_column == RING_SIZES) {
375  return list_iter;
376  }
377  list_iter++;
378  if (geo_column == POLY_RINGS) {
379  return list_iter;
380  }
381  list_iter++;
382  if (geo_column == BOUNDS) {
383  return list_iter;
384  }
385  list_iter++;
386  if (geo_column == RENDER_GROUP) {
387  return list_iter;
388  }
389  UNREACHABLE();
390  }
391  default:
392  UNREACHABLE();
393  }
394  return {};
395  }
#define UNREACHABLE()
Definition: Logger.h:253

+ Here is the caller graph for this function:

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

Definition at line 433 of file GeospatialEncoder.h.

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

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

433  {
434  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
435  return geo_column_type == kLINESTRING || geo_column_type == kPOLYGON ||
436  geo_column_type == kMULTIPOLYGON;
437  }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
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 449 of file GeospatialEncoder.h.

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

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

449  {
450  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
451  return geo_column_type == kMULTIPOLYGON;
452  }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
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 444 of file GeospatialEncoder.h.

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

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

444  {
445  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
446  return geo_column_type == kPOLYGON || geo_column_type == kMULTIPOLYGON;
447  }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
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 439 of file GeospatialEncoder.h.

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

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

439  {
440  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
441  return geo_column_type == kPOLYGON || geo_column_type == kMULTIPOLYGON;
442  }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
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 398 of file GeospatialEncoder.h.

References getIteratorForGeoColumnType().

Referenced by GeospatialEncoder().

402  {
403  auto chunk = getIteratorForGeoColumnType(chunks, sql_type, geo_column_type);
404  chunk->initEncoder();
405  auto encoder = chunk->getBuffer()->getEncoder();
406  auto metadata =
407  getIteratorForGeoColumnType(chunk_metadata, sql_type, geo_column_type)->get();
408  auto column_descriptor = chunk->getColumnDesc();
409  return {encoder, metadata, column_descriptor};
410  }
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:

+ Here is the caller graph for this function:

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

Definition at line 233 of file GeospatialEncoder.h.

References bounds_datum_buffer_, bounds_parse_buffer_, 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(), hasRingSizesColumn(), kMULTIPOLYGON, kPOLYGON, poly_rings_datum_buffer_, poly_rings_parse_buffer_, PROMOTE_POLYGON_TO_MULTIPOLYGON, 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().

233  {
235  if (!Geospatial::GeoTypesFactory::getGeoColumns(std::string(geo_string_view),
236  import_ti,
243  }
244 
245  // validate types
246  if (geo_column_descriptor_->columnType.get_type() != import_ti.get_type()) {
248  !(import_ti.get_type() == SQLTypes::kPOLYGON &&
251  }
252  }
253 
254  // append coords
255  std::vector<uint8_t> compressed_coords = Geospatial::compress_coords(
257  coords_datum_buffer_.emplace_back(encode_as_array_datum(compressed_coords));
258 
259  // append bounds
260  if (hasBoundsColumn()) {
262  }
263 
264  // append ring sizes
265  if (hasRingSizesColumn()) {
266  ring_sizes_datum_buffer_.emplace_back(
268  }
269 
270  // append poly rings
271  if (hasPolyRingsColumn()) {
272  poly_rings_datum_buffer_.emplace_back(
274  }
275  }
static void throwMismatchedGeoElement(const std::string &omnisci_column_name)
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:329
static void throwMalformedGeoElement(const std::string &omnisci_column_name)
std::vector< uint8_t > compress_coords(const std::vector< double > &coords, const SQLTypeInfo &ti)
Definition: Compression.cpp:52
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:937
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

+ 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 277 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(), hasRingSizesColumn(), kPOINT, poly_rings_column_descriptor_, poly_rings_datum_buffer_, poly_rings_parse_buffer_, PROMOTE_POLYGON_TO_MULTIPOLYGON, 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().

277  {
285  // POINT columns are represented using fixed length arrays and need
286  // special treatment of nulls
288  std::vector<uint8_t> compressed_coords = Geospatial::compress_coords(
290  coords_datum_buffer_.emplace_back(encode_as_array_datum(compressed_coords));
291  } else {
294  }
295  if (hasBoundsColumn()) {
298  }
299  if (hasRingSizesColumn()) {
300  ring_sizes_datum_buffer_.emplace_back(
303  }
304  if (hasPolyRingsColumn()) {
305  poly_rings_datum_buffer_.emplace_back(
308  }
309  }
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:410
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:1144
std::vector< ArrayDatum > bounds_datum_buffer_
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
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 420 of file GeospatialEncoder.h.

Referenced by processGeoElement().

420  {
421  std::string error_message = "Failed to extract valid geometry in OmniSci column '" +
422  omnisci_column_name + "'.";
423  throw foreign_storage::ForeignStorageException(error_message);
424  }

+ Here is the caller graph for this function:

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

Definition at line 426 of file GeospatialEncoder.h.

Referenced by processGeoElement().

426  {
428  "Imported geometry"
429  " doesn't match the geospatial type of OmniSci column '" +
430  omnisci_column_name + "'.");
431  }

+ Here is the caller graph for this function:

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

Definition at line 171 of file GeospatialEncoder.h.

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

Referenced by GeospatialEncoder().

171  {
172  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
173  if (geo_column_type == kPOINT) {
174  CHECK(chunks.size() == 2);
175  } else if (geo_column_type == kLINESTRING) {
176  CHECK(chunks.size() == 3);
177  } else if (geo_column_type == kPOLYGON) {
178  CHECK(chunks.size() == 5);
179  } else if (geo_column_type == kMULTIPOLYGON) {
180  CHECK(chunks.size() == 6);
181  }
182  }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
#define CHECK(condition)
Definition: Logger.h:209
const ColumnDescriptor * geo_column_descriptor_
SQLTypeInfo columnType

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 184 of file GeospatialEncoder.h.

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

Referenced by GeospatialEncoder().

185  {
186  const auto geo_column_type = geo_column_descriptor_->columnType.get_type();
187  if (geo_column_type == kPOINT) {
188  CHECK(chunk_metadata.size() == 2);
189  } else if (geo_column_type == kLINESTRING) {
190  CHECK(chunk_metadata.size() == 3);
191  } else if (geo_column_type == kPOLYGON) {
192  CHECK(chunk_metadata.size() == 5);
193  } else if (geo_column_type == kMULTIPOLYGON) {
194  CHECK(chunk_metadata.size() == 6);
195  }
196  }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
#define CHECK(condition)
Definition: Logger.h:209
const ColumnDescriptor * geo_column_descriptor_
SQLTypeInfo columnType

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

StringNoneEncoder* foreign_storage::GeospatialEncoder::base_column_encoder_
protected
ChunkMetadata* foreign_storage::GeospatialEncoder::base_column_metadata_
protected
std::vector<std::string> foreign_storage::GeospatialEncoder::base_values_
protected

Definition at line 479 of file GeospatialEncoder.h.

Referenced by appendBaseAndRenderGroupDataAndUpdateMetadata().

const ColumnDescriptor* foreign_storage::GeospatialEncoder::bounds_column_descriptor_
protected

Definition at line 473 of file GeospatialEncoder.h.

Referenced by GeospatialEncoder(), and processNullGeoElement().

Encoder* foreign_storage::GeospatialEncoder::bounds_column_encoder_
protected
ChunkMetadata* foreign_storage::GeospatialEncoder::bounds_column_metadata_
protected
std::vector<double> foreign_storage::GeospatialEncoder::bounds_parse_buffer_
protected
const ColumnDescriptor* foreign_storage::GeospatialEncoder::coords_column_descriptor_
protected

Definition at line 472 of file GeospatialEncoder.h.

Referenced by GeospatialEncoder(), and processNullGeoElement().

Encoder* foreign_storage::GeospatialEncoder::coords_column_encoder_
protected
ChunkMetadata* foreign_storage::GeospatialEncoder::coords_column_metadata_
protected
std::vector<double> foreign_storage::GeospatialEncoder::coords_parse_buffer_
protected
const ColumnDescriptor* foreign_storage::GeospatialEncoder::poly_rings_column_descriptor_
protected

Definition at line 475 of file GeospatialEncoder.h.

Referenced by GeospatialEncoder(), and processNullGeoElement().

Encoder* foreign_storage::GeospatialEncoder::poly_rings_column_encoder_
protected
ChunkMetadata* foreign_storage::GeospatialEncoder::poly_rings_column_metadata_
protected
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 456 of file GeospatialEncoder.h.

Referenced by processGeoElement(), and processNullGeoElement().

const ColumnDescriptor* foreign_storage::GeospatialEncoder::render_group_column_descriptor_
protected
Encoder* foreign_storage::GeospatialEncoder::render_group_column_encoder_
protected
ChunkMetadata* foreign_storage::GeospatialEncoder::render_group_column_metadata_
protected
std::vector<int32_t> foreign_storage::GeospatialEncoder::render_group_values_
protected
const ColumnDescriptor* foreign_storage::GeospatialEncoder::ring_sizes_column_descriptor_
protected

Definition at line 474 of file GeospatialEncoder.h.

Referenced by GeospatialEncoder(), and processNullGeoElement().

Encoder* foreign_storage::GeospatialEncoder::ring_sizes_column_encoder_
protected
ChunkMetadata* foreign_storage::GeospatialEncoder::ring_sizes_column_metadata_
protected
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: