OmniSciDB  085a039ca4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RegexFileBufferParser.h
Go to the documentation of this file.
1 /*
2  * Copyright 2021 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 
21 
22 namespace foreign_storage {
24  public:
25  RegexFileBufferParser(const ForeignTable* foreign_table);
26 
28  bool convert_data_blocks,
29  bool columns_are_pre_filtered = false) const override;
30 
32  const ForeignTable* foreign_table) const override;
33 
34  size_t findRowEndPosition(size_t& alloc_size,
35  std::unique_ptr<char[]>& buffer,
36  size_t& buffer_size,
37  const import_export::CopyParams& copy_params,
38  const size_t buffer_first_row_index,
39  unsigned int& num_rows_in_buffer,
40  FileReader* file_reader) const override;
41 
42  void validateFiles(const FileReader* file_reader,
43  const ForeignTable* foreign_table) const override;
44 
45  // For testing purposes only
46  static void setMaxBufferResize(size_t max_buffer_resize);
47 
48  inline static const std::string LINE_REGEX_KEY = "LINE_REGEX";
49  inline static const std::string LINE_START_REGEX_KEY = "LINE_START_REGEX";
50  inline static const std::string HEADER_KEY = "HEADER";
51 
52  private:
53  static size_t getMaxBufferResize();
54 
55  inline static size_t max_buffer_resize_{
57 
58  // Flag added for testing purposes only
59  inline static bool skip_first_line_{false};
60 
61  boost::regex line_regex_;
62  std::optional<boost::regex> line_start_regex_;
63 };
64 } // namespace foreign_storage
import_export::CopyParams validateAndGetCopyParams(const ForeignTable *foreign_table) const override
RegexFileBufferParser(const ForeignTable *foreign_table)
static void setMaxBufferResize(size_t max_buffer_resize)
size_t findRowEndPosition(size_t &alloc_size, std::unique_ptr< char[]> &buffer, size_t &buffer_size, const import_export::CopyParams &copy_params, const size_t buffer_first_row_index, unsigned int &num_rows_in_buffer, FileReader *file_reader) const override
std::optional< boost::regex > line_start_regex_
ParseBufferResult parseBuffer(ParseBufferRequest &request, bool convert_data_blocks, bool columns_are_pre_filtered=false) const override
static constexpr size_t max_import_buffer_resize_byte_size
Definition: CopyParams.h:37
void validateFiles(const FileReader *file_reader, const ForeignTable *foreign_table) const override