OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QueryExporter.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 
21 
22 #include <string>
23 #include <unordered_set>
24 
25 namespace import_export {
26 
28  public:
30  enum class FileCompression { kNone, kGZip, kZip };
31  enum class ArrayNullHandling {
36  };
37 
38  explicit QueryExporter(const FileType file_type);
39  QueryExporter() = delete;
40  virtual ~QueryExporter() {}
41 
42  static std::unique_ptr<QueryExporter> create(const FileType file_type);
43 
44  virtual void beginExport(const std::string& file_path,
45  const std::string& layer_name,
46  const CopyParams& copy_params,
47  const std::vector<TargetMetaInfo>& column_info,
48  const FileCompression file_compression,
49  const ArrayNullHandling array_null_handling) = 0;
50  virtual void exportResults(const std::vector<AggregatedResult>& query_results) = 0;
51  virtual void endExport() = 0;
52 
53  protected:
55 
57  const std::string& file_path,
58  const std::string& file_type,
59  const std::unordered_set<std::string>& valid_extensions) const;
60  std::string safeColumnName(const std::string& resname, const int column_index);
61 };
62 
63 } // namespace import_export
std::string safeColumnName(const std::string &resname, const int column_index)
static std::unique_ptr< QueryExporter > create(const FileType file_type)
virtual void endExport()=0
virtual void beginExport(const std::string &file_path, const std::string &layer_name, const CopyParams &copy_params, const std::vector< TargetMetaInfo > &column_info, const FileCompression file_compression, const ArrayNullHandling array_null_handling)=0
virtual void exportResults(const std::vector< AggregatedResult > &query_results)=0
void validateFileExtensions(const std::string &file_path, const std::string &file_type, const std::unordered_set< std::string > &valid_extensions) const