OmniSciDB  085a039ca4
 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 "DataPreview.h"
24 #include "ForeignTableSchema.h"
25 #include "Interval.h"
26 #include "ParquetEncoder.h"
27 #include "ParquetShared.h"
29 
30 extern size_t g_max_import_threads;
31 
32 namespace foreign_storage {
33 
38  public:
39  // The number of elements in a batch that are read from the Parquet file;
40  // this number is subject to change with performance tuning.
41  // Most filesystems use a default block size of 4096 bytes.
42  const static int batch_reader_num_elements = 4096;
43 
44  LazyParquetChunkLoader(std::shared_ptr<arrow::fs::FileSystem> file_system,
45  FileReaderMap* file_reader_cache,
46  const RenderGroupAnalyzerMap* render_group_analyzer_map);
47 
73  std::list<std::unique_ptr<ChunkMetadata>> loadChunk(
74  const std::vector<RowGroupInterval>& row_group_intervals,
75  const int parquet_column_index,
76  std::list<Chunk_NS::Chunk>& chunks,
77  StringDictionary* string_dictionary = nullptr,
78  RejectedRowIndices* rejected_row_indices = nullptr);
79 
90  std::list<RowGroupMetadata> metadataScan(
91  const std::vector<std::string>& file_paths,
92  const ForeignTableSchema& schema,
93  const bool do_metadata_stats_validation = true);
94 
104  static bool isColumnMappingSupported(const ColumnDescriptor* omnisci_column,
105  const parquet::ColumnDescriptor* parquet_column);
106 
125  std::pair<size_t, size_t> loadRowGroups(
126  const RowGroupInterval& row_group_interval,
127  const std::map<int, Chunk_NS::Chunk>& chunks,
128  const ForeignTableSchema& schema,
129  const std::map<int, StringDictionary*>& column_dictionaries,
130  const int num_threads = 1);
131 
141  DataPreview previewFiles(const std::vector<std::string>& files,
142  const size_t max_num_rows);
143 
144  private:
158  const parquet::ColumnDescriptor* parquet_column);
159 
160  std::list<std::unique_ptr<ChunkMetadata>> appendRowGroups(
161  const std::vector<RowGroupInterval>& row_group_intervals,
162  const int parquet_column_index,
163  const ColumnDescriptor* column_descriptor,
164  std::list<Chunk_NS::Chunk>& chunks,
165  StringDictionary* string_dictionary,
166  RejectedRowIndices* rejected_row_indices,
167  const bool is_for_detect = false,
168  const std::optional<int64_t> max_levels_read = std::nullopt);
169 
170  std::shared_ptr<arrow::fs::FileSystem> file_system_;
172 
174 };
175 } // namespace foreign_storage
static bool isColumnMappingSupported(const ColumnDescriptor *omnisci_column, const parquet::ColumnDescriptor *parquet_column)
const RenderGroupAnalyzerMap * render_group_analyzer_map_
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, RejectedRowIndices *rejected_row_indices=nullptr)
DataPreview previewFiles(const std::vector< std::string > &files, const size_t max_num_rows)
Preview rows of data and column types in a set of files.
specifies the content in-memory of a row in the column metadata table
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, const int num_threads=1)
Load row groups of data into given chunks.
std::list< RowGroupMetadata > metadataScan(const std::vector< std::string > &file_paths, const ForeignTableSchema &schema, const bool do_metadata_stats_validation=true)
Perform a metadata scan for the paths specified.
LazyParquetChunkLoader(std::shared_ptr< arrow::fs::FileSystem > file_system, FileReaderMap *file_reader_cache, const RenderGroupAnalyzerMap *render_group_analyzer_map)
std::set< int64_t > RejectedRowIndices
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, RejectedRowIndices *rejected_row_indices, const bool is_for_detect=false, const std::optional< int64_t > max_levels_read=std::nullopt)
std::shared_ptr< arrow::fs::FileSystem > file_system_
std::map< int, std::unique_ptr< import_export::RenderGroupAnalyzer >> RenderGroupAnalyzerMap
size_t g_max_import_threads
Definition: Importer.cpp:106
static SQLTypeInfo suggestColumnMapping(const parquet::ColumnDescriptor *parquet_column)