OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ForeignDataWrapperFactory.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 
20 #include "ForeignDataWrapper.h"
22 
23 namespace foreign_storage {
29  static constexpr char const* CSV = "OMNISCI_CSV";
30  static constexpr char const* PARQUET = "OMNISCI_PARQUET";
31  static constexpr char const* REGEX_PARSER = "OMNISCI_REGEX_PARSER";
32  static constexpr char const* INTERNAL_CATALOG = "OMNISCI_INTERNAL_CATALOG";
33 
34  static constexpr std::array<std::string_view, 4> supported_data_wrapper_types{
35  PARQUET,
36  CSV,
39 };
40 
42  public:
47  static std::unique_ptr<ForeignDataWrapper> create(const std::string& data_wrapper_type,
48  const int db_id,
49  const ForeignTable* foreign_table);
50 
51  static std::unique_ptr<UserMapping> createUserMappingProxyIfApplicable(
52  const int db_id,
53  const int user_id,
54  const std::string& file_path,
55  const import_export::CopyParams& copy_params,
56  const ForeignServer* server);
57 
58  static std::unique_ptr<ForeignServer> createForeignServerProxy(
59  const int db_id,
60  const int user_id,
61  const std::string& file_path,
62  const import_export::CopyParams& copy_params);
63 
64  static std::unique_ptr<ForeignTable> createForeignTableProxy(
65  const int db_id,
66  const TableDescriptor* table,
67  const std::string& file_path,
68  const import_export::CopyParams& copy_params,
69  const ForeignServer* server);
70 
74  static std::unique_ptr<ForeignDataWrapper> createForImport(
75  const std::string& data_wrapper_type,
76  const int db_id,
77  const ForeignTable* foreign_table,
78  const UserMapping* user_mapping);
79 
86  const std::string& data_wrapper_type,
87  const ForeignTable* foreign_table = nullptr);
88 
92  static void validateDataWrapperType(const std::string& data_wrapper_type);
93 
94  private:
95  static std::map<std::string, std::unique_ptr<ForeignDataWrapper>>
97 };
98 } // namespace foreign_storage
static const ForeignDataWrapper & createForValidation(const std::string &data_wrapper_type, const ForeignTable *foreign_table=nullptr)
static std::unique_ptr< ForeignDataWrapper > createForImport(const std::string &data_wrapper_type, const int db_id, const ForeignTable *foreign_table, const UserMapping *user_mapping)
static constexpr char const * REGEX_PARSER
static std::unique_ptr< ForeignDataWrapper > create(const std::string &data_wrapper_type, const int db_id, const ForeignTable *foreign_table)
static constexpr std::array< std::string_view, 4 > supported_data_wrapper_types
static constexpr char const * INTERNAL_CATALOG
static std::map< std::string, std::unique_ptr< ForeignDataWrapper > > validation_data_wrappers_
static void validateDataWrapperType(const std::string &data_wrapper_type)
Encapsulates an enumeration of foreign data wrapper type strings.
static std::unique_ptr< ForeignServer > createForeignServerProxy(const int db_id, const int user_id, const std::string &file_path, const import_export::CopyParams &copy_params)
static std::unique_ptr< ForeignTable > createForeignTableProxy(const int db_id, const TableDescriptor *table, const std::string &file_path, const import_export::CopyParams &copy_params, const ForeignServer *server)
static constexpr char const * CSV
static constexpr char const * PARQUET
static std::unique_ptr< UserMapping > createUserMappingProxyIfApplicable(const int db_id, const int user_id, const std::string &file_path, const import_export::CopyParams &copy_params, const ForeignServer *server)