OmniSciDB  72c90bc290
 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 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 
20 #include "ForeignDataWrapper.h"
22 
23 namespace foreign_storage {
24 class UserMapping;
25 
29 bool is_valid_source_type(const import_export::CopyParams& copy_params);
30 
32 
45 std::tuple<std::unique_ptr<foreign_storage::ForeignServer>,
46  std::unique_ptr<foreign_storage::UserMapping>,
47  std::unique_ptr<foreign_storage::ForeignTable>>
48 create_proxy_fsi_objects(const std::string& copy_from_source,
49  const import_export::CopyParams& copy_params,
50  const int db_id,
51  const TableDescriptor* table,
52  const int32_t user_id);
53 
58 std::tuple<std::unique_ptr<foreign_storage::ForeignServer>,
59  std::unique_ptr<foreign_storage::UserMapping>,
60  std::unique_ptr<foreign_storage::ForeignTable>>
61 create_proxy_fsi_objects(const std::string& copy_from_source,
62  const import_export::CopyParams& copy_params,
63  const TableDescriptor* table);
64 
70  static constexpr char const* CSV = "DELIMITED_FILE";
71  static constexpr char const* PARQUET = "PARQUET_FILE";
72  static constexpr char const* REGEX_PARSER = "REGEX_PARSED_FILE";
73  static constexpr char const* INTERNAL_CATALOG = "INTERNAL_CATALOG";
74  static constexpr char const* INTERNAL_MEMORY_STATS = "INTERNAL_MEMORY_STATS";
75  static constexpr char const* INTERNAL_STORAGE_STATS = "INTERNAL_STORAGE_STATS";
76  static constexpr char const* INTERNAL_EXECUTOR_STATS = "INTERNAL_EXECUTOR_STATS";
77  static constexpr char const* INTERNAL_ML_MODEL_METADATA = "INTERNAL_ML_MODEL_METADATA";
78  static constexpr char const* INTERNAL_LOGS = "INTERNAL_LOGS";
79 
80  static constexpr std::array<char const*, 6> INTERNAL_DATA_WRAPPERS{
87 
88  static constexpr std::array<char const*, 5> IN_MEMORY_DATA_WRAPPERS{
94 
95  static constexpr std::array<std::string_view, 9> supported_data_wrapper_types{
96  PARQUET,
97  CSV,
104  INTERNAL_LOGS};
105 };
106 
108  public:
113  static std::unique_ptr<ForeignDataWrapper> create(const std::string& data_wrapper_type,
114  const int db_id,
115  const ForeignTable* foreign_table);
116 
117  static std::unique_ptr<UserMapping> createUserMappingProxyIfApplicable(
118  const int db_id,
119  const int user_id,
120  const std::string& file_path,
121  const import_export::CopyParams& copy_params,
122  const ForeignServer* server);
123 
124  static std::unique_ptr<ForeignServer> createForeignServerProxy(
125  const int db_id,
126  const int user_id,
127  const std::string& file_path,
128  const import_export::CopyParams& copy_params);
129 
130  static std::unique_ptr<ForeignTable> createForeignTableProxy(
131  const int db_id,
132  const TableDescriptor* table,
133  const std::string& file_path,
134  const import_export::CopyParams& copy_params,
135  const ForeignServer* server);
136 
140  static std::unique_ptr<ForeignDataWrapper> createForImport(
141  const std::string& data_wrapper_type,
142  const int db_id,
143  const ForeignTable* foreign_table,
144  const UserMapping* user_mapping);
145 
146  static std::unique_ptr<ForeignDataWrapper> createForGeneralImport(
147  const import_export::CopyParams& copy_params,
148  const int db_id,
149  const ForeignTable* foreign_table,
150  const UserMapping* user_mapping);
151 
158  const std::string& data_wrapper_type,
159  const ForeignTable* foreign_table = nullptr);
160 
164  static void validateDataWrapperType(const std::string& data_wrapper_type);
165 
166  private:
167  static std::map<std::string, std::unique_ptr<ForeignDataWrapper>>
169 };
170 } // namespace foreign_storage
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 const ForeignDataWrapper * createForValidation(const std::string &data_wrapper_type, const ForeignTable *foreign_table=nullptr)
static std::unique_ptr< ForeignDataWrapper > create(const std::string &data_wrapper_type, const int db_id, const ForeignTable *foreign_table)
static constexpr char const * INTERNAL_STORAGE_STATS
static constexpr std::array< char const *, 6 > INTERNAL_DATA_WRAPPERS
static constexpr char const * INTERNAL_CATALOG
static constexpr std::array< char const *, 5 > IN_MEMORY_DATA_WRAPPERS
std::tuple< std::unique_ptr< foreign_storage::ForeignServer >, std::unique_ptr< foreign_storage::UserMapping >, std::unique_ptr< foreign_storage::ForeignTable > > create_proxy_fsi_objects(const std::string &copy_from_source, const import_export::CopyParams &copy_params, const int db_id, const TableDescriptor *table, const int32_t user_id)
Create proxy fsi objects for use outside FSI.
static std::map< std::string, std::unique_ptr< ForeignDataWrapper > > validation_data_wrappers_
static std::unique_ptr< ForeignDataWrapper > createForGeneralImport(const import_export::CopyParams &copy_params, const int db_id, const ForeignTable *foreign_table, const UserMapping *user_mapping)
static constexpr char const * INTERNAL_ML_MODEL_METADATA
static void validateDataWrapperType(const std::string &data_wrapper_type)
Encapsulates an enumeration of foreign data wrapper type strings.
bool is_valid_source_type(const import_export::CopyParams &copy_params)
static constexpr std::array< std::string_view, 9 > supported_data_wrapper_types
static constexpr char const * INTERNAL_EXECUTOR_STATS
void validate_regex_parser_options(const import_export::CopyParams &copy_params)
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 constexpr char const * INTERNAL_MEMORY_STATS
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 * INTERNAL_LOGS
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)