OmniSciDB  ba1bac9284
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 622 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 628 of file TargetValueConvertersImpl.h.

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

631  : TargetValueConverter(logicalColumnDescriptor) {
635 
636  if (num_rows) {
637  allocateColumnarData(num_rows);
638  }
639  }
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:206

+ Here is the call graph for this function:

GeoPointValueConverter::~GeoPointValueConverter ( )
inlineoverride

Definition at line 641 of file TargetValueConvertersImpl.h.

641 {}

Member Function Documentation

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

Implements TargetValueConverter.

Reimplemented in GeoMultiPolygonValueConverter, GeoPolygonValueConverter, and GeoLinestringValueConverter.

Definition at line 690 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 GeoLinestringValueConverter::addDataBlocksToInsertData(), GeoPolygonValueConverter::addDataBlocksToInsertData(), and GeoMultiPolygonValueConverter::addDataBlocksToInsertData().

690  {
691  DataBlockPtr logical, coords;
692 
693  logical.stringsPtr = column_data_.get();
695 
696  insertData.data.emplace_back(logical);
697  insertData.columnIds.emplace_back(column_descriptor_->columnId);
698 
699  insertData.data.emplace_back(coords);
700  insertData.columnIds.emplace_back(coords_column_descriptor_->columnId);
701  }
std::vector< std::string > * stringsPtr
Definition: sqltypes.h:221
std::vector< ArrayDatum > * arraysPtr
Definition: sqltypes.h:222
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:64
const ColumnDescriptor * coords_column_descriptor_
std::vector< int > columnIds
identifies the table into which the data is being inserted
Definition: Fragmenter.h:62
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, and GeoLinestringValueConverter.

Definition at line 643 of file TargetValueConvertersImpl.h.

References CHECK, column_data_, and signed_compressed_coords_data_.

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

643  {
644  CHECK(num_rows > 0);
645  column_data_ = std::make_unique<std::vector<std::string>>(num_rows);
646  signed_compressed_coords_data_ = std::make_unique<std::vector<ArrayDatum>>(num_rows);
647  }
std::unique_ptr< std::vector< std::string > > column_data_
#define CHECK(condition)
Definition: Logger.h:206
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, and GeoLinestringValueConverter.

Definition at line 668 of file TargetValueConvertersImpl.h.

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

668  {
669  const auto geoValue = checked_get<GeoTargetValue>(row, value, GEO_VALUE_ACCESSOR);
670  CHECK(geoValue);
671  if (geoValue->is_initialized()) {
672  const auto geo = geoValue->get();
673  const auto geoPoint =
674  checked_get<GeoPointTargetValue>(row, &geo, GEO_POINT_VALUE_ACCESSOR);
675  CHECK(geoPoint);
676  (*column_data_)[row] = "";
677  (*signed_compressed_coords_data_)[row] = toCompressedCoords(geoPoint->coords);
678  } else {
679  // NULL point
680  (*column_data_)[row] = "";
681  auto coords = std::make_shared<std::vector<double>>();
682  coords->push_back(NULL_ARRAY_DOUBLE);
683  coords->push_back(NULL_DOUBLE);
684  auto coords_datum = toCompressedCoords(coords);
685  coords_datum.is_null = true;
686  (*signed_compressed_coords_data_)[row] = coords_datum;
687  }
688  }
#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:206
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 652 of file TargetValueConvertersImpl.h.

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

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

653  {
654  const auto compressed_coords_vector =
656 
657  uint8_t* compressed_coords_array = reinterpret_cast<uint8_t*>(
658  checked_malloc(sizeof(uint8_t) * compressed_coords_vector.size()));
659  memcpy(compressed_coords_array,
660  &compressed_coords_vector[0],
661  compressed_coords_vector.size());
662 
663  return ArrayDatum((int)compressed_coords_vector.size(),
664  reinterpret_cast<int8_t*>(compressed_coords_array),
665  false);
666  }
const ColumnDescriptor * column_descriptor_
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Definition: sqltypes.h:202
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 625 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 650 of file TargetValueConvertersImpl.h.

Referenced by convertToColumnarFormat().

boost_variant_accessor<GeoTargetValue> GeoPointValueConverter::GEO_VALUE_ACCESSOR

Definition at line 649 of file TargetValueConvertersImpl.h.

Referenced by convertToColumnarFormat().

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

Definition at line 626 of file TargetValueConvertersImpl.h.

Referenced by addDataBlocksToInsertData(), and allocateColumnarData().


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