OmniSciDB  6686921089
 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::string getUserFromId (const int32_t 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 5123 of file Catalog.cpp.

References DBObject::setPrivileges().

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

5127  {
5128  DBObject db_object{object_name, object_type};
5129  db_object.setPrivileges(privileges);
5130  db_objects[user_id].emplace_back(db_object);
5131 }
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 5100 of file Catalog.cpp.

References DBObjectTypeToString(), and run_benchmark_import::result.

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

5103  {
5104  std::stringstream result;
5105  for (const auto& [old_owner_id, db_objects] : old_owner_db_objects) {
5106  result << "db_id: " << db_id << ", new_owner_user_id: " << new_owner_id
5107  << ", old_owner_user_id: " << old_owner_id << ", db_objects: [";
5108  bool first_object{true};
5109  for (const auto& db_object : db_objects) {
5110  if (first_object) {
5111  first_object = false;
5112  } else {
5113  result << ", ";
5114  }
5115  result << "\"object_id: " << db_object.getObjectKey().objectId
5116  << ", object_type: " << DBObjectTypeToString(db_object.getType()) << "\"";
5117  }
5118  result << "]\n";
5119  }
5120  return result.str();
5121 }
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 3222 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().

3224  {
3225  const auto& table_name = shared_dict_def.get_foreign_table();
3226  const auto td = cat.getMetadataForTable(table_name, false);
3227  CHECK(td);
3228  const auto& foreign_col_name = shared_dict_def.get_foreign_column();
3229  return cat.getMetadataForColumn(td->tableId, foreign_col_name);
3230 }
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:209

+ 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 2231 of file Catalog.cpp.

References CHECK, foreign_storage::get_next_refresh_time(), 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().

2231  {
2232  auto timing_type_entry =
2234  CHECK(timing_type_entry != foreign_table.options.end());
2235  if (timing_type_entry->second ==
2237  return foreign_storage::get_next_refresh_time(foreign_table.options);
2238  }
2240 }
int64_t get_next_refresh_time(const std::map< std::string, std::string, std::less<>> &foreign_table_options)
static constexpr const char * REFRESH_TIMING_TYPE_KEY
Definition: ForeignTable.h:42
#define CHECK(condition)
Definition: Logger.h:209
static constexpr int NULL_REFRESH_TIME
Definition: ForeignTable.h:52
static constexpr const char * SCHEDULE_REFRESH_TIMING_TYPE
Definition: ForeignTable.h:50

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string Catalog_Namespace::anonymous_namespace{Catalog.cpp}::getUserFromId ( const int32_t  id)

Definition at line 941 of file Catalog.cpp.

References Catalog_Namespace::SysCatalog::instance(), and Catalog_Namespace::UserMetadata::userName.

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

941  {
942  UserMetadata user;
943  if (SysCatalog::instance().getMetadataForUserById(id, user)) {
944  return user.userName;
945  }
946  // a user could be deleted and a dashboard still exist?
947  return "Unknown";
948 }

+ Here is the call graph for this function:

+ 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 3136 of file Catalog.cpp.

References to_string().

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

3136  {
3137  std::string table_epochs_str{"["};
3138  bool first_entry{true};
3139  for (const auto& table_epoch : table_epochs) {
3140  if (first_entry) {
3141  first_entry = false;
3142  } else {
3143  table_epochs_str += ", ";
3144  }
3145  table_epochs_str += "(table_id: " + std::to_string(table_epoch.table_id) +
3146  ", epoch: " + std::to_string(table_epoch.table_epoch) + ")";
3147  }
3148  table_epochs_str += "]";
3149  return table_epochs_str;
3150 }
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 156 of file Catalog.cpp.

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

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

+ 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 5092 of file Catalog.cpp.

References Catalog_Namespace::UserMetadata::userId.

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

5092  {
5093  UserMetadata user;
5094  if (!SysCatalog::instance().getMetadataForUser(user_name, user)) {
5095  throw std::runtime_error{"User with username \"" + user_name + "\" does not exist."};
5096  }
5097  return user.userId;
5098 }

+ Here is the caller graph for this function: