OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LazyParquetChunkLoader.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 <arrow/filesystem/filesystem.h>
20 #include <parquet/schema.h>
21 
22 #include "DataMgr/Chunk/Chunk.h"
23 #include "ForeignTableSchema.h"
24 #include "Interval.h"
25 #include "ParquetEncoder.h"
26 #include "ParquetShared.h"
27 
28 extern size_t g_max_import_threads;
29 
30 namespace foreign_storage {
31 
36  public:
37  // The number of elements in a batch that are read from the Parquet file;
38  // this number is subject to change with performance tuning.
39  // Most filesystems use a default block size of 4096 bytes.
40  const static int batch_reader_num_elements = 4096;
41 
42  LazyParquetChunkLoader(std::shared_ptr<arrow::fs::FileSystem> file_system,
43  FileReaderMap* file_reader_cache);
44 
68  std::list<std::unique_ptr<ChunkMetadata>> loadChunk(
69  const std::vector<RowGroupInterval>& row_group_intervals,
70  const int parquet_column_index,
71  std::list<Chunk_NS::Chunk>& chunks,
72  StringDictionary* string_dictionary = nullptr);
73 
82  std::list<RowGroupMetadata> metadataScan(const std::vector<std::string>& file_paths,
83  const ForeignTableSchema& schema);
84 
94  static bool isColumnMappingSupported(const ColumnDescriptor* omnisci_column,
95  const parquet::ColumnDescriptor* parquet_column);
96 
114  std::pair<size_t, size_t> loadRowGroups(
115  const RowGroupInterval& row_group_interval,
116  const std::map<int, Chunk_NS::Chunk>& chunks,
117  const ForeignTableSchema& schema,
118  const std::map<int, StringDictionary*>& column_dictionaries);
119 
120  private:
121  std::shared_ptr<arrow::fs::FileSystem> file_system_;
123 
124  std::list<std::unique_ptr<ChunkMetadata>> appendRowGroups(
125  const std::vector<RowGroupInterval>& row_group_intervals,
126  const int parquet_column_index,
127  const ColumnDescriptor* column_descriptor,
128  std::list<Chunk_NS::Chunk>& chunks,
129  StringDictionary* string_dictionary);
130 };
131 } // namespace foreign_storage
static bool isColumnMappingSupported(const ColumnDescriptor *omnisci_column, const parquet::ColumnDescriptor *parquet_column)
std::list< std::unique_ptr< ChunkMetadata > > loadChunk(const std::vector< RowGroupInterval > &row_group_intervals, const int parquet_column_index, std::list< Chunk_NS::Chunk > &chunks, StringDictionary *string_dictionary=nullptr)
LazyParquetChunkLoader(std::shared_ptr< arrow::fs::FileSystem > file_system, FileReaderMap *file_reader_cache)
std::list< std::unique_ptr< ChunkMetadata > > appendRowGroups(const std::vector< RowGroupInterval > &row_group_intervals, const int parquet_column_index, const ColumnDescriptor *column_descriptor, std::list< Chunk_NS::Chunk > &chunks, StringDictionary *string_dictionary)
specifies the content in-memory of a row in the column metadata table
std::shared_ptr< arrow::fs::FileSystem > file_system_
std::list< RowGroupMetadata > metadataScan(const std::vector< std::string > &file_paths, const ForeignTableSchema &schema)
Perform a metadata scan for the paths specified.
std::pair< size_t, size_t > loadRowGroups(const RowGroupInterval &row_group_interval, const std::map< int, Chunk_NS::Chunk > &chunks, const ForeignTableSchema &schema, const std::map< int, StringDictionary * > &column_dictionaries)
Load row groups of data into given chunks.
size_t g_max_import_threads
Definition: Importer.cpp:85