OmniSciDB  471d68cefb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
foreign_storage::OptionsContainer Struct Reference

#include <OptionsContainer.h>

+ Inheritance diagram for foreign_storage::OptionsContainer:

Public Member Functions

 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

OptionsMap options
 

Detailed Description

Definition at line 49 of file OptionsContainer.h.

Constructor & Destructor Documentation

foreign_storage::OptionsContainer::OptionsContainer ( )
inline

Definition at line 52 of file OptionsContainer.h.

52 {}
foreign_storage::OptionsContainer::OptionsContainer ( const OptionsMap options)
inline

Definition at line 54 of file OptionsContainer.h.

foreign_storage::OptionsContainer::OptionsContainer ( const std::string &  options_str)
inline

Definition at line 56 of file OptionsContainer.h.

References populateOptionsMap().

56 { populateOptionsMap(options_str); }
void populateOptionsMap(OptionsMap &&options_map, bool clear=false)

+ Here is the call graph for this function:

Member Function Documentation

std::optional<std::string> foreign_storage::OptionsContainer::getOption ( const std::string_view &  key) const
inline

Definition at line 105 of file OptionsContainer.h.

References options.

Referenced by foreign_storage::ParquetDataWrapper::getAllFilePaths(), foreign_storage::AbstractFileStorageDataWrapper::getFullFilePath(), foreign_storage::AbstractTextFileDataWrapper::populateChunkMetadata(), foreign_storage::AbstractFileStorageDataWrapper::validateFilePathOptionKey(), and foreign_storage::AbstractFileStorageDataWrapper::validateTableOptions().

105  {
106  if (auto it = options.find(key); it != options.end()) {
107  return it->second;
108  } else {
109  return {};
110  }
111  }

+ Here is the caller graph for this function:

std::string foreign_storage::OptionsContainer::getOptionsAsJsonString ( ) const
inline

Definition at line 87 of file OptionsContainer.h.

References options.

Referenced by AlterForeignServerCommand::setForeignServerOptions().

87  {
88  rapidjson::Document document;
89  document.SetObject();
90 
91  for (const auto& [key, value] : options) {
92  document.AddMember(rapidjson::Value().SetString(
93  key.c_str(), key.length(), document.GetAllocator()),
94  rapidjson::Value().SetString(
95  value.c_str(), value.length(), document.GetAllocator()),
96  document.GetAllocator());
97  }
98 
99  rapidjson::StringBuffer buffer;
100  rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
101  document.Accept(writer);
102  return buffer.GetString();
103  }

+ Here is the caller graph for this function:

void foreign_storage::OptionsContainer::populateOptionsMap ( OptionsMap &&  options_map,
bool  clear = false 
)
inline

Definition at line 58 of file OptionsContainer.h.

References options.

Referenced by RefreshForeignTablesCommand::execute(), OptionsContainer(), populateOptionsMap(), AlterForeignServerCommand::setForeignServerOptions(), and Catalog_Namespace::Catalog::setForeignServerOptions().

58  {
59  if (clear) {
60  options = options_map;
61  } else {
62  // The merge order here is to make sure we overwrite duplicates in options. If we
63  // used options.merge(options_map) we would preserve existing entries.
64  options_map.merge(options);
65  options = options_map;
66  }
67  }

+ Here is the caller graph for this function:

void foreign_storage::OptionsContainer::populateOptionsMap ( const rapidjson::Value &  ddl_options,
bool  clear = false 
)
inline

Definition at line 69 of file OptionsContainer.h.

References CHECK, options, and to_upper().

69  {
70  CHECK(ddl_options.IsObject());
71  if (clear) {
72  options.clear();
73  }
74  for (const auto& member : ddl_options.GetObject()) {
75  std::string key = to_upper(member.name.GetString());
76  options[key] = member.value.GetString();
77  }
78  }
std::string to_upper(const std::string &str)
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the call graph for this function:

void foreign_storage::OptionsContainer::populateOptionsMap ( const std::string &  options_json,
bool  clear = false 
)
inline

Definition at line 80 of file OptionsContainer.h.

References CHECK, options, and populateOptionsMap().

80  {
81  CHECK(!options_json.empty());
82  rapidjson::Document options;
83  options.Parse(options_json);
84  populateOptionsMap(options);
85  }
void populateOptionsMap(OptionsMap &&options_map, bool clear=false)
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the call graph for this function:

Member Data Documentation

OptionsMap foreign_storage::OptionsContainer::options

Definition at line 50 of file OptionsContainer.h.

Referenced by RefreshForeignTablesCommand::execute(), foreign_storage::anonymous_namespace{RegexFileBufferParser.cpp}::get_line_regex(), foreign_storage::anonymous_namespace{RegexFileBufferParser.cpp}::get_line_start_regex(), Catalog_Namespace::anonymous_namespace{Catalog.cpp}::get_next_refresh_time(), foreign_storage::ParquetDataWrapper::getAllFilePaths(), getOption(), getOptionsAsJsonString(), foreign_storage::ParquetDataWrapper::ParquetDataWrapper(), foreign_storage::ParquetImporter::ParquetImporter(), foreign_storage::AbstractTextFileDataWrapper::populateChunkMetadata(), foreign_storage::AbstractTextFileDataWrapper::populateChunks(), populateOptionsMap(), foreign_storage::AbstractTextFileDataWrapper::restoreDataWrapperInternals(), Catalog_Namespace::Catalog::setForeignServerOptions(), foreign_storage::Csv::anonymous_namespace{CsvShared.cpp}::validate_and_get_bool_value(), foreign_storage::anonymous_namespace{CsvFileBufferParser.cpp}::validate_and_get_bool_value(), foreign_storage::Csv::validate_and_get_copy_params(), foreign_storage::Csv::anonymous_namespace{CsvShared.cpp}::validate_and_get_delimiter(), foreign_storage::anonymous_namespace{CsvFileBufferParser.cpp}::validate_and_get_delimiter(), foreign_storage::Csv::validate_and_get_is_s3_select(), foreign_storage::Csv::anonymous_namespace{CsvShared.cpp}::validate_and_get_string_with_length(), foreign_storage::anonymous_namespace{CsvFileBufferParser.cpp}::validate_and_get_string_with_length(), foreign_storage::CsvFileBufferParser::validateAndGetCopyParams(), foreign_storage::RegexFileBufferParser::validateAndGetCopyParams(), foreign_storage::CsvDataWrapper::validateAndGetIsS3Select(), foreign_storage::AbstractFileStorageDataWrapper::validateFilePath(), foreign_storage::AbstractFileStorageDataWrapper::validateServerOptions(), foreign_storage::InternalSystemDataWrapper::validateServerOptions(), and foreign_storage::RegexParserDataWrapper::validateTableOptions().


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