OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GeoPointValueConverter Struct Reference

#include <TargetValueConvertersImpl.h>

+ Inheritance diagram for GeoPointValueConverter:
+ Collaboration diagram for GeoPointValueConverter:

Public Member Functions

 GeoPointValueConverter (const Catalog_Namespace::Catalog &cat, size_t num_rows, const ColumnDescriptor *logicalColumnDescriptor)
 
 ~GeoPointValueConverter () override
 
void allocateColumnarData (size_t num_rows) override
 
ArrayDatum toCompressedCoords (const std::shared_ptr< std::vector< double >> &coords)
 
void convertToColumnarFormat (size_t row, const TargetValue *value) override
 
void addDataBlocksToInsertData (Fragmenter_Namespace::InsertData &insertData) override
 
- Public Member Functions inherited from TargetValueConverter
 TargetValueConverter (const ColumnDescriptor *cd)
 
virtual ~TargetValueConverter ()
 
virtual void finalizeDataBlocksForInsertData ()
 

Public Attributes

const ColumnDescriptorcoords_column_descriptor_
 
std::unique_ptr< std::vector
< std::string > > 
column_data_
 
std::unique_ptr< std::vector
< ArrayDatum > > 
signed_compressed_coords_data_
 
boost_variant_accessor
< GeoTargetValue
GEO_VALUE_ACCESSOR
 
boost_variant_accessor
< GeoPointTargetValue
GEO_POINT_VALUE_ACCESSOR
 
- Public Attributes inherited from TargetValueConverter
const ColumnDescriptorcolumn_descriptor_
 
boost_variant_accessor
< ScalarTargetValue
SCALAR_TARGET_VALUE_ACCESSOR
 
boost_variant_accessor
< ArrayTargetValue
ARRAY_TARGET_VALUE_ACCESSOR
 
boost_variant_accessor
< GeoTargetValue
GEO_TARGET_VALUE_ACCESSOR
 
boost_variant_accessor
< NullableString
NULLABLE_STRING_ACCESSOR
 
boost_variant_accessor
< std::string > 
STRING_ACCESSOR
 

Detailed Description

Definition at line 623 of file TargetValueConvertersImpl.h.

Constructor & Destructor Documentation

GeoPointValueConverter::GeoPointValueConverter ( const Catalog_Namespace::Catalog cat,
size_t  num_rows,
const ColumnDescriptor logicalColumnDescriptor 
)
inline

Definition at line 629 of file TargetValueConvertersImpl.h.

References allocateColumnarData(), CHECK, TargetValueConverter::column_descriptor_, ColumnDescriptor::columnId, coords_column_descriptor_, Catalog_Namespace::Catalog::getMetadataForColumn(), and ColumnDescriptor::tableId.

632  : TargetValueConverter(logicalColumnDescriptor) {
636 
637  if (num_rows) {
638  allocateColumnarData(num_rows);
639  }
640  }
TargetValueConverter(const ColumnDescriptor *cd)
void allocateColumnarData(size_t num_rows) override
const ColumnDescriptor * column_descriptor_
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
const ColumnDescriptor * coords_column_descriptor_
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

GeoPointValueConverter::~GeoPointValueConverter ( )
inlineoverride

Definition at line 642 of file TargetValueConvertersImpl.h.

642 {}

Member Function Documentation

void GeoPointValueConverter::addDataBlocksToInsertData ( Fragmenter_Namespace::InsertData insertData)
inlineoverridevirtual

Implements TargetValueConverter.

Reimplemented in GeoMultiPolygonValueConverter, GeoPolygonValueConverter, GeoMultiLinestringValueConverter, GeoLinestringValueConverter, and GeoMultiPointValueConverter.

Definition at line 691 of file TargetValueConvertersImpl.h.

References DataBlockPtr::arraysPtr, column_data_, TargetValueConverter::column_descriptor_, ColumnDescriptor::columnId, Fragmenter_Namespace::InsertData::columnIds, coords_column_descriptor_, Fragmenter_Namespace::InsertData::data, signed_compressed_coords_data_, and DataBlockPtr::stringsPtr.

Referenced by GeoMultiPointValueConverter::addDataBlocksToInsertData(), GeoLinestringValueConverter::addDataBlocksToInsertData(), GeoMultiLinestringValueConverter::addDataBlocksToInsertData(), GeoPolygonValueConverter::addDataBlocksToInsertData(), and GeoMultiPolygonValueConverter::addDataBlocksToInsertData().

691  {
692  DataBlockPtr logical, coords;
693 
694  logical.stringsPtr = column_data_.get();
696 
697  insertData.data.emplace_back(logical);
698  insertData.columnIds.emplace_back(column_descriptor_->columnId);
699 
700  insertData.data.emplace_back(coords);
701  insertData.columnIds.emplace_back(coords_column_descriptor_->columnId);
702  }
std::vector< std::string > * stringsPtr
Definition: sqltypes.h:234
std::vector< ArrayDatum > * arraysPtr
Definition: sqltypes.h:235
const ColumnDescriptor * column_descriptor_
std::unique_ptr< std::vector< std::string > > column_data_
std::vector< DataBlockPtr > data
the number of rows being inserted
Definition: Fragmenter.h:73
const ColumnDescriptor * coords_column_descriptor_
std::vector< int > columnIds
identifies the table into which the data is being inserted
Definition: Fragmenter.h:71
std::unique_ptr< std::vector< ArrayDatum > > signed_compressed_coords_data_

+ Here is the caller graph for this function:

void GeoPointValueConverter::allocateColumnarData ( size_t  num_rows)
inlineoverridevirtual

Implements TargetValueConverter.

Reimplemented in GeoMultiPolygonValueConverter, GeoPolygonValueConverter, GeoMultiLinestringValueConverter, GeoLinestringValueConverter, and GeoMultiPointValueConverter.

Definition at line 644 of file TargetValueConvertersImpl.h.

References CHECK, column_data_, and signed_compressed_coords_data_.

Referenced by GeoMultiPointValueConverter::allocateColumnarData(), GeoLinestringValueConverter::allocateColumnarData(), GeoMultiLinestringValueConverter::allocateColumnarData(), GeoPolygonValueConverter::allocateColumnarData(), GeoMultiPolygonValueConverter::allocateColumnarData(), and GeoPointValueConverter().

644  {
645  CHECK(num_rows > 0);
646  column_data_ = std::make_unique<std::vector<std::string>>(num_rows);
647  signed_compressed_coords_data_ = std::make_unique<std::vector<ArrayDatum>>(num_rows);
648  }
std::unique_ptr< std::vector< std::string > > column_data_
#define CHECK(condition)
Definition: Logger.h:291
std::unique_ptr< std::vector< ArrayDatum > > signed_compressed_coords_data_

+ Here is the caller graph for this function:

void GeoPointValueConverter::convertToColumnarFormat ( size_t  row,
const TargetValue value 
)
inlineoverridevirtual

Implements TargetValueConverter.

Reimplemented in GeoMultiPolygonValueConverter, GeoPolygonValueConverter, GeoMultiLinestringValueConverter, GeoLinestringValueConverter, and GeoMultiPointValueConverter.

Definition at line 669 of file TargetValueConvertersImpl.h.

References CHECK, GEO_POINT_VALUE_ACCESSOR, GEO_VALUE_ACCESSOR, NULL_ARRAY_DOUBLE, NULL_DOUBLE, and toCompressedCoords().

669  {
670  const auto geoValue = checked_get<GeoTargetValue>(row, value, GEO_VALUE_ACCESSOR);
671  CHECK(geoValue);
672  if (geoValue->is_initialized()) {
673  const auto geo = geoValue->get();
674  const auto geoPoint =
675  checked_get<GeoPointTargetValue>(row, &geo, GEO_POINT_VALUE_ACCESSOR);
676  CHECK(geoPoint);
677  (*column_data_)[row] = "";
678  (*signed_compressed_coords_data_)[row] = toCompressedCoords(geoPoint->coords);
679  } else {
680  // NULL point
681  (*column_data_)[row] = "";
682  auto coords = std::make_shared<std::vector<double>>();
683  coords->push_back(NULL_ARRAY_DOUBLE);
684  coords->push_back(NULL_DOUBLE);
685  auto coords_datum = toCompressedCoords(coords);
686  coords_datum.is_null = true;
687  (*signed_compressed_coords_data_)[row] = coords_datum;
688  }
689  }
#define NULL_DOUBLE
ArrayDatum toCompressedCoords(const std::shared_ptr< std::vector< double >> &coords)
boost_variant_accessor< GeoTargetValue > GEO_VALUE_ACCESSOR
#define NULL_ARRAY_DOUBLE
#define CHECK(condition)
Definition: Logger.h:291
boost_variant_accessor< GeoPointTargetValue > GEO_POINT_VALUE_ACCESSOR

+ Here is the call graph for this function:

ArrayDatum GeoPointValueConverter::toCompressedCoords ( const std::shared_ptr< std::vector< double >> &  coords)
inline

Definition at line 653 of file TargetValueConvertersImpl.h.

References checked_malloc(), TargetValueConverter::column_descriptor_, ColumnDescriptor::columnType, and Geospatial::compress_coords().

Referenced by convertToColumnarFormat(), GeoMultiPointValueConverter::convertToColumnarFormat(), GeoLinestringValueConverter::convertToColumnarFormat(), GeoMultiLinestringValueConverter::convertToColumnarFormat(), GeoPolygonValueConverter::convertToColumnarFormat(), and GeoMultiPolygonValueConverter::convertToColumnarFormat().

654  {
655  const auto compressed_coords_vector =
657 
658  uint8_t* compressed_coords_array = reinterpret_cast<uint8_t*>(
659  checked_malloc(sizeof(uint8_t) * compressed_coords_vector.size()));
660  memcpy(compressed_coords_array,
661  &compressed_coords_vector[0],
662  compressed_coords_vector.size());
663 
664  return ArrayDatum((int)compressed_coords_vector.size(),
665  reinterpret_cast<int8_t*>(compressed_coords_array),
666  false);
667  }
const ColumnDescriptor * column_descriptor_
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Definition: sqltypes.h:229
std::vector< uint8_t > compress_coords(const std::vector< double > &coords, const SQLTypeInfo &ti)
Definition: Compression.cpp:52
void * checked_malloc(const size_t size)
Definition: checked_alloc.h:45
SQLTypeInfo columnType

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

std::unique_ptr<std::vector<std::string> > GeoPointValueConverter::column_data_

Definition at line 626 of file TargetValueConvertersImpl.h.

Referenced by addDataBlocksToInsertData(), and allocateColumnarData().

const ColumnDescriptor* GeoPointValueConverter::coords_column_descriptor_
boost_variant_accessor<GeoPointTargetValue> GeoPointValueConverter::GEO_POINT_VALUE_ACCESSOR

Definition at line 651 of file TargetValueConvertersImpl.h.

Referenced by convertToColumnarFormat().

boost_variant_accessor<GeoTargetValue> GeoPointValueConverter::GEO_VALUE_ACCESSOR

Definition at line 650 of file TargetValueConvertersImpl.h.

Referenced by convertToColumnarFormat().

std::unique_ptr<std::vector<ArrayDatum> > GeoPointValueConverter::signed_compressed_coords_data_

Definition at line 627 of file TargetValueConvertersImpl.h.

Referenced by addDataBlocksToInsertData(), and allocateColumnarData().


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