OmniSciDB  3a86f6ec37
foreign_storage::ForeignServer Struct Reference

#include <ForeignServer.h>

+ Inheritance diagram for foreign_storage::ForeignServer:
+ Collaboration diagram for foreign_storage::ForeignServer:

Public Member Functions

 ForeignServer ()
 
 ForeignServer (const int32_t server_id, const std::string &server_name, const std::string &data_wrapper_type, const std::string &options_str, const int32_t user_id, const time_t creation_time)
 
 ForeignServer (const std::string &server_name, const std::string &data_wrapper_type, const std::map< std::string, std::string, std::less<>> &options, const int32_t user_id)
 
void validate ()
 
- Public Member Functions inherited from foreign_storage::OptionsContainer
 OptionsContainer ()
 
 OptionsContainer (const OptionsMap &options)
 
 OptionsContainer (const std::string &options_str)
 
void populateOptionsMap (OptionsMap &&options_map, bool clear=false)
 
void populateOptionsMap (const rapidjson::Value &ddl_options, bool clear=false)
 
void populateOptionsMap (const std::string &options_json, bool clear=false)
 
std::string getOptionsAsJsonString () const
 
std::optional< std::string > getOption (const std::string_view &key) const
 

Public Attributes

int32_t id
 
std::string name
 
std::string data_wrapper_type
 
int32_t user_id
 
time_t creation_time
 
- Public Attributes inherited from foreign_storage::OptionsContainer
OptionsMap options
 

Static Public Attributes

static constexpr std::string_view STORAGE_TYPE_KEY = "STORAGE_TYPE"
 
static constexpr std::string_view BASE_PATH_KEY = "BASE_PATH"
 
static constexpr std::string_view LOCAL_FILE_STORAGE_TYPE = "LOCAL_FILE"
 
static constexpr std::string_view S3_STORAGE_TYPE = "AWS_S3"
 
static constexpr std::array< std::string_view, 1 > supported_storage_types
 
static constexpr std::array< std::string_view, 2 > all_option_keys
 

Private Member Functions

void validateDataWrapperType ()
 
void validateStorageParameters ()
 
void validateRecognizedOption ()
 

Detailed Description

Definition at line 44 of file ForeignServer.h.

Constructor & Destructor Documentation

◆ ForeignServer() [1/3]

foreign_storage::ForeignServer::ForeignServer ( )
inline

Definition at line 63 of file ForeignServer.h.

63 {}

◆ ForeignServer() [2/3]

foreign_storage::ForeignServer::ForeignServer ( const int32_t  server_id,
const std::string &  server_name,
const std::string &  data_wrapper_type,
const std::string &  options_str,
const int32_t  user_id,
const time_t  creation_time 
)
inline

◆ ForeignServer() [3/3]

foreign_storage::ForeignServer::ForeignServer ( const std::string &  server_name,
const std::string &  data_wrapper_type,
const std::map< std::string, std::string, std::less<>> &  options,
const int32_t  user_id 
)
inline

Member Function Documentation

◆ validate()

void foreign_storage::ForeignServer::validate ( )
inline

Definition at line 87 of file ForeignServer.h.

Referenced by Catalog_Namespace::Catalog::createDefaultServersIfNotExists(), Catalog_Namespace::Catalog::setForeignServerDataWrapper(), and Catalog_Namespace::Catalog::setForeignServerOptions().

+ Here is the caller graph for this function:

◆ validateDataWrapperType()

void foreign_storage::ForeignServer::validateDataWrapperType ( )
inlineprivate

Definition at line 94 of file ForeignServer.h.

References join(), and foreign_storage::DataWrapperType::supported_data_wrapper_types.

94  {
95  const auto& supported_wrapper_types = DataWrapperType::supported_data_wrapper_types;
96  if (std::find(supported_wrapper_types.begin(),
97  supported_wrapper_types.end(),
98  data_wrapper_type) == supported_wrapper_types.end()) {
99  throw std::runtime_error{"Invalid data wrapper type \"" + data_wrapper_type +
100  "\". Data wrapper type must be one of the following: " +
101  join(supported_wrapper_types, ", ") + "."};
102  }
103  }
std::string join(T const &container, std::string const &delim)
static constexpr std::array< std::string_view, 2 > supported_data_wrapper_types
Definition: ForeignServer.h:40
+ Here is the call graph for this function:

◆ validateRecognizedOption()

void foreign_storage::ForeignServer::validateRecognizedOption ( )
inlineprivate

Definition at line 125 of file ForeignServer.h.

References join().

125  {
126  for (const auto& entry : options) {
127  if (std::find(all_option_keys.begin(), all_option_keys.end(), entry.first) ==
128  all_option_keys.end()) {
129  std::string error_message =
130  "Invalid option \"" + entry.first + "\"." +
131  " Option must be one of the following: " + join(all_option_keys, ", ") + ".";
132  throw std::runtime_error{error_message};
133  }
134  }
135  }
static constexpr std::array< std::string_view, 2 > all_option_keys
Definition: ForeignServer.h:54
std::string join(T const &container, std::string const &delim)
+ Here is the call graph for this function:

◆ validateStorageParameters()

void foreign_storage::ForeignServer::validateStorageParameters ( )
inlineprivate

Definition at line 105 of file ForeignServer.h.

References g_enable_s3_fsi, and join().

105  {
106  if (options.find(STORAGE_TYPE_KEY) == options.end()) {
107  throw std::runtime_error{"Foreign server options must contain \"STORAGE_TYPE\"."};
108  }
109 
110  const auto& storage_type = options.find(STORAGE_TYPE_KEY)->second;
111  if (!g_enable_s3_fsi && storage_type == S3_STORAGE_TYPE) {
112  throw std::runtime_error{
113  "Foreign server storage type value of \"" + std::string{S3_STORAGE_TYPE} +
114  "\" is not allowed because FSI S3 support is currently disabled."};
115  } else if (std::find(supported_storage_types.begin(),
117  storage_type) == supported_storage_types.end()) {
118  std::string error_message =
119  "Invalid storage type value. Value must be one of the following: " +
120  join(supported_storage_types, ", ") + ".";
121  throw std::runtime_error{error_message};
122  }
123  }
static constexpr std::string_view S3_STORAGE_TYPE
Definition: ForeignServer.h:49
static constexpr std::array< std::string_view, 1 > supported_storage_types
Definition: ForeignServer.h:51
bool g_enable_s3_fsi
std::string join(T const &container, std::string const &delim)
static constexpr std::string_view STORAGE_TYPE_KEY
Definition: ForeignServer.h:45
+ Here is the call graph for this function:

Member Data Documentation

◆ all_option_keys

constexpr std::array<std::string_view, 2> foreign_storage::ForeignServer::all_option_keys
static
Initial value:

Definition at line 54 of file ForeignServer.h.

◆ BASE_PATH_KEY

constexpr std::string_view foreign_storage::ForeignServer::BASE_PATH_KEY = "BASE_PATH"
static

◆ creation_time

time_t foreign_storage::ForeignServer::creation_time

Definition at line 61 of file ForeignServer.h.

◆ data_wrapper_type

◆ id

◆ LOCAL_FILE_STORAGE_TYPE

◆ name

◆ S3_STORAGE_TYPE

constexpr std::string_view foreign_storage::ForeignServer::S3_STORAGE_TYPE = "AWS_S3"
static

◆ STORAGE_TYPE_KEY

◆ supported_storage_types

constexpr std::array<std::string_view, 1> foreign_storage::ForeignServer::supported_storage_types
static
Initial value:

Definition at line 51 of file ForeignServer.h.

◆ user_id

int32_t foreign_storage::ForeignServer::user_id

The documentation for this struct was generated from the following file: