OmniSciDB  06b3bd477c
 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 620 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 626 of file TargetValueConvertersImpl.h.

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

629  : TargetValueConverter(logicalColumnDescriptor) {
633 
634  if (num_rows) {
636  }
637  }
const int8_t const int64_t * num_rows
TargetValueConverter(const ColumnDescriptor *cd)
void allocateColumnarData(size_t num_rows) override
const ColumnDescriptor * column_descriptor_
CHECK(cgen_state)
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
const ColumnDescriptor * coords_column_descriptor_

+ Here is the call graph for this function:

GeoPointValueConverter::~GeoPointValueConverter ( )
inlineoverride

Definition at line 639 of file TargetValueConvertersImpl.h.

639 {}

Member Function Documentation

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

Implements TargetValueConverter.

Reimplemented in GeoMultiPolygonValueConverter, GeoPolygonValueConverter, and GeoLinestringValueConverter.

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

686  {
687  DataBlockPtr logical, coords;
688 
689  logical.stringsPtr = column_data_.get();
691 
692  insertData.data.emplace_back(logical);
693  insertData.columnIds.emplace_back(column_descriptor_->columnId);
694 
695  insertData.data.emplace_back(coords);
696  insertData.columnIds.emplace_back(coords_column_descriptor_->columnId);
697  }
std::vector< std::string > * stringsPtr
Definition: sqltypes.h:149
std::vector< ArrayDatum > * arraysPtr
Definition: sqltypes.h:150
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 641 of file TargetValueConvertersImpl.h.

References CHECK(), column_data_, num_rows, and signed_compressed_coords_data_.

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

641  {
642  CHECK(num_rows > 0);
643  column_data_ = std::make_unique<std::vector<std::string>>(num_rows);
644  signed_compressed_coords_data_ = std::make_unique<std::vector<ArrayDatum>>(num_rows);
645  }
const int8_t const int64_t * num_rows
std::unique_ptr< std::vector< std::string > > column_data_
CHECK(cgen_state)
std::unique_ptr< std::vector< ArrayDatum > > signed_compressed_coords_data_

+ Here is the call graph for this function:

+ 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 666 of file TargetValueConvertersImpl.h.

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

666  {
667  const auto geoValue = checked_get<GeoTargetValue>(row, value, GEO_VALUE_ACCESSOR);
668  CHECK(geoValue);
669  if (geoValue->is_initialized()) {
670  const auto geo = geoValue->get();
671  const auto geoPoint =
672  checked_get<GeoPointTargetValue>(row, &geo, GEO_POINT_VALUE_ACCESSOR);
673  CHECK(geoPoint);
674  (*column_data_)[row] = "";
675  (*signed_compressed_coords_data_)[row] = toCompressedCoords(geoPoint->coords);
676  } else {
677  // NULL point
678  (*column_data_)[row] = "";
679  auto coords = std::make_shared<std::vector<double>>(NULL_ARRAY_DOUBLE, NULL_DOUBLE);
680  auto coords_datum = toCompressedCoords(coords);
681  coords_datum.is_null = true;
682  (*signed_compressed_coords_data_)[row] = coords_datum;
683  }
684  }
#define NULL_DOUBLE
Definition: sqltypes.h:185
#define NULL_ARRAY_DOUBLE
Definition: sqltypes.h:193
ArrayDatum toCompressedCoords(const std::shared_ptr< std::vector< double >> &coords)
CHECK(cgen_state)
boost_variant_accessor< GeoTargetValue > GEO_VALUE_ACCESSOR
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 650 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().

651  {
652  const auto compressed_coords_vector =
654 
655  uint8_t* compressed_coords_array = reinterpret_cast<uint8_t*>(
656  checked_malloc(sizeof(uint8_t) * compressed_coords_vector.size()));
657  memcpy(compressed_coords_array,
658  &compressed_coords_vector[0],
659  compressed_coords_vector.size());
660 
661  return ArrayDatum((int)compressed_coords_vector.size(),
662  reinterpret_cast<int8_t*>(compressed_coords_array),
663  false);
664  }
const ColumnDescriptor * column_descriptor_
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Definition: sqltypes.h:130
void * checked_malloc(const size_t size)
Definition: checked_alloc.h:44
std::vector< uint8_t > compress_coords(std::vector< double > &coords, const SQLTypeInfo &ti)
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 623 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 648 of file TargetValueConvertersImpl.h.

Referenced by convertToColumnarFormat().

boost_variant_accessor<GeoTargetValue> GeoPointValueConverter::GEO_VALUE_ACCESSOR

Definition at line 647 of file TargetValueConvertersImpl.h.

Referenced by convertToColumnarFormat().

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

Definition at line 624 of file TargetValueConvertersImpl.h.

Referenced by addDataBlocksToInsertData(), and allocateColumnarData().


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