OmniSciDB  72c90bc290
 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 2022 HEAVY.AI, 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 ForeignTable* foreign_table);
47 
71  std::list<std::unique_ptr<ChunkMetadata>> loadChunk(
72  const std::vector<RowGroupInterval>& row_group_intervals,
73  const int parquet_column_index,
74  std::list<Chunk_NS::Chunk>& chunks,
75  StringDictionary* string_dictionary = nullptr,
76  RejectedRowIndices* rejected_row_indices = nullptr);
77 
88  std::list<RowGroupMetadata> metadataScan(
89  const std::vector<std::string>& file_paths,
90  const ForeignTableSchema& schema,
91  const bool do_metadata_stats_validation = true);
92 
102  static bool isColumnMappingSupported(const ColumnDescriptor* omnisci_column,
103  const parquet::ColumnDescriptor* parquet_column);
104 
123  std::pair<size_t, size_t> loadRowGroups(
124  const RowGroupInterval& row_group_interval,
125  const std::map<int, Chunk_NS::Chunk>& chunks,
126  const ForeignTableSchema& schema,
127  const std::map<int, StringDictionary*>& column_dictionaries,
128  const int num_threads = 1);
129 
140  DataPreview previewFiles(const std::vector<std::string>& files,
141  const size_t max_num_rows,
142  const ForeignTable& table);
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)
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)
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.
std::set< int64_t > RejectedRowIndices
DataPreview previewFiles(const std::vector< std::string > &files, const size_t max_num_rows, const ForeignTable &table)
Preview rows of data and column types in a set of files.
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)
LazyParquetChunkLoader(std::shared_ptr< arrow::fs::FileSystem > file_system, FileReaderMap *file_reader_cache, const ForeignTable *foreign_table)
std::shared_ptr< arrow::fs::FileSystem > file_system_
size_t g_max_import_threads
Definition: Importer.cpp:105
static SQLTypeInfo suggestColumnMapping(const parquet::ColumnDescriptor *parquet_column)