OmniSciDB  95562058bd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 std::map< std::string, std::string, std::less<>> &options)
 
 OptionsContainer (const std::string &options_str)
 
void populateOptionsMap (const rapidjson::Value &ddl_options)
 
void populateOptionsMap (const std::string &options_json, bool clear=false)
 
std::string getOptionsAsJsonString () 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
std::map< std::string,
std::string, std::less<> > 
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::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 42 of file ForeignServer.h.

Constructor & Destructor Documentation

foreign_storage::ForeignServer::ForeignServer ( )
inline

Definition at line 57 of file ForeignServer.h.

57 {}
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
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

Definition at line 72 of file ForeignServer.h.

Member Function Documentation

void foreign_storage::ForeignServer::validate ( )
inline

Definition at line 81 of file ForeignServer.h.

References validateDataWrapperType(), validateRecognizedOption(), and validateStorageParameters().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void foreign_storage::ForeignServer::validateDataWrapperType ( )
inlineprivate

Definition at line 88 of file ForeignServer.h.

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

Referenced by validate().

88  {
89  const auto& supported_wrapper_types = DataWrapperType::supported_data_wrapper_types;
90  if (std::find(supported_wrapper_types.begin(),
91  supported_wrapper_types.end(),
92  data_wrapper_type) == supported_wrapper_types.end()) {
93  throw std::runtime_error{"Invalid data wrapper type \"" + data_wrapper_type +
94  "\". Data wrapper type must be one of the following: " +
95  join(supported_wrapper_types, ", ") + "."};
96  }
97  }
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:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void foreign_storage::ForeignServer::validateRecognizedOption ( )
inlineprivate

Definition at line 123 of file ForeignServer.h.

References all_option_keys, join(), and foreign_storage::OptionsContainer::options.

Referenced by validate().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void foreign_storage::ForeignServer::validateStorageParameters ( )
inlineprivate

Definition at line 99 of file ForeignServer.h.

References BASE_PATH_KEY, join(), LOCAL_FILE_STORAGE_TYPE, foreign_storage::OptionsContainer::options, STORAGE_TYPE_KEY, supported_storage_types, and UNREACHABLE.

Referenced by validate().

99  {
100  if (options.find(STORAGE_TYPE_KEY) == options.end()) {
101  throw std::runtime_error{"Foreign server options must contain \"STORAGE_TYPE\"."};
102  }
103 
104  if (std::find(supported_storage_types.begin(),
106  options.find(STORAGE_TYPE_KEY)->second) ==
107  supported_storage_types.end()) {
108  std::string error_message =
109  "Invalid storage type value. Value must be one of the following: " +
110  join(supported_storage_types, ", ") + ".";
111  throw std::runtime_error{error_message};
112  }
113 
114  if (options.find(STORAGE_TYPE_KEY)->second == LOCAL_FILE_STORAGE_TYPE) {
115  if (options.find(BASE_PATH_KEY) == options.end()) {
116  throw std::runtime_error{"Foreign server options must contain \"BASE_PATH\"."};
117  }
118  } else {
119  UNREACHABLE();
120  }
121  }
std::map< std::string, std::string, std::less<> > options
static constexpr std::array< std::string_view, 1 > supported_storage_types
Definition: ForeignServer.h:46
std::string join(T const &container, std::string const &delim)
#define UNREACHABLE()
Definition: Logger.h:241
static constexpr std::string_view STORAGE_TYPE_KEY
Definition: ForeignServer.h:43
static constexpr std::string_view LOCAL_FILE_STORAGE_TYPE
Definition: ForeignServer.h:45
static constexpr std::string_view BASE_PATH_KEY
Definition: ForeignServer.h:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 48 of file ForeignServer.h.

Referenced by validateRecognizedOption().

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

Definition at line 55 of file ForeignServer.h.

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

Definition at line 46 of file ForeignServer.h.

Referenced by validateStorageParameters().

int32_t foreign_storage::ForeignServer::user_id

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