OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ParquetGeospatialEncoder.h
Go to the documentation of this file.
1 /*
2  * Copyright 2020 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <parquet/schema.h>
20 #include <parquet/types.h>
21 #include "GeospatialEncoder.h"
22 #include "ParquetEncoder.h"
23 
24 namespace foreign_storage {
25 
27  public:
29 
30  ParquetGeospatialEncoder(const parquet::ColumnDescriptor* parquet_column_descriptor,
31  std::list<Chunk_NS::Chunk>& chunks,
32  std::list<std::unique_ptr<ChunkMetadata>>& chunk_metadata)
33  : ParquetEncoder(nullptr), GeospatialEncoder(chunks, chunk_metadata) {}
34 
35  void appendData(const int16_t* def_levels,
36  const int16_t* rep_levels,
37  const int64_t values_read,
38  const int64_t levels_read,
39  int8_t* values) override {
40  auto parquet_data_ptr = reinterpret_cast<const parquet::ByteArray*>(values);
41 
43 
44  for (int64_t i = 0, j = 0; i < levels_read; ++i) {
46  if (def_levels[i] == 0) {
48  } else {
49  CHECK(j < values_read);
50  auto& byte_array = parquet_data_ptr[j++];
51  auto geo_string_view = std::string_view{
52  reinterpret_cast<const char*>(byte_array.ptr), byte_array.len};
53  processGeoElement(geo_string_view);
54  }
55  }
56 
58 
60  }
61 };
62 
63 } // namespace foreign_storage
void processGeoElement(std::string_view geo_string_view)
void appendData(const int16_t *def_levels, const int16_t *rep_levels, const int64_t values_read, const int64_t levels_read, int8_t *values) override
void appendBaseAndRenderGroupDataAndUpdateMetadata(const int64_t row_count)
#define CHECK(condition)
Definition: Logger.h:209
ParquetGeospatialEncoder(const parquet::ColumnDescriptor *parquet_column_descriptor, std::list< Chunk_NS::Chunk > &chunks, std::list< std::unique_ptr< ChunkMetadata >> &chunk_metadata)