OmniSciDB  2b310ab3b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
foreign_storage::ForeignTable Struct Reference

#include <ForeignTable.h>

+ Inheritance diagram for foreign_storage::ForeignTable:
+ Collaboration diagram for foreign_storage::ForeignTable:

Public Member Functions

void validate (const std::vector< std::string_view > &supported_data_wrapper_options)
 
bool isAppendMode () const
 
- Public Member Functions inherited from TableDescriptor
 TableDescriptor ()
 
virtual ~TableDescriptor ()=default
 
- 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

const ForeignServerforeign_server
 
int64_t last_refresh_time {NULL_REFRESH_TIME}
 
int64_t next_refresh_time {NULL_REFRESH_TIME}
 
- Public Attributes inherited from TableDescriptor
int32_t tableId
 
int32_t shard
 
std::string tableName
 
int32_t userId
 
int32_t nColumns
 
bool isView
 
std::string viewSQL
 
std::string fragments
 
Fragmenter_Namespace::FragmenterType fragType
 
int32_t maxFragRows
 
int64_t maxChunkSize
 
int32_t fragPageSize
 
int64_t maxRows
 
std::string partitions
 
std::string keyMetainfo
 
std::shared_ptr
< Fragmenter_Namespace::AbstractFragmenter
fragmenter
 
int32_t nShards
 
int shardedColumnId
 
int sortedColumnId
 
Data_Namespace::MemoryLevel persistenceLevel
 
bool hasDeletedCol
 
std::vector< int > columnIdBySpi_
 
std::string storageType
 
std::shared_ptr< std::mutex > mutex_
 
- Public Attributes inherited from foreign_storage::OptionsContainer
std::map< std::string,
std::string, std::less<> > 
options
 

Static Public Attributes

static constexpr const char * FRAGMENT_SIZE_KEY = "FRAGMENT_SIZE"
 
static constexpr const char * REFRESH_TIMING_TYPE_KEY = "REFRESH_TIMING_TYPE"
 
static constexpr const char * REFRESH_START_DATE_TIME_KEY = "REFRESH_START_DATE_TIME"
 
static constexpr const char * REFRESH_INTERVAL_KEY = "REFRESH_INTERVAL"
 
static constexpr const char * REFRESH_UPDATE_TYPE_KEY = "REFRESH_UPDATE_TYPE"
 
static constexpr const char * ALL_REFRESH_UPDATE_TYPE = "ALL"
 
static constexpr const char * APPEND_REFRESH_UPDATE_TYPE = "APPEND"
 
static constexpr const char * SCHEDULE_REFRESH_TIMING_TYPE = "SCHEDULED"
 
static constexpr const char * MANUAL_REFRESH_TIMING_TYPE = "MANUAL"
 
static constexpr int NULL_REFRESH_TIME = -1
 
static constexpr std::array
< const char *, 5 > 
supported_options
 

Private Member Functions

void validateRecognizedOption (const std::vector< std::string_view > &supported_data_wrapper_options)
 

Detailed Description

Definition at line 27 of file ForeignTable.h.

Member Function Documentation

bool foreign_storage::ForeignTable::isAppendMode ( ) const
inline

Definition at line 98 of file ForeignTable.h.

References APPEND_REFRESH_UPDATE_TYPE, foreign_storage::OptionsContainer::options, and REFRESH_UPDATE_TYPE_KEY.

Referenced by foreign_storage::CsvDataWrapper::populateChunkMetadata(), foreign_storage::ForeignStorageMgr::refreshTableInCache(), and foreign_storage::CsvDataWrapper::restoreDataWrapperInternals().

98  {
99  auto update_mode = options.find(REFRESH_UPDATE_TYPE_KEY);
100  return (update_mode != options.end() &&
101  update_mode->second == APPEND_REFRESH_UPDATE_TYPE);
102  }
std::map< std::string, std::string, std::less<> > options
static constexpr const char * REFRESH_UPDATE_TYPE_KEY
Definition: ForeignTable.h:32
static constexpr const char * APPEND_REFRESH_UPDATE_TYPE
Definition: ForeignTable.h:34

+ Here is the caller graph for this function:

void foreign_storage::ForeignTable::validate ( const std::vector< std::string_view > &  supported_data_wrapper_options)
inline

Definition at line 48 of file ForeignTable.h.

References ALL_REFRESH_UPDATE_TYPE, APPEND_REFRESH_UPDATE_TYPE, CHECK(), dateTimeParse< kTIMESTAMP >(), MANUAL_REFRESH_TIMING_TYPE, foreign_storage::OptionsContainer::options, REFRESH_INTERVAL_KEY, REFRESH_START_DATE_TIME_KEY, REFRESH_TIMING_TYPE_KEY, REFRESH_UPDATE_TYPE_KEY, SCHEDULE_REFRESH_TIMING_TYPE, and validateRecognizedOption().

48  {
49  auto update_type_entry =
51  CHECK(update_type_entry != options.end());
52  if (update_type_entry->second != ALL_REFRESH_UPDATE_TYPE &&
53  update_type_entry->second != APPEND_REFRESH_UPDATE_TYPE) {
54  std::string error_message = "Invalid value \"" + update_type_entry->second +
55  "\" for " + REFRESH_UPDATE_TYPE_KEY + " option." +
56  " Value must be \"" +
57  std::string{APPEND_REFRESH_UPDATE_TYPE} + "\" or \"" +
58  std::string{ALL_REFRESH_UPDATE_TYPE} + "\".";
59  throw std::runtime_error{error_message};
60  }
61 
62  auto refresh_timing_entry =
64  CHECK(refresh_timing_entry != options.end());
65  if (refresh_timing_entry->second == SCHEDULE_REFRESH_TIMING_TYPE) {
66  auto start_date_entry = options.find(REFRESH_START_DATE_TIME_KEY);
67  if (start_date_entry == options.end()) {
68  throw std::runtime_error{std::string{REFRESH_START_DATE_TIME_KEY} +
69  " option must be provided for scheduled refreshes."};
70  }
71  auto start_date_time = dateTimeParse<kTIMESTAMP>(start_date_entry->second, 0);
72  int64_t current_time = std::chrono::duration_cast<std::chrono::seconds>(
73  std::chrono::system_clock::now().time_since_epoch())
74  .count();
75  if (start_date_time < current_time) {
76  throw std::runtime_error{std::string{REFRESH_START_DATE_TIME_KEY} +
77  " cannot be a past date time."};
78  }
79 
80  auto interval_entry = options.find(REFRESH_INTERVAL_KEY);
81  if (interval_entry != options.end()) {
82  boost::regex interval_regex{"^\\d{1,}[SHD]$",
83  boost::regex::extended | boost::regex::icase};
84  if (!boost::regex_match(interval_entry->second, interval_regex)) {
85  throw std::runtime_error{"Invalid value provided for the " +
86  std::string{REFRESH_INTERVAL_KEY} + " option."};
87  }
88  }
89  } else if (refresh_timing_entry->second != MANUAL_REFRESH_TIMING_TYPE) {
90  throw std::runtime_error{"Invalid value provided for the " +
91  std::string{REFRESH_TIMING_TYPE_KEY} +
92  " option. Value must be \"" + MANUAL_REFRESH_TIMING_TYPE +
93  "\" or \"" + SCHEDULE_REFRESH_TIMING_TYPE + "\"."};
94  }
95  validateRecognizedOption(supported_data_wrapper_options);
96  }
std::map< std::string, std::string, std::less<> > options
void validateRecognizedOption(const std::vector< std::string_view > &supported_data_wrapper_options)
Definition: ForeignTable.h:105
int64_t dateTimeParse< kTIMESTAMP >(std::string_view str, unsigned const dim)
static constexpr const char * MANUAL_REFRESH_TIMING_TYPE
Definition: ForeignTable.h:36
static constexpr const char * REFRESH_START_DATE_TIME_KEY
Definition: ForeignTable.h:30
CHECK(cgen_state)
static constexpr const char * REFRESH_UPDATE_TYPE_KEY
Definition: ForeignTable.h:32
static constexpr const char * REFRESH_INTERVAL_KEY
Definition: ForeignTable.h:31
static constexpr const char * ALL_REFRESH_UPDATE_TYPE
Definition: ForeignTable.h:33
static constexpr const char * APPEND_REFRESH_UPDATE_TYPE
Definition: ForeignTable.h:34
static constexpr const char * REFRESH_TIMING_TYPE_KEY
Definition: ForeignTable.h:29
static constexpr const char * SCHEDULE_REFRESH_TIMING_TYPE
Definition: ForeignTable.h:35

+ Here is the call graph for this function:

void foreign_storage::ForeignTable::validateRecognizedOption ( const std::vector< std::string_view > &  supported_data_wrapper_options)
inlineprivate

Definition at line 105 of file ForeignTable.h.

References foreign_storage::OptionsContainer::options, and supported_options.

Referenced by validate().

106  {
107  for (const auto& entry : options) {
108  if (std::find(supported_options.begin(), supported_options.end(), entry.first) ==
109  supported_options.end() &&
110  std::find(supported_data_wrapper_options.begin(),
111  supported_data_wrapper_options.end(),
112  entry.first) == supported_data_wrapper_options.end()) {
113  std::string error_message =
114  "Invalid foreign table option \"" + entry.first + "\".";
115  throw std::runtime_error{error_message};
116  }
117  }
118  }
std::map< std::string, std::string, std::less<> > options
static constexpr std::array< const char *, 5 > supported_options
Definition: ForeignTable.h:41

+ Here is the caller graph for this function:

Member Data Documentation

constexpr const char* foreign_storage::ForeignTable::ALL_REFRESH_UPDATE_TYPE = "ALL"
static

Definition at line 33 of file ForeignTable.h.

Referenced by CreateForeignTableCommand::setRefreshOptions(), and validate().

constexpr const char* foreign_storage::ForeignTable::APPEND_REFRESH_UPDATE_TYPE = "APPEND"
static

Definition at line 34 of file ForeignTable.h.

Referenced by isAppendMode(), and validate().

constexpr const char* foreign_storage::ForeignTable::FRAGMENT_SIZE_KEY = "FRAGMENT_SIZE"
static

Definition at line 28 of file ForeignTable.h.

int64_t foreign_storage::ForeignTable::last_refresh_time {NULL_REFRESH_TIME}

Definition at line 40 of file ForeignTable.h.

constexpr const char* foreign_storage::ForeignTable::MANUAL_REFRESH_TIMING_TYPE = "MANUAL"
static

Definition at line 36 of file ForeignTable.h.

Referenced by CreateForeignTableCommand::setRefreshOptions(), and validate().

int64_t foreign_storage::ForeignTable::next_refresh_time {NULL_REFRESH_TIME}

Definition at line 40 of file ForeignTable.h.

Referenced by Catalog_Namespace::Catalog::createTable().

constexpr int foreign_storage::ForeignTable::NULL_REFRESH_TIME = -1
static
constexpr const char* foreign_storage::ForeignTable::REFRESH_INTERVAL_KEY = "REFRESH_INTERVAL"
static

Definition at line 31 of file ForeignTable.h.

Referenced by foreign_storage::get_next_refresh_time(), and validate().

constexpr const char* foreign_storage::ForeignTable::REFRESH_START_DATE_TIME_KEY = "REFRESH_START_DATE_TIME"
static

Definition at line 30 of file ForeignTable.h.

Referenced by foreign_storage::get_next_refresh_time(), and validate().

constexpr const char* foreign_storage::ForeignTable::REFRESH_TIMING_TYPE_KEY = "REFRESH_TIMING_TYPE"
static
constexpr const char* foreign_storage::ForeignTable::REFRESH_UPDATE_TYPE_KEY = "REFRESH_UPDATE_TYPE"
static
constexpr const char* foreign_storage::ForeignTable::SCHEDULE_REFRESH_TIMING_TYPE = "SCHEDULED"
static
constexpr std::array<const char*, 5> foreign_storage::ForeignTable::supported_options
static

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