29 namespace foreign_storage {
33 const size_t num_bytes = data.size() *
sizeof(
T);
34 std::shared_ptr<int8_t> buffer(
new int8_t[num_bytes], std::default_delete<int8_t[]>());
35 memcpy(buffer.get(), data.data(), num_bytes);
85 std::list<std::unique_ptr<ChunkMetadata>>& chunk_metadata,
86 const bool geo_validate_geometry)
107 auto base_chunk = chunks.begin();
108 base_chunk->initEncoder();
117 chunks, chunk_metadata, geo_column_type,
COORDS);
124 chunks, chunk_metadata, geo_column_type,
BOUNDS);
142 chunks, chunk_metadata, geo_column_type,
POLY_RINGS);
155 CHECK_EQ(chunks.size(), expected_size);
159 std::list<std::unique_ptr<ChunkMetadata>>& chunk_metadata)
const {
161 CHECK_EQ(chunk_metadata.size(), expected_size);
178 const std::vector<ArrayDatum>& datum_parse_buffer,
182 CHECK(!chunk_metadata);
185 if (
auto fixed_len_array_encoder =
186 dynamic_cast<FixedLengthArrayNoneEncoder*>(encoder)) {
187 auto new_chunk_metadata = fixed_len_array_encoder->appendData(
188 &datum_parse_buffer, 0, datum_parse_buffer.size());
189 *chunk_metadata = *new_chunk_metadata;
190 }
else if (
auto array_encoder = dynamic_cast<ArrayNoneEncoder*>(encoder)) {
191 auto new_chunk_metadata = array_encoder->appendData(
192 &datum_parse_buffer, 0, datum_parse_buffer.size(),
false);
193 *chunk_metadata = *new_chunk_metadata;
290 template <
typename T>
295 auto list_iter = list.begin();
297 switch (column_type) {
299 if (geo_column ==
COORDS) {
306 if (geo_column ==
COORDS) {
310 if (geo_column ==
BOUNDS) {
316 if (geo_column ==
COORDS) {
324 if (geo_column ==
BOUNDS) {
330 if (geo_column ==
COORDS) {
338 if (geo_column ==
BOUNDS) {
344 if (geo_column ==
COORDS) {
356 if (geo_column ==
BOUNDS) {
367 std::tuple<Encoder*, ChunkMetadata*, const ColumnDescriptor*>
369 std::list<Chunk_NS::Chunk>& chunks,
370 std::list<std::unique_ptr<ChunkMetadata>>& chunk_metadata,
374 chunk->initEncoder();
375 auto encoder = chunk->getBuffer()->getEncoder();
378 auto column_descriptor = chunk->getColumnDesc();
379 return {encoder, metadata, column_descriptor};
386 auto column_descriptor = chunk->getColumnDesc();
387 return column_descriptor;
391 std::string error_message =
"Failed to extract valid geometry in HeavyDB column '" +
392 omnisci_column_name +
"'.";
399 " doesn't match the geospatial type of HeavyDB column '" +
400 omnisci_column_name +
"'.");
static void throwMismatchedGeoElement(const std::string &omnisci_column_name)
bool geo_promoted_type_match(const SQLTypes a, const SQLTypes b)
void processNullGeoElement()
const ColumnDescriptor * poly_rings_column_descriptor_
ChunkMetadata * poly_rings_column_metadata_
std::vector< ArrayDatum > coords_datum_buffer_
std::vector< std::string > base_values_
GeospatialEncoder(std::list< Chunk_NS::Chunk > &chunks, const bool geo_validate_geometry)
static ArrayDatum composeNullArray(const SQLTypeInfo &ti)
std::vector< ArrayDatum > ring_or_line_sizes_datum_buffer_
std::vector< int > ring_or_line_sizes_parse_buffer_
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
Encoder * bounds_column_encoder_
void validateMetadataSizing(std::list< std::unique_ptr< ChunkMetadata >> &chunk_metadata) const
static void getNullGeoColumns(SQLTypeInfo &ti, std::vector< double > &coords, std::vector< double > &bounds, std::vector< int > &ring_sizes, std::vector< int > &poly_rings)
std::vector< ArrayDatum > bounds_datum_buffer_
HOST DEVICE SQLTypes get_type() const
void appendToArrayEncoderAndUpdateMetadata(const std::vector< ArrayDatum > &datum_parse_buffer, Encoder *encoder, ChunkMetadata *chunk_metadata) const
Encoder * ring_or_line_sizes_column_encoder_
static void throwMalformedGeoElement(const std::string &omnisci_column_name)
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Encoder * coords_column_encoder_
bool hasRingOrLineSizesColumn() const
std::vector< uint8_t > compress_coords(const std::vector< double > &coords, const SQLTypeInfo &ti)
int get_physical_cols() const
void appendArrayDatumsToBufferAndUpdateMetadata()
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 validate_with_geos_if_available)
void validateChunksSizing(std::list< Chunk_NS::Chunk > &chunks) const
bool hasBoundsColumn() const
specifies the content in-memory of a row in the column metadata table
void processGeoElement(std::string_view geo_string_view)
const ColumnDescriptor * getColumnDescriptor(std::list< Chunk_NS::Chunk > &chunks, const SQLTypes sql_type, GeoColumnType geo_column_type)
bool geo_validate_geometry_
ChunkMetadata * bounds_column_metadata_
ChunkMetadata * base_column_metadata_
ChunkMetadata * coords_column_metadata_
ChunkMetadata * ring_or_line_sizes_column_metadata_
const ColumnDescriptor * coords_column_descriptor_
std::vector< double > bounds_parse_buffer_
std::vector< double > coords_parse_buffer_
StringNoneEncoder * base_column_encoder_
unencoded fixed length array encoder
bool hasPolyRingsColumn() const
ArrayDatum encode_as_array_datum(const std::vector< T > &data)
std::vector< int > poly_rings_parse_buffer_
GeospatialEncoder(std::list< Chunk_NS::Chunk > &chunks, std::list< std::unique_ptr< ChunkMetadata >> &chunk_metadata, const bool geo_validate_geometry)
GeospatialEncoder(const bool geo_validate_geometry)
Encoder * poly_rings_column_encoder_
const ColumnDescriptor * geo_column_descriptor_
void appendBaseDataAndUpdateMetadata(const int64_t row_count)
const ColumnDescriptor * ring_or_line_sizes_column_descriptor_
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)
std::vector< ArrayDatum > poly_rings_datum_buffer_
std::list< T >::iterator getIteratorForGeoColumnType(std::list< T > &list, const SQLTypes column_type, const GeoColumnType geo_column)
virtual ~GeospatialEncoder()=default
const ColumnDescriptor * bounds_column_descriptor_