OmniSciDB  16c4e035a1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Catalog_Namespace::anonymous_namespace{Catalog.cpp} Namespace Reference

Functions

auto table_json_filepath (const std::string &base_path, const std::string &db_name)
 
std::map< int32_t, std::string > get_user_id_to_user_name_map ()
 
std::string get_user_name_from_id (int32_t id, const std::map< int32_t, std::string > &user_name_by_user_id)
 
int64_t get_next_refresh_time (const foreign_storage::ForeignTable &foreign_table)
 
std::string table_epochs_to_string (const std::vector< TableEpochInfo > &table_epochs)
 
const ColumnDescriptorget_foreign_col (const Catalog &cat, const Parser::SharedDictionaryDef &shared_dict_def)
 
int32_t validate_and_get_user_id (const std::string &user_name)
 
std::string convert_object_owners_map_to_string (int32_t db_id, int32_t new_owner_id, const std::map< int32_t, std::vector< DBObject >> &old_owner_db_objects)
 
void add_db_object (const std::string &object_name, DBObjectType object_type, int32_t user_id, const AccessPrivileges &privileges, std::map< int32_t, std::vector< DBObject >> &db_objects)
 

Function Documentation

void Catalog_Namespace::anonymous_namespace{Catalog.cpp}::add_db_object ( const std::string &  object_name,
DBObjectType  object_type,
int32_t  user_id,
const AccessPrivileges privileges,
std::map< int32_t, std::vector< DBObject >> &  db_objects 
)

Definition at line 5183 of file Catalog.cpp.

References DBObject::setPrivileges().

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

5187  {
5188  DBObject db_object{object_name, object_type};
5189  db_object.setPrivileges(privileges);
5190  db_objects[user_id].emplace_back(db_object);
5191 }
void setPrivileges(const AccessPrivileges &privs)
Definition: DBObject.h:229

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string Catalog_Namespace::anonymous_namespace{Catalog.cpp}::convert_object_owners_map_to_string ( int32_t  db_id,
int32_t  new_owner_id,
const std::map< int32_t, std::vector< DBObject >> &  old_owner_db_objects 
)

Definition at line 5160 of file Catalog.cpp.

References DBObjectTypeToString(), and run_benchmark_import::result.

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

5163  {
5164  std::stringstream result;
5165  for (const auto& [old_owner_id, db_objects] : old_owner_db_objects) {
5166  result << "db_id: " << db_id << ", new_owner_user_id: " << new_owner_id
5167  << ", old_owner_user_id: " << old_owner_id << ", db_objects: [";
5168  bool first_object{true};
5169  for (const auto& db_object : db_objects) {
5170  if (first_object) {
5171  first_object = false;
5172  } else {
5173  result << ", ";
5174  }
5175  result << "\"object_id: " << db_object.getObjectKey().objectId
5176  << ", object_type: " << DBObjectTypeToString(db_object.getType()) << "\"";
5177  }
5178  result << "]\n";
5179  }
5180  return result.str();
5181 }
std::string DBObjectTypeToString(DBObjectType type)
Definition: DBObject.cpp:83

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const ColumnDescriptor* Catalog_Namespace::anonymous_namespace{Catalog.cpp}::get_foreign_col ( const Catalog &  cat,
const Parser::SharedDictionaryDef shared_dict_def 
)

Definition at line 3240 of file Catalog.cpp.

References CHECK, Parser::SharedDictionaryDef::get_foreign_column(), Parser::SharedDictionaryDef::get_foreign_table(), Catalog_Namespace::Catalog::getMetadataForColumn(), Catalog_Namespace::Catalog::getMetadataForTable(), and TableDescriptor::tableId.

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

3242  {
3243  const auto& table_name = shared_dict_def.get_foreign_table();
3244  const auto td = cat.getMetadataForTable(table_name, false);
3245  CHECK(td);
3246  const auto& foreign_col_name = shared_dict_def.get_foreign_column();
3247  return cat.getMetadataForColumn(td->tableId, foreign_col_name);
3248 }
std::string cat(Ts &&...args)
const std::string & get_foreign_table() const
Definition: ParserNode.h:929
const std::string & get_foreign_column() const
Definition: ParserNode.h:931
#define CHECK(condition)
Definition: Logger.h:211

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t Catalog_Namespace::anonymous_namespace{Catalog.cpp}::get_next_refresh_time ( const foreign_storage::ForeignTable foreign_table)

Definition at line 2248 of file Catalog.cpp.

References CHECK, foreign_storage::RefreshTimeCalculator::getNextRefreshTime(), foreign_storage::ForeignTable::NULL_REFRESH_TIME, foreign_storage::OptionsContainer::options, foreign_storage::ForeignTable::REFRESH_TIMING_TYPE_KEY, and foreign_storage::ForeignTable::SCHEDULE_REFRESH_TIMING_TYPE.

Referenced by Catalog_Namespace::Catalog::createTable(), and Catalog_Namespace::Catalog::updateForeignTableRefreshTimes().

2248  {
2249  auto timing_type_entry =
2251  CHECK(timing_type_entry != foreign_table.options.end());
2252  if (timing_type_entry->second ==
2255  foreign_table.options);
2256  }
2258 }
static int64_t getNextRefreshTime(const std::map< std::string, std::string, std::less<>> &foreign_table_options)
static constexpr const char * REFRESH_TIMING_TYPE_KEY
Definition: ForeignTable.h:43
#define CHECK(condition)
Definition: Logger.h:211
static constexpr int NULL_REFRESH_TIME
Definition: ForeignTable.h:53
static constexpr const char * SCHEDULE_REFRESH_TIMING_TYPE
Definition: ForeignTable.h:51

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::map<int32_t, std::string> Catalog_Namespace::anonymous_namespace{Catalog.cpp}::get_user_id_to_user_name_map ( )

Definition at line 942 of file Catalog.cpp.

References Catalog_Namespace::SysCatalog::getAllUserMetadata(), and Catalog_Namespace::SysCatalog::instance().

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

942  {
943  auto users = SysCatalog::instance().getAllUserMetadata();
944  std::map<int32_t, std::string> user_name_by_user_id;
945  for (const auto& user : users) {
946  user_name_by_user_id[user.userId] = user.userName;
947  }
948  return user_name_by_user_id;
949 }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string Catalog_Namespace::anonymous_namespace{Catalog.cpp}::get_user_name_from_id ( int32_t  id,
const std::map< int32_t, std::string > &  user_name_by_user_id 
)

Definition at line 951 of file Catalog.cpp.

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

953  {
954  auto entry = user_name_by_user_id.find(id);
955  if (entry != user_name_by_user_id.end()) {
956  return entry->second;
957  }
958  // a user could be deleted and a dashboard still exist?
959  return "Unknown";
960 }

+ Here is the caller graph for this function:

std::string Catalog_Namespace::anonymous_namespace{Catalog.cpp}::table_epochs_to_string ( const std::vector< TableEpochInfo > &  table_epochs)

Definition at line 3154 of file Catalog.cpp.

References to_string().

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

3154  {
3155  std::string table_epochs_str{"["};
3156  bool first_entry{true};
3157  for (const auto& table_epoch : table_epochs) {
3158  if (first_entry) {
3159  first_entry = false;
3160  } else {
3161  table_epochs_str += ", ";
3162  }
3163  table_epochs_str += "(table_id: " + std::to_string(table_epoch.table_id) +
3164  ", epoch: " + std::to_string(table_epoch.table_epoch) + ")";
3165  }
3166  table_epochs_str += "]";
3167  return table_epochs_str;
3168 }
std::string to_string(char const *&&v)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

auto Catalog_Namespace::anonymous_namespace{Catalog.cpp}::table_json_filepath ( const std::string &  base_path,
const std::string &  db_name 
)
inline

Definition at line 157 of file Catalog.cpp.

Referenced by Catalog_Namespace::Catalog::dropTableFromJsonUnlocked(), Catalog_Namespace::Catalog::serializeTableJsonUnlocked(), and Catalog_Namespace::Catalog::~Catalog().

158  {
159  return boost::filesystem::path(base_path + "/mapd_catalogs/" + db_name +
160  "_temp_tables.json");
161 }

+ Here is the caller graph for this function:

int32_t Catalog_Namespace::anonymous_namespace{Catalog.cpp}::validate_and_get_user_id ( const std::string &  user_name)

Definition at line 5152 of file Catalog.cpp.

References Catalog_Namespace::UserMetadata::userId.

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

5152  {
5153  UserMetadata user;
5154  if (!SysCatalog::instance().getMetadataForUser(user_name, user)) {
5155  throw std::runtime_error{"User with username \"" + user_name + "\" does not exist."};
5156  }
5157  return user.userId;
5158 }

+ Here is the caller graph for this function: