OmniSciDB  0fdbebe030
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Catalog_Namespace::Catalog Class Referencefinal

class for a per-database catalog. also includes metadata for the current database and the current user. More...

#include <Catalog.h>

+ Collaboration diagram for Catalog_Namespace::Catalog:

Public Member Functions

 Catalog (const std::string &basePath, const DBMetadata &curDB, std::shared_ptr< Data_Namespace::DataMgr > dataMgr, const std::vector< LeafHostInfo > &string_dict_hosts, std::shared_ptr< Calcite > calcite, bool is_new_db)
 Constructor - takes basePath to already extant data directory for writing. More...
 
 ~Catalog ()
 Destructor - deletes all ColumnDescriptor and TableDescriptor structures which were allocated on the heap and writes Catalog to Sqlite. More...
 
void createTable (TableDescriptor &td, const std::list< ColumnDescriptor > &columns, const std::vector< Parser::SharedDictionaryDef > &shared_dict_defs, bool isLogicalTable)
 
void createShardedTable (TableDescriptor &td, const std::list< ColumnDescriptor > &columns, const std::vector< Parser::SharedDictionaryDef > &shared_dict_defs)
 
int32_t createDashboard (DashboardDescriptor &vd)
 
void replaceDashboard (DashboardDescriptor &vd)
 
std::string createLink (LinkDescriptor &ld, size_t min_length)
 
void dropTable (const TableDescriptor *td)
 
void truncateTable (const TableDescriptor *td)
 
void renameTable (const TableDescriptor *td, const std::string &newTableName)
 
void renameColumn (const TableDescriptor *td, const ColumnDescriptor *cd, const std::string &newColumnName)
 
void addColumn (const TableDescriptor &td, ColumnDescriptor &cd)
 
void dropColumn (const TableDescriptor &td, const ColumnDescriptor &cd)
 
void removeChunks (const int table_id)
 
const TableDescriptorgetMetadataForTable (const std::string &tableName, const bool populateFragmenter=true) const
 Returns a pointer to a const TableDescriptor struct matching the provided tableName. More...
 
const TableDescriptorgetMetadataForTableImpl (int tableId, const bool populateFragmenter) const
 
const TableDescriptorgetMetadataForTable (int tableId) const
 
const ColumnDescriptorgetMetadataForColumn (int tableId, const std::string &colName) const
 
const ColumnDescriptorgetMetadataForColumn (int tableId, int columnId) const
 
const int getColumnIdBySpi (const int tableId, const size_t spi) const
 
const ColumnDescriptorgetMetadataForColumnBySpi (const int tableId, const size_t spi) const
 
const DashboardDescriptorgetMetadataForDashboard (const std::string &userId, const std::string &dashName) const
 
void deleteMetadataForDashboard (const std::string &userId, const std::string &dashName)
 
const DashboardDescriptorgetMetadataForDashboard (const int32_t dashboard_id) const
 
void deleteMetadataForDashboard (const int32_t dashboard_id)
 
const LinkDescriptorgetMetadataForLink (const std::string &link) const
 
const LinkDescriptorgetMetadataForLink (int linkId) const
 
std::list< const
ColumnDescriptor * > 
getAllColumnMetadataForTable (const int tableId, const bool fetchSystemColumns, const bool fetchVirtualColumns, const bool fetchPhysicalColumns) const
 Returns a list of pointers to constant ColumnDescriptor structs for all the columns from a particular table specified by table id. More...
 
std::list< const
TableDescriptor * > 
getAllTableMetadata () const
 
std::list< const
DashboardDescriptor * > 
getAllDashboardsMetadata () const
 
const DBMetadatagetCurrentDB () const
 
Data_Namespace::DataMgrgetDataMgr () const
 
std::shared_ptr< CalcitegetCalciteMgr () const
 
const std::string & getBasePath () const
 
const DictDescriptorgetMetadataForDict (int dict_ref, bool loadDict=true) const
 
const std::vector< LeafHostInfo > & getStringDictionaryHosts () const
 
const ColumnDescriptorgetShardColumnMetadataForTable (const TableDescriptor *td) const
 
std::vector< const
TableDescriptor * > 
getPhysicalTablesDescriptors (const TableDescriptor *logicalTableDesc) const
 
std::vector< std::string > getTableNamesForUser (const UserMetadata &user, const GetTablesType get_tables_type) const
 
int32_t getTableEpoch (const int32_t db_id, const int32_t table_id) const
 
void setTableEpoch (const int db_id, const int table_id, const int new_epoch)
 
int getDatabaseId () const
 
SqliteConnectorgetSqliteConnector ()
 
void roll (const bool forward)
 
DictRef addDictionary (ColumnDescriptor &cd)
 
void delDictionary (const ColumnDescriptor &cd)
 
void getDictionary (const ColumnDescriptor &cd, std::map< int, StringDictionary * > &stringDicts)
 
const bool checkMetadataForDeletedRecs (const TableDescriptor *td, int column_id) const
 
const ColumnDescriptorgetDeletedColumn (const TableDescriptor *td) const
 
const ColumnDescriptorgetDeletedColumnIfRowsDeleted (const TableDescriptor *td) const
 
void setDeletedColumn (const TableDescriptor *td, const ColumnDescriptor *cd)
 
void setDeletedColumnUnlocked (const TableDescriptor *td, const ColumnDescriptor *cd)
 
int getLogicalTableId (const int physicalTableId) const
 
void checkpoint (const int logicalTableId) const
 
std::string name () const
 
void eraseDBData ()
 
void eraseTablePhysicalData (const TableDescriptor *td)
 
void vacuumDeletedRows (const TableDescriptor *td) const
 
void vacuumDeletedRows (const int logicalTableId) const
 
void setForReload (const int32_t tableId)
 
std::vector< std::string > getTableDataDirectories (const TableDescriptor *td) const
 
std::vector< std::string > getTableDictDirectories (const TableDescriptor *td) const
 
std::string getColumnDictDirectory (const ColumnDescriptor *cd) const
 
std::string dumpSchema (const TableDescriptor *td) const
 
void createForeignServer (std::unique_ptr< foreign_storage::ForeignServer > foreign_server, bool if_not_exists)
 
foreign_storage::ForeignServergetForeignServer (const std::string &server_name) const
 
foreign_storage::ForeignServergetForeignServerSkipCache (const std::string &server_name)
 
void dropForeignServer (const std::string &server_name)
 
void createDefaultServersIfNotExists ()
 

Static Public Member Functions

static void expandGeoColumn (const ColumnDescriptor &cd, std::list< ColumnDescriptor > &columns)
 
static void set (const std::string &dbName, std::shared_ptr< Catalog > cat)
 
static std::shared_ptr< Catalogget (const std::string &dbName)
 
static std::shared_ptr< Catalogget (const std::string &basePath, const DBMetadata &curDB, std::shared_ptr< Data_Namespace::DataMgr > dataMgr, const std::vector< LeafHostInfo > &string_dict_hosts, std::shared_ptr< Calcite > calcite, bool is_new_db)
 
static void remove (const std::string &dbName)
 

Public Attributes

std::mutex sqliteMutex_
 
mapd_shared_mutex sharedMutex_
 
std::atomic< std::thread::id > thread_holding_sqlite_lock
 
std::atomic< std::thread::id > thread_holding_write_lock
 

Static Public Attributes

static thread_local bool thread_holds_read_lock = false
 

Protected Types

using ColumnDescriptorsForRoll = std::vector< std::pair< ColumnDescriptor *, ColumnDescriptor * >>
 

Protected Member Functions

void CheckAndExecuteMigrations ()
 
void CheckAndExecuteMigrationsPostBuildMaps ()
 
void updateDictionaryNames ()
 
void updateTableDescriptorSchema ()
 
void updateFixlenArrayColumns ()
 
void updateGeoColumns ()
 
void updateFrontendViewSchema ()
 
void updateLinkSchema ()
 
void updateFrontendViewAndLinkUsers ()
 
void updateLogicalToPhysicalTableLinkSchema ()
 
void updateLogicalToPhysicalTableMap (const int32_t logical_tb_id)
 
void updateDictionarySchema ()
 
void updatePageSize ()
 
void updateDeletedColumnIndicator ()
 
void updateFrontendViewsToDashboards ()
 
void createFsiSchemasAndDefaultServers ()
 
void dropFsiSchemasAndTables ()
 
void recordOwnershipOfObjectsInObjectPermissions ()
 
void checkDateInDaysColumnMigration ()
 
void createDashboardSystemRoles ()
 
void buildMaps ()
 
void addTableToMap (const TableDescriptor *td, const std::list< ColumnDescriptor > &columns, const std::list< DictDescriptor > &dicts)
 
void addReferenceToForeignDict (ColumnDescriptor &referencing_column, Parser::SharedDictionaryDef shared_dict_def, const bool persist_reference)
 
bool setColumnSharedDictionary (ColumnDescriptor &cd, std::list< ColumnDescriptor > &cdd, std::list< DictDescriptor > &dds, const TableDescriptor td, const std::vector< Parser::SharedDictionaryDef > &shared_dict_defs)
 
void setColumnDictionary (ColumnDescriptor &cd, std::list< DictDescriptor > &dds, const TableDescriptor &td, const bool isLogicalTable)
 
void addFrontendViewToMap (DashboardDescriptor &vd)
 
void addFrontendViewToMapNoLock (DashboardDescriptor &vd)
 
void addLinkToMap (LinkDescriptor &ld)
 
void removeTableFromMap (const std::string &tableName, const int tableId, const bool is_on_error=false)
 
void doDropTable (const TableDescriptor *td)
 
void executeDropTableSqliteQueries (const TableDescriptor *td)
 
void doTruncateTable (const TableDescriptor *td)
 
void renamePhysicalTable (const TableDescriptor *td, const std::string &newTableName)
 
void instantiateFragmenter (TableDescriptor *td) const
 
void getAllColumnMetadataForTable (const TableDescriptor *td, std::list< const ColumnDescriptor * > &colDescs, const bool fetchSystemColumns, const bool fetchVirtualColumns, const bool fetchPhysicalColumns) const
 
std::string calculateSHA1 (const std::string &data)
 
std::string generatePhysicalTableName (const std::string &logicalTableName, const int32_t &shardNumber)
 
std::vector< DBObjectparseDashboardObjects (const std::string &view_meta, const int &user_id)
 
void createOrUpdateDashboardSystemRole (const std::string &view_meta, const int32_t &user_id, const std::string &dash_role_name)
 
const int getColumnIdBySpiUnlocked (const int table_id, const size_t spi) const
 
void serializeTableJsonUnlocked (const TableDescriptor *td, const std::list< ColumnDescriptor > &cds) const
 
void dropTableFromJsonUnlocked (const std::string &table_name) const
 

Protected Attributes

std::string basePath_
 
TableDescriptorMap tableDescriptorMap_
 
TableDescriptorMapById tableDescriptorMapById_
 
ColumnDescriptorMap columnDescriptorMap_
 
ColumnDescriptorMapById columnDescriptorMapById_
 
DictDescriptorMapById dictDescriptorMapByRef_
 
DashboardDescriptorMap dashboardDescriptorMap_
 
LinkDescriptorMap linkDescriptorMap_
 
LinkDescriptorMapById linkDescriptorMapById_
 
ForeignServerMap foreignServerMap_
 
ForeignServerMapById foreignServerMapById_
 
SqliteConnector sqliteConnector_
 
DBMetadata currentDB_
 
std::shared_ptr
< Data_Namespace::DataMgr
dataMgr_
 
const std::vector< LeafHostInfostring_dict_hosts_
 
std::shared_ptr< CalcitecalciteMgr_
 
LogicalToPhysicalTableMapById logicalToPhysicalTableMapById_
 
int nextTempTableId_
 
int nextTempDictId_
 
ColumnDescriptorsForRoll columnDescriptorsForRoll
 

Static Protected Attributes

static const std::string physicalTableNameTag_
 

Private Member Functions

void adjustAlteredTableFiles (const std::string &temp_data_dir, const std::unordered_map< int, int > &all_column_ids_map) const
 
void renameTableDirectories (const std::string &temp_data_dir, const std::vector< std::string > &target_paths, const std::string &name_prefix) const
 
void buildForeignServerMap ()
 
void addForeignTableDetails ()
 
void createForeignServerNoLocks (std::unique_ptr< foreign_storage::ForeignServer > foreign_server, bool if_not_exists)
 

Private Attributes

DeletedColumnPerTableMap deletedColumnPerTable_
 

Static Private Attributes

static std::map< std::string,
std::shared_ptr< Catalog > > 
mapd_cat_map_
 

Detailed Description

class for a per-database catalog. also includes metadata for the current database and the current user.

Catalog

Definition at line 86 of file Catalog.h.

Member Typedef Documentation

Definition at line 392 of file Catalog.h.

Constructor & Destructor Documentation

Catalog_Namespace::Catalog::Catalog ( const std::string &  basePath,
const DBMetadata curDB,
std::shared_ptr< Data_Namespace::DataMgr dataMgr,
const std::vector< LeafHostInfo > &  string_dict_hosts,
std::shared_ptr< Calcite calcite,
bool  is_new_db 
)

Constructor - takes basePath to already extant data directory for writing.

Parameters
basePathdirectory path for writing catalog
dbNamename of the database
fragmenterFragmenter object metadata - expects for this directory to already exist

Definition at line 158 of file Catalog.cpp.

References basePath_, buildMaps(), CheckAndExecuteMigrations(), CheckAndExecuteMigrationsPostBuildMaps(), currentDB_, Catalog_Namespace::DBMetadata::dbName, g_serialize_temp_tables, and Catalog_Namespace::anonymous_namespace{Catalog.cpp}::table_json_filepath().

164  : basePath_(basePath)
165  , sqliteConnector_(curDB.dbName, basePath + "/mapd_catalogs/")
166  , currentDB_(curDB)
167  , dataMgr_(dataMgr)
168  , string_dict_hosts_(string_dict_hosts)
169  , calciteMgr_(calcite)
172  , sqliteMutex_()
173  , sharedMutex_()
176  if (!is_new_db) {
178  }
179  buildMaps();
180  if (!is_new_db) {
182  }
184  boost::filesystem::remove(table_json_filepath(basePath_, currentDB_.dbName));
185  }
186 }
const int MAPD_TEMP_TABLE_START_ID
Definition: Catalog.cpp:99
mapd_shared_mutex sharedMutex_
Definition: Catalog.h:417
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
const std::vector< LeafHostInfo > string_dict_hosts_
Definition: Catalog.h:378
std::shared_ptr< Data_Namespace::DataMgr > dataMgr_
Definition: Catalog.h:376
auto table_json_filepath(const std::string &base_path, const std::string &db_name)
Definition: Catalog.cpp:150
const int MAPD_TEMP_DICT_START_ID
Definition: Catalog.cpp:101
std::atomic< std::thread::id > thread_holding_sqlite_lock
Definition: Catalog.h:418
bool g_serialize_temp_tables
Definition: Catalog.cpp:94
std::shared_ptr< Calcite > calciteMgr_
Definition: Catalog.h:379
std::atomic< std::thread::id > thread_holding_write_lock
Definition: Catalog.h:419
void CheckAndExecuteMigrationsPostBuildMaps()
Definition: Catalog.cpp:907

+ Here is the call graph for this function:

Catalog_Namespace::Catalog::~Catalog ( )

Destructor - deletes all ColumnDescriptor and TableDescriptor structures which were allocated on the heap and writes Catalog to Sqlite.

Definition at line 188 of file Catalog.cpp.

References basePath_, columnDescriptorMap_, currentDB_, Catalog_Namespace::DBMetadata::dbName, g_serialize_temp_tables, Catalog_Namespace::anonymous_namespace{Catalog.cpp}::table_json_filepath(), and tableDescriptorMap_.

188  {
189  cat_write_lock write_lock(this);
190  // must clean up heap-allocated TableDescriptor and ColumnDescriptor structs
191  for (TableDescriptorMap::iterator tableDescIt = tableDescriptorMap_.begin();
192  tableDescIt != tableDescriptorMap_.end();
193  ++tableDescIt) {
194  if (tableDescIt->second->fragmenter != nullptr) {
195  delete tableDescIt->second->fragmenter;
196  }
197  delete tableDescIt->second;
198  }
199 
200  // TableDescriptorMapById points to the same descriptors. No need to delete
201 
202  for (ColumnDescriptorMap::iterator columnDescIt = columnDescriptorMap_.begin();
203  columnDescIt != columnDescriptorMap_.end();
204  ++columnDescIt) {
205  delete columnDescIt->second;
206  }
207 
208  // ColumnDescriptorMapById points to the same descriptors. No need to delete
209 
211  boost::filesystem::remove(table_json_filepath(basePath_, currentDB_.dbName));
212  }
213 }
ColumnDescriptorMap columnDescriptorMap_
Definition: Catalog.h:365
auto table_json_filepath(const std::string &base_path, const std::string &db_name)
Definition: Catalog.cpp:150
bool g_serialize_temp_tables
Definition: Catalog.cpp:94
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110
TableDescriptorMap tableDescriptorMap_
Definition: Catalog.h:363

+ Here is the call graph for this function:

Member Function Documentation

void Catalog_Namespace::Catalog::addColumn ( const TableDescriptor td,
ColumnDescriptor cd 
)

Definition at line 1804 of file Catalog.cpp.

References addDictionary(), columnDescriptorMap_, columnDescriptorsForRoll, ColumnDescriptor::columnId, ColumnDescriptor::columnName, ColumnDescriptor::columnType, SQLTypeInfo::get_comp_param(), SQLTypeInfo::get_compression(), SQLTypeInfo::get_dimension(), SQLTypeInfo::get_notnull(), SQLTypeInfo::get_scale(), SQLTypeInfo::get_size(), SQLTypeInfo::get_subtype(), SQLTypeInfo::get_type(), SqliteConnector::getData(), getPhysicalTablesDescriptors(), ColumnDescriptor::isDeletedCol, ColumnDescriptor::isSystemCol, ColumnDescriptor::isVirtualCol, kENCODING_DICT, TableDescriptor::nShards, SqliteConnector::query_with_text_params(), TableDescriptor::shard, sqliteConnector_, tableDescriptorMapById_, ColumnDescriptor::tableId, TableDescriptor::tableId, to_string(), to_upper(), and ColumnDescriptor::virtualExpr.

1804  {
1805  cat_write_lock write_lock(this);
1806  // caller must handle sqlite/chunk transaction TOGETHER
1807  cd.tableId = td.tableId;
1808  if (td.nShards > 0 && td.shard < 0) {
1809  for (const auto shard : getPhysicalTablesDescriptors(&td)) {
1810  auto shard_cd = cd;
1811  addColumn(*shard, shard_cd);
1812  }
1813  }
1815  addDictionary(cd);
1816  }
1817 
1819  "INSERT INTO mapd_columns (tableid, columnid, name, coltype, colsubtype, coldim, "
1820  "colscale, is_notnull, "
1821  "compression, comp_param, size, chunks, is_systemcol, is_virtualcol, virtual_expr, "
1822  "is_deletedcol) "
1823  "VALUES (?, "
1824  "(SELECT max(columnid) + 1 FROM mapd_columns WHERE tableid = ?), "
1825  "?, ?, ?, "
1826  "?, "
1827  "?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1828  std::vector<std::string>{std::to_string(td.tableId),
1829  std::to_string(td.tableId),
1830  cd.columnName,
1839  "",
1842  cd.virtualExpr,
1844 
1846  "UPDATE mapd_tables SET ncolumns = ncolumns + 1 WHERE tableid = ?",
1847  std::vector<std::string>{std::to_string(td.tableId)});
1848 
1850  "SELECT columnid FROM mapd_columns WHERE tableid = ? AND name = ?",
1851  std::vector<std::string>{std::to_string(td.tableId), cd.columnName});
1852  cd.columnId = sqliteConnector_.getData<int>(0, 0);
1853 
1854  ++tableDescriptorMapById_[td.tableId]->nColumns;
1855  auto ncd = new ColumnDescriptor(cd);
1858  columnDescriptorsForRoll.emplace_back(nullptr, ncd);
1859 }
std::string virtualExpr
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:249
std::tuple< int, std::string > ColumnKey
Definition: Types.h:36
HOST DEVICE int get_size() const
Definition: sqltypes.h:258
T getData(const int row, const int col)
ColumnDescriptorMap columnDescriptorMap_
Definition: Catalog.h:365
virtual void query_with_text_params(std::string const &query_only)
void addColumn(const TableDescriptor &td, ColumnDescriptor &cd)
Definition: Catalog.cpp:1804
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
std::vector< const TableDescriptor * > getPhysicalTablesDescriptors(const TableDescriptor *logicalTableDesc) const
Definition: Catalog.cpp:3287
HOST DEVICE int get_scale() const
Definition: sqltypes.h:253
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:248
ColumnDescriptorMapById columnDescriptorMapById_
Definition: Catalog.h:366
std::string to_string(char const *&&v)
TableDescriptorMapById tableDescriptorMapById_
Definition: Catalog.h:364
specifies the content in-memory of a row in the column metadata table
std::string to_upper(const std::string &str)
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:256
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:250
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:257
SQLTypeInfo columnType
DictRef addDictionary(ColumnDescriptor &cd)
Definition: Catalog.cpp:1709
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:255
ColumnDescriptorsForRoll columnDescriptorsForRoll
Definition: Catalog.h:393
std::string columnName
std::tuple< int, int > ColumnIdKey
Definition: Types.h:38

+ Here is the call graph for this function:

DictRef Catalog_Namespace::Catalog::addDictionary ( ColumnDescriptor cd)

Definition at line 1709 of file Catalog.cpp.

References CHECK(), currentDB_, Catalog_Namespace::DBMetadata::dbId, dictDescriptorMapByRef_, DictDescriptor::dictFolderPath, setColumnDictionary(), string_dict_hosts_, tableDescriptorMapById_, and ColumnDescriptor::tableId.

Referenced by addColumn().

1709  {
1710  const auto& td = *tableDescriptorMapById_[cd.tableId];
1711  list<DictDescriptor> dds;
1712  setColumnDictionary(cd, dds, td, true);
1713  auto& dd = dds.back();
1714  CHECK(dd.dictRef.dictId);
1715 
1716  std::unique_ptr<StringDictionaryClient> client;
1717  if (!string_dict_hosts_.empty()) {
1718  client.reset(new StringDictionaryClient(
1719  string_dict_hosts_.front(), DictRef(currentDB_.dbId, -1), true));
1720  }
1721  if (client) {
1722  client->create(dd.dictRef, dd.dictIsTemp);
1723  }
1724 
1725  DictDescriptor* new_dd = new DictDescriptor(dd);
1726  dictDescriptorMapByRef_[dd.dictRef].reset(new_dd);
1727  if (!dd.dictIsTemp) {
1728  boost::filesystem::create_directory(new_dd->dictFolderPath);
1729  }
1730  return dd.dictRef;
1731 }
std::string dictFolderPath
const std::vector< LeafHostInfo > string_dict_hosts_
Definition: Catalog.h:378
DictDescriptorMapById dictDescriptorMapByRef_
Definition: Catalog.h:367
CHECK(cgen_state)
TableDescriptorMapById tableDescriptorMapById_
Definition: Catalog.h:364
struct dict_ref_t DictRef
Definition: DictRef.h:37
Descriptor for a dictionary for a string columne.
void setColumnDictionary(ColumnDescriptor &cd, std::list< DictDescriptor > &dds, const TableDescriptor &td, const bool isLogicalTable)
Definition: Catalog.cpp:2722

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::addForeignTableDetails ( )
private

Definition at line 3510 of file Catalog.cpp.

References CHECK(), foreignServerMapById_, SqliteConnector::getData(), SqliteConnector::getNumRows(), num_rows, SqliteConnector::query(), sqliteConnector_, and tableDescriptorMapById_.

Referenced by buildMaps().

3510  {
3512  "SELECT table_id, server_id, options from omnisci_foreign_tables");
3514  for (size_t r = 0; r < num_rows; r++) {
3515  const auto table_id = sqliteConnector_.getData<int>(r, 0);
3516  const auto server_id = sqliteConnector_.getData<int>(r, 1);
3517  const auto& options = sqliteConnector_.getData<std::string>(r, 2);
3518 
3519  CHECK(tableDescriptorMapById_.find(table_id) != tableDescriptorMapById_.end());
3520  auto foreign_table =
3521  dynamic_cast<foreign_storage::ForeignTable*>(tableDescriptorMapById_[table_id]);
3522  CHECK(foreign_table);
3523  foreign_table->foreign_server = foreignServerMapById_[server_id].get();
3524  CHECK(foreign_table->foreign_server);
3525  foreign_table->populateOptionsMap(options);
3526  }
3527 }
T getData(const int row, const int col)
const int8_t const int64_t * num_rows
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
virtual void query(const std::string &queryString)
CHECK(cgen_state)
TableDescriptorMapById tableDescriptorMapById_
Definition: Catalog.h:364
ForeignServerMapById foreignServerMapById_
Definition: Catalog.h:372
virtual size_t getNumRows() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::addFrontendViewToMap ( DashboardDescriptor vd)
protected

Definition at line 1276 of file Catalog.cpp.

References addFrontendViewToMapNoLock().

Referenced by createDashboard().

1276  {
1277  cat_write_lock write_lock(this);
1279 }
void addFrontendViewToMapNoLock(DashboardDescriptor &vd)
Definition: Catalog.cpp:1281
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::addFrontendViewToMapNoLock ( DashboardDescriptor vd)
protected

Definition at line 1281 of file Catalog.cpp.

References dashboardDescriptorMap_, DashboardDescriptor::dashboardName, to_string(), and DashboardDescriptor::userId.

Referenced by addFrontendViewToMap(), and replaceDashboard().

1281  {
1282  cat_write_lock write_lock(this);
1284  std::make_shared<DashboardDescriptor>(vd);
1285 }
DashboardDescriptorMap dashboardDescriptorMap_
Definition: Catalog.h:368
std::string to_string(char const *&&v)
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::addLinkToMap ( LinkDescriptor ld)
protected

Definition at line 1358 of file Catalog.cpp.

References currentDB_, Catalog_Namespace::DBMetadata::dbId, LinkDescriptor::link, linkDescriptorMap_, linkDescriptorMapById_, LinkDescriptor::linkId, and to_string().

Referenced by createLink().

1358  {
1359  cat_write_lock write_lock(this);
1360  LinkDescriptor* new_ld = new LinkDescriptor();
1361  *new_ld = ld;
1363  linkDescriptorMapById_[ld.linkId] = new_ld;
1364 }
std::string to_string(char const *&&v)
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110
LinkDescriptorMapById linkDescriptorMapById_
Definition: Catalog.h:370
LinkDescriptorMap linkDescriptorMap_
Definition: Catalog.h:369

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::addReferenceToForeignDict ( ColumnDescriptor referencing_column,
Parser::SharedDictionaryDef  shared_dict_def,
const bool  persist_reference 
)
protected

Definition at line 2631 of file Catalog.cpp.

References CHECK(), CHECK_GE, ColumnDescriptor::columnType, currentDB_, Catalog_Namespace::DBMetadata::dbId, dictDescriptorMapByRef_, SQLTypeInfo::get_comp_param(), Catalog_Namespace::anonymous_namespace{Catalog.cpp}::get_foreign_col(), SqliteConnector::query_with_text_params(), sqliteConnector_, and to_string().

Referenced by setColumnSharedDictionary().

2633  {
2634  cat_write_lock write_lock(this);
2635  const auto foreign_ref_col = get_foreign_col(*this, shared_dict_def);
2636  CHECK(foreign_ref_col);
2637  referencing_column.columnType = foreign_ref_col->columnType;
2638  const int dict_id = referencing_column.columnType.get_comp_param();
2639  const DictRef dict_ref(currentDB_.dbId, dict_id);
2640  const auto dictIt = dictDescriptorMapByRef_.find(dict_ref);
2641  CHECK(dictIt != dictDescriptorMapByRef_.end());
2642  const auto& dd = dictIt->second;
2643  CHECK_GE(dd->refcount, 1);
2644  ++dd->refcount;
2645  if (persist_reference) {
2646  cat_sqlite_lock sqlite_lock(this);
2648  "UPDATE mapd_dictionaries SET refcount = refcount + 1 WHERE dictid = ?",
2649  {std::to_string(dict_id)});
2650  }
2651 }
virtual void query_with_text_params(std::string const &query_only)
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
DictDescriptorMapById dictDescriptorMapByRef_
Definition: Catalog.h:367
#define CHECK_GE(x, y)
Definition: Logger.h:210
const ColumnDescriptor * get_foreign_col(const Catalog &cat, const Parser::SharedDictionaryDef &shared_dict_def)
Definition: Catalog.cpp:2619
std::string to_string(char const *&&v)
CHECK(cgen_state)
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:257
SQLTypeInfo columnType
sqlite_lock< Catalog > cat_sqlite_lock
Definition: Catalog.cpp:111

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::addTableToMap ( const TableDescriptor td,
const std::list< ColumnDescriptor > &  columns,
const std::list< DictDescriptor > &  dicts 
)
protected

Definition at line 1134 of file Catalog.cpp.

References CHECK(), columnDescriptorMap_, columnDescriptorMapById_, ColumnDescriptor::columnId, TableDescriptor::columnIdBySpi_, ColumnDescriptor::columnName, currentDB_, Catalog_Namespace::DBMetadata::dbId, dictDescriptorMapByRef_, DictDescriptor::dictFolderPath, dict_ref_t::dictId, TableDescriptor::hasDeletedCol, TableDescriptor::mutex_, setDeletedColumnUnlocked(), string_dict_hosts_, tableDescriptorMap_, tableDescriptorMapById_, ColumnDescriptor::tableId, TableDescriptor::tableId, TableDescriptor::tableName, and to_upper().

Referenced by createTable().

1136  {
1137  cat_write_lock write_lock(this);
1138  TableDescriptor* new_td;
1139 
1140  auto foreign_table = dynamic_cast<const foreign_storage::ForeignTable*>(td);
1141  if (foreign_table) {
1142  auto new_foreign_table = new foreign_storage::ForeignTable();
1143  *new_foreign_table = *foreign_table;
1144  new_td = new_foreign_table;
1145  } else {
1146  new_td = new TableDescriptor();
1147  *new_td = *td;
1148  }
1149 
1150  new_td->mutex_ = std::make_shared<std::mutex>();
1151  tableDescriptorMap_[to_upper(td->tableName)] = new_td;
1152  tableDescriptorMapById_[td->tableId] = new_td;
1153  for (auto cd : columns) {
1154  ColumnDescriptor* new_cd = new ColumnDescriptor();
1155  *new_cd = cd;
1156  ColumnKey columnKey(new_cd->tableId, to_upper(new_cd->columnName));
1157  columnDescriptorMap_[columnKey] = new_cd;
1158  ColumnIdKey columnIdKey(new_cd->tableId, new_cd->columnId);
1159  columnDescriptorMapById_[columnIdKey] = new_cd;
1160 
1161  // Add deleted column to the map
1162  if (cd.isDeletedCol) {
1163  CHECK(new_td->hasDeletedCol);
1164  setDeletedColumnUnlocked(new_td, new_cd);
1165  }
1166  }
1167 
1168  std::sort(new_td->columnIdBySpi_.begin(),
1169  new_td->columnIdBySpi_.end(),
1170  [](const size_t a, const size_t b) -> bool { return a < b; });
1171 
1172  std::unique_ptr<StringDictionaryClient> client;
1173  DictRef dict_ref(currentDB_.dbId, -1);
1174  if (!string_dict_hosts_.empty()) {
1175  client.reset(new StringDictionaryClient(string_dict_hosts_.front(), dict_ref, true));
1176  }
1177  for (auto dd : dicts) {
1178  if (!dd.dictRef.dictId) {
1179  // Dummy entry created for a shard of a logical table, nothing to do.
1180  continue;
1181  }
1182  dict_ref.dictId = dd.dictRef.dictId;
1183  if (client) {
1184  client->create(dict_ref, dd.dictIsTemp);
1185  }
1186  DictDescriptor* new_dd = new DictDescriptor(dd);
1187  dictDescriptorMapByRef_[dict_ref].reset(new_dd);
1188  if (!dd.dictIsTemp) {
1189  boost::filesystem::create_directory(new_dd->dictFolderPath);
1190  }
1191  }
1192 }
std::string dictFolderPath
std::tuple< int, std::string > ColumnKey
Definition: Types.h:36
std::string tableName
ColumnDescriptorMap columnDescriptorMap_
Definition: Catalog.h:365
const std::vector< LeafHostInfo > string_dict_hosts_
Definition: Catalog.h:378
DictDescriptorMapById dictDescriptorMapByRef_
Definition: Catalog.h:367
std::vector< int > columnIdBySpi_
ColumnDescriptorMapById columnDescriptorMapById_
Definition: Catalog.h:366
std::shared_ptr< std::mutex > mutex_
CHECK(cgen_state)
void setDeletedColumnUnlocked(const TableDescriptor *td, const ColumnDescriptor *cd)
Definition: Catalog.cpp:2610
TableDescriptorMapById tableDescriptorMapById_
Definition: Catalog.h:364
specifies the content in-memory of a row in the column metadata table
std::string to_upper(const std::string &str)
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110
Descriptor for a dictionary for a string columne.
specifies the content in-memory of a row in the table metadata table
std::string columnName
TableDescriptorMap tableDescriptorMap_
Definition: Catalog.h:363
std::tuple< int, int > ColumnIdKey
Definition: Types.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::adjustAlteredTableFiles ( const std::string &  temp_data_dir,
const std::unordered_map< int, int > &  all_column_ids_map 
) const
private
void Catalog_Namespace::Catalog::buildForeignServerMap ( )
private

Definition at line 3493 of file Catalog.cpp.

References foreignServerMap_, foreignServerMapById_, SqliteConnector::getData(), SqliteConnector::getNumRows(), foreign_storage::ForeignServer::id, foreign_storage::ForeignServer::name, num_rows, foreign_storage::OptionsContainer::populateOptionsMap(), SqliteConnector::query(), sqliteConnector_, and foreign_storage::ForeignServer::user_id.

Referenced by buildMaps().

3493  {
3495  "SELECT id, name, data_wrapper_type, options, owner_user_id FROM "
3496  "omnisci_foreign_servers");
3498  for (size_t row = 0; row < num_rows; row++) {
3499  auto foreign_server = std::make_shared<foreign_storage::ForeignServer>(
3500  foreign_storage::DataWrapper{sqliteConnector_.getData<std::string>(row, 2)});
3501  foreign_server->id = sqliteConnector_.getData<int>(row, 0);
3502  foreign_server->name = sqliteConnector_.getData<std::string>(row, 1);
3503  foreign_server->populateOptionsMap(sqliteConnector_.getData<std::string>(row, 3));
3504  foreign_server->user_id = sqliteConnector_.getData<std::int32_t>(row, 4);
3505  foreignServerMap_[foreign_server->name] = foreign_server;
3506  foreignServerMapById_[foreign_server->id] = foreign_server;
3507  }
3508 }
T getData(const int row, const int col)
const int8_t const int64_t * num_rows
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
virtual void query(const std::string &queryString)
ForeignServerMapById foreignServerMapById_
Definition: Catalog.h:372
ForeignServerMap foreignServerMap_
Definition: Catalog.h:371
virtual size_t getNumRows() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::buildMaps ( )
protected

Definition at line 923 of file Catalog.cpp.

References addForeignTableDetails(), basePath_, buildForeignServerMap(), CHECK(), ColumnDescriptor::chunks, columnDescriptorMap_, columnDescriptorMapById_, ColumnDescriptor::columnId, ColumnDescriptor::columnName, ColumnDescriptor::columnType, currentDB_, dashboardDescriptorMap_, Catalog_Namespace::DBMetadata::dbId, Catalog_Namespace::DBMetadata::dbName, dictDescriptorMapByRef_, logger::FATAL, StorageType::FOREIGN_TABLE, TableDescriptor::fragmenter, TableDescriptor::fragments, TableDescriptor::fragPageSize, TableDescriptor::fragType, g_enable_fsi, generate_dashboard_system_rolename(), SQLTypeInfo::get_physical_cols(), SqliteConnector::getData(), SqliteConnector::getNumRows(), Catalog_Namespace::anonymous_namespace{Catalog.cpp}::getUserFromId(), TableDescriptor::hasDeletedCol, SQLTypeInfo::is_geometry(), ColumnDescriptor::isDeletedCol, ColumnDescriptor::isGeoPhyCol, SqliteConnector::isNull(), ColumnDescriptor::isSystemCol, TableDescriptor::isView, ColumnDescriptor::isVirtualCol, TableDescriptor::keyMetainfo, LinkDescriptor::link, linkDescriptorMap_, linkDescriptorMapById_, LinkDescriptor::linkId, LOG, logicalToPhysicalTableMapById_, TableDescriptor::maxChunkSize, TableDescriptor::maxFragRows, TableDescriptor::maxRows, TableDescriptor::nColumns, TableDescriptor::nShards, TableDescriptor::partitions, SqliteConnector::query(), SQLTypeInfo::set_comp_param(), SQLTypeInfo::set_compression(), SQLTypeInfo::set_dimension(), SQLTypeInfo::set_notnull(), SQLTypeInfo::set_scale(), SQLTypeInfo::set_size(), SQLTypeInfo::set_subtype(), SQLTypeInfo::set_type(), setDeletedColumnUnlocked(), TableDescriptor::shard, TableDescriptor::shardedColumnId, TableDescriptor::sortedColumnId, sqliteConnector_, TableDescriptor::storageType, tableDescriptorMap_, tableDescriptorMapById_, ColumnDescriptor::tableId, TableDescriptor::tableId, TableDescriptor::tableName, to_string(), to_upper(), LinkDescriptor::updateTime, LinkDescriptor::userId, TableDescriptor::userId, LinkDescriptor::viewMetadata, TableDescriptor::viewSQL, LinkDescriptor::viewState, and ColumnDescriptor::virtualExpr.

Referenced by Catalog().

923  {
924  cat_write_lock write_lock(this);
925  cat_sqlite_lock sqlite_lock(this);
926 
927  string dictQuery(
928  "SELECT dictid, name, nbits, is_shared, refcount from mapd_dictionaries");
929  sqliteConnector_.query(dictQuery);
930  size_t numRows = sqliteConnector_.getNumRows();
931  for (size_t r = 0; r < numRows; ++r) {
932  int dictId = sqliteConnector_.getData<int>(r, 0);
933  std::string dictName = sqliteConnector_.getData<string>(r, 1);
934  int dictNBits = sqliteConnector_.getData<int>(r, 2);
935  bool is_shared = sqliteConnector_.getData<bool>(r, 3);
936  int refcount = sqliteConnector_.getData<int>(r, 4);
937  std::string fname = basePath_ + "/mapd_data/DB_" + std::to_string(currentDB_.dbId) +
938  "_DICT_" + std::to_string(dictId);
939  DictRef dict_ref(currentDB_.dbId, dictId);
940  DictDescriptor* dd = new DictDescriptor(
941  dict_ref, dictName, dictNBits, is_shared, refcount, fname, false);
942  dictDescriptorMapByRef_[dict_ref].reset(dd);
943  }
944 
945  string tableQuery(
946  "SELECT tableid, name, ncolumns, isview, fragments, frag_type, max_frag_rows, "
947  "max_chunk_size, frag_page_size, "
948  "max_rows, partitions, shard_column_id, shard, num_shards, key_metainfo, userid, "
949  "sort_column_id, storage_type "
950  "from mapd_tables");
951  sqliteConnector_.query(tableQuery);
952  numRows = sqliteConnector_.getNumRows();
953  for (size_t r = 0; r < numRows; ++r) {
954  TableDescriptor* td;
955  const auto& storage_type = sqliteConnector_.getData<string>(r, 17);
956  if (!storage_type.empty() &&
957  (!g_enable_fsi || storage_type != StorageType::FOREIGN_TABLE)) {
958  const auto table_id = sqliteConnector_.getData<int>(r, 0);
959  const auto& table_name = sqliteConnector_.getData<string>(r, 1);
960  LOG(FATAL) << "Unable to read Catalog metadata: storage type is currently not a "
961  "supported table option (table "
962  << table_name << " [" << table_id << "] in database "
963  << currentDB_.dbName << ").";
964  }
965 
966  if (storage_type == StorageType::FOREIGN_TABLE) {
968  } else {
969  td = new TableDescriptor();
970  }
971 
972  td->storageType = storage_type;
973  td->tableId = sqliteConnector_.getData<int>(r, 0);
974  td->tableName = sqliteConnector_.getData<string>(r, 1);
975  td->nColumns = sqliteConnector_.getData<int>(r, 2);
976  td->isView = sqliteConnector_.getData<bool>(r, 3);
977  td->fragments = sqliteConnector_.getData<string>(r, 4);
978  td->fragType =
980  td->maxFragRows = sqliteConnector_.getData<int>(r, 6);
981  td->maxChunkSize = sqliteConnector_.getData<int>(r, 7);
982  td->fragPageSize = sqliteConnector_.getData<int>(r, 8);
983  td->maxRows = sqliteConnector_.getData<int64_t>(r, 9);
984  td->partitions = sqliteConnector_.getData<string>(r, 10);
985  td->shardedColumnId = sqliteConnector_.getData<int>(r, 11);
986  td->shard = sqliteConnector_.getData<int>(r, 12);
987  td->nShards = sqliteConnector_.getData<int>(r, 13);
988  td->keyMetainfo = sqliteConnector_.getData<string>(r, 14);
989  td->userId = sqliteConnector_.getData<int>(r, 15);
990  td->sortedColumnId =
991  sqliteConnector_.isNull(r, 16) ? 0 : sqliteConnector_.getData<int>(r, 16);
992  if (!td->isView) {
993  td->fragmenter = nullptr;
994  }
995  td->hasDeletedCol = false;
996 
999  }
1000 
1001  if (g_enable_fsi) {
1004  }
1005 
1006  string columnQuery(
1007  "SELECT tableid, columnid, name, coltype, colsubtype, coldim, colscale, "
1008  "is_notnull, compression, comp_param, "
1009  "size, chunks, is_systemcol, is_virtualcol, virtual_expr, is_deletedcol from "
1010  "mapd_columns ORDER BY tableid, "
1011  "columnid");
1012  sqliteConnector_.query(columnQuery);
1013  numRows = sqliteConnector_.getNumRows();
1014  int32_t skip_physical_cols = 0;
1015  for (size_t r = 0; r < numRows; ++r) {
1016  ColumnDescriptor* cd = new ColumnDescriptor();
1017  cd->tableId = sqliteConnector_.getData<int>(r, 0);
1018  cd->columnId = sqliteConnector_.getData<int>(r, 1);
1019  cd->columnName = sqliteConnector_.getData<string>(r, 2);
1023  cd->columnType.set_scale(sqliteConnector_.getData<int>(r, 6));
1027  cd->columnType.set_size(sqliteConnector_.getData<int>(r, 10));
1028  cd->chunks = sqliteConnector_.getData<string>(r, 11);
1029  cd->isSystemCol = sqliteConnector_.getData<bool>(r, 12);
1030  cd->isVirtualCol = sqliteConnector_.getData<bool>(r, 13);
1031  cd->virtualExpr = sqliteConnector_.getData<string>(r, 14);
1032  cd->isDeletedCol = sqliteConnector_.getData<bool>(r, 15);
1033  cd->isGeoPhyCol = skip_physical_cols > 0;
1034  ColumnKey columnKey(cd->tableId, to_upper(cd->columnName));
1035  columnDescriptorMap_[columnKey] = cd;
1036  ColumnIdKey columnIdKey(cd->tableId, cd->columnId);
1037  columnDescriptorMapById_[columnIdKey] = cd;
1038 
1039  if (skip_physical_cols <= 0) {
1040  skip_physical_cols = cd->columnType.get_physical_cols();
1041  }
1042 
1043  auto td_itr = tableDescriptorMapById_.find(cd->tableId);
1044  CHECK(td_itr != tableDescriptorMapById_.end());
1045 
1046  if (cd->isDeletedCol) {
1047  td_itr->second->hasDeletedCol = true;
1048  setDeletedColumnUnlocked(td_itr->second, cd);
1049  } else if (cd->columnType.is_geometry() || skip_physical_cols-- <= 0) {
1050  tableDescriptorMapById_[cd->tableId]->columnIdBySpi_.push_back(cd->columnId);
1051  }
1052  }
1053  // sort columnIdBySpi_ based on columnId
1054  for (auto& tit : tableDescriptorMapById_) {
1055  std::sort(tit.second->columnIdBySpi_.begin(),
1056  tit.second->columnIdBySpi_.end(),
1057  [](const size_t a, const size_t b) -> bool { return a < b; });
1058  }
1059 
1060  string viewQuery("SELECT tableid, sql FROM mapd_views");
1061  sqliteConnector_.query(viewQuery);
1062  numRows = sqliteConnector_.getNumRows();
1063  for (size_t r = 0; r < numRows; ++r) {
1064  int32_t tableId = sqliteConnector_.getData<int>(r, 0);
1065  TableDescriptor* td = tableDescriptorMapById_[tableId];
1066  td->viewSQL = sqliteConnector_.getData<string>(r, 1);
1067  td->fragmenter = nullptr;
1068  }
1069 
1070  string frontendViewQuery(
1071  "SELECT id, state, name, image_hash, strftime('%Y-%m-%dT%H:%M:%SZ', update_time), "
1072  "userid, "
1073  "metadata "
1074  "FROM mapd_dashboards");
1075  sqliteConnector_.query(frontendViewQuery);
1076  numRows = sqliteConnector_.getNumRows();
1077  for (size_t r = 0; r < numRows; ++r) {
1078  std::shared_ptr<DashboardDescriptor> vd = std::make_shared<DashboardDescriptor>();
1079  vd->dashboardId = sqliteConnector_.getData<int>(r, 0);
1080  vd->dashboardState = sqliteConnector_.getData<string>(r, 1);
1081  vd->dashboardName = sqliteConnector_.getData<string>(r, 2);
1082  vd->imageHash = sqliteConnector_.getData<string>(r, 3);
1083  vd->updateTime = sqliteConnector_.getData<string>(r, 4);
1084  vd->userId = sqliteConnector_.getData<int>(r, 5);
1085  vd->dashboardMetadata = sqliteConnector_.getData<string>(r, 6);
1086  vd->user = getUserFromId(vd->userId);
1087  vd->dashboardSystemRoleName = generate_dashboard_system_rolename(
1089  dashboardDescriptorMap_[std::to_string(vd->userId) + ":" + vd->dashboardName] = vd;
1090  }
1091 
1092  string linkQuery(
1093  "SELECT linkid, userid, link, view_state, strftime('%Y-%m-%dT%H:%M:%SZ', "
1094  "update_time), view_metadata "
1095  "FROM mapd_links");
1096  sqliteConnector_.query(linkQuery);
1097  numRows = sqliteConnector_.getNumRows();
1098  for (size_t r = 0; r < numRows; ++r) {
1099  LinkDescriptor* ld = new LinkDescriptor();
1100  ld->linkId = sqliteConnector_.getData<int>(r, 0);
1101  ld->userId = sqliteConnector_.getData<int>(r, 1);
1102  ld->link = sqliteConnector_.getData<string>(r, 2);
1103  ld->viewState = sqliteConnector_.getData<string>(r, 3);
1104  ld->updateTime = sqliteConnector_.getData<string>(r, 4);
1105  ld->viewMetadata = sqliteConnector_.getData<string>(r, 5);
1107  linkDescriptorMapById_[ld->linkId] = ld;
1108  }
1109 
1110  /* rebuild map linking logical tables to corresponding physical ones */
1111  string logicalToPhysicalTableMapQuery(
1112  "SELECT logical_table_id, physical_table_id "
1113  "FROM mapd_logical_to_physical");
1114  sqliteConnector_.query(logicalToPhysicalTableMapQuery);
1115  numRows = sqliteConnector_.getNumRows();
1116  for (size_t r = 0; r < numRows; ++r) {
1117  int32_t logical_tb_id = sqliteConnector_.getData<int>(r, 0);
1118  int32_t physical_tb_id = sqliteConnector_.getData<int>(r, 1);
1119  const auto physicalTableIt = logicalToPhysicalTableMapById_.find(logical_tb_id);
1120  if (physicalTableIt == logicalToPhysicalTableMapById_.end()) {
1121  /* add new entity to the map logicalToPhysicalTableMapById_ */
1122  std::vector<int32_t> physicalTables;
1123  physicalTables.push_back(physical_tb_id);
1124  const auto it_ok =
1125  logicalToPhysicalTableMapById_.emplace(logical_tb_id, physicalTables);
1126  CHECK(it_ok.second);
1127  } else {
1128  /* update map logicalToPhysicalTableMapById_ */
1129  physicalTableIt->second.push_back(physical_tb_id);
1130  }
1131  }
1132 }
std::string virtualExpr
void set_compression(EncodingType c)
Definition: sqltypes.h:348
void set_size(int s)
Definition: sqltypes.h:346
std::string partitions
std::tuple< int, std::string > ColumnKey
Definition: Types.h:36
T getData(const int row, const int col)
SQLTypes
Definition: sqltypes.h:39
std::string tableName
ColumnDescriptorMap columnDescriptorMap_
Definition: Catalog.h:365
EncodingType
Definition: encodetypes.h:22
#define LOG(tag)
Definition: Logger.h:188
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
DictDescriptorMapById dictDescriptorMapByRef_
Definition: Catalog.h:367
std::string storageType
HOST DEVICE void set_subtype(SQLTypes st)
Definition: sqltypes.h:339
virtual void query(const std::string &queryString)
std::string fragments
ColumnDescriptorMapById columnDescriptorMapById_
Definition: Catalog.h:366
DashboardDescriptorMap dashboardDescriptorMap_
Definition: Catalog.h:368
std::string to_string(char const *&&v)
std::string chunks
int get_physical_cols() const
Definition: sqltypes.h:269
CHECK(cgen_state)
std::string getUserFromId(const int32_t id)
Definition: Catalog.cpp:913
void set_scale(int s)
Definition: sqltypes.h:343
void setDeletedColumnUnlocked(const TableDescriptor *td, const ColumnDescriptor *cd)
Definition: Catalog.cpp:2610
TableDescriptorMapById tableDescriptorMapById_
Definition: Catalog.h:364
specifies the content in-memory of a row in the column metadata table
std::string keyMetainfo
std::string to_upper(const std::string &str)
void set_comp_param(int p)
Definition: sqltypes.h:349
bool isNull(const int row, const int col) const
void set_dimension(int d)
Definition: sqltypes.h:340
Fragmenter_Namespace::FragmenterType fragType
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110
void set_notnull(bool n)
Definition: sqltypes.h:345
bool is_geometry() const
Definition: sqltypes.h:411
Descriptor for a dictionary for a string columne.
std::string viewSQL
SQLTypeInfo columnType
specifies the content in-memory of a row in the table metadata table
sqlite_lock< Catalog > cat_sqlite_lock
Definition: Catalog.cpp:111
LinkDescriptorMapById linkDescriptorMapById_
Definition: Catalog.h:370
static constexpr char const * FOREIGN_TABLE
Fragmenter_Namespace::AbstractFragmenter * fragmenter
bool g_enable_fsi
Definition: Catalog.cpp:89
std::string columnName
virtual size_t getNumRows() const
LogicalToPhysicalTableMapById logicalToPhysicalTableMapById_
Definition: Catalog.h:381
TableDescriptorMap tableDescriptorMap_
Definition: Catalog.h:363
LinkDescriptorMap linkDescriptorMap_
Definition: Catalog.h:369
std::string generate_dashboard_system_rolename(const std::string &db_id, const std::string &dash_id)
std::tuple< int, int > ColumnIdKey
Definition: Types.h:38
HOST DEVICE void set_type(SQLTypes t)
Definition: sqltypes.h:338

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string Catalog_Namespace::Catalog::calculateSHA1 ( const std::string &  data)
protected

Definition at line 3220 of file Catalog.cpp.

Referenced by createLink().

3220  {
3221  boost::uuids::detail::sha1 sha1;
3222  unsigned int digest[5];
3223  sha1.process_bytes(data.c_str(), data.length());
3224  sha1.get_digest(digest);
3225  std::stringstream ss;
3226  for (size_t i = 0; i < 5; i++) {
3227  ss << std::hex << digest[i];
3228  }
3229  return ss.str();
3230 }

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::CheckAndExecuteMigrations ( )
protected

Definition at line 885 of file Catalog.cpp.

References createFsiSchemasAndDefaultServers(), dropFsiSchemasAndTables(), g_enable_fsi, recordOwnershipOfObjectsInObjectPermissions(), updateDeletedColumnIndicator(), updateDictionaryNames(), updateDictionarySchema(), updateFixlenArrayColumns(), updateFrontendViewAndLinkUsers(), updateFrontendViewSchema(), updateFrontendViewsToDashboards(), updateGeoColumns(), updateLinkSchema(), updateLogicalToPhysicalTableLinkSchema(), updatePageSize(), and updateTableDescriptorSchema().

Referenced by Catalog().

885  {
895  updatePageSize();
899 
900  if (g_enable_fsi) {
902  } else {
904  }
905 }
void updateFrontendViewAndLinkUsers()
Definition: Catalog.cpp:407
void recordOwnershipOfObjectsInObjectPermissions()
Definition: Catalog.cpp:683
void updateFrontendViewsToDashboards()
Definition: Catalog.cpp:117
void createFsiSchemasAndDefaultServers()
Definition: Catalog.cpp:608
void updateLogicalToPhysicalTableLinkSchema()
Definition: Catalog.cpp:547
bool g_enable_fsi
Definition: Catalog.cpp:89

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::CheckAndExecuteMigrationsPostBuildMaps ( )
protected

Definition at line 907 of file Catalog.cpp.

References checkDateInDaysColumnMigration(), and createDashboardSystemRoles().

Referenced by Catalog().

907  {
910 }
void checkDateInDaysColumnMigration()
Definition: Catalog.cpp:811

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::checkDateInDaysColumnMigration ( )
protected

Definition at line 811 of file Catalog.cpp.

References getCurrentDB(), migrations::MigrationMgr::migrateDateInDaysMetadata(), sqliteConnector_, and tableDescriptorMapById_.

Referenced by CheckAndExecuteMigrationsPostBuildMaps().

811  {
812  cat_sqlite_lock sqlite_lock(this);
815 }
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:182
static void migrateDateInDaysMetadata(const Catalog_Namespace::TableDescriptorMapById &table_descriptors_by_id, const int database_id, const Catalog_Namespace::Catalog *cat, SqliteConnector &sqlite)
TableDescriptorMapById tableDescriptorMapById_
Definition: Catalog.h:364
sqlite_lock< Catalog > cat_sqlite_lock
Definition: Catalog.cpp:111

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const bool Catalog_Namespace::Catalog::checkMetadataForDeletedRecs ( const TableDescriptor td,
int  column_id 
) const

Definition at line 2545 of file Catalog.cpp.

References CHECK(), currentDB_, dataMgr_, Catalog_Namespace::DBMetadata::dbId, TableDescriptor::fragmenter, table_is_temporary(), and TableDescriptor::tableId.

Referenced by getDeletedColumnIfRowsDeleted().

2546  {
2547  // check if there are rows deleted by examining the deletedColumn metadata
2548  CHECK(td);
2549 
2550  if (table_is_temporary(td)) {
2551  auto fragmenter = td->fragmenter;
2552  CHECK(fragmenter);
2553  return fragmenter->hasDeletedRows(delete_column_id);
2554  } else {
2555  ChunkKey chunk_key_prefix = {currentDB_.dbId, td->tableId, delete_column_id};
2556  std::vector<std::pair<ChunkKey, ChunkMetadata>> chunk_metadata_vec;
2557  dataMgr_->getChunkMetadataVecForKeyPrefix(chunk_metadata_vec, chunk_key_prefix);
2558  int64_t chunk_max{0};
2559 
2560  for (auto chunk_metadata : chunk_metadata_vec) {
2561  chunk_max = chunk_metadata.second.chunkStats.max.tinyintval;
2562  // delete has occured
2563  if (chunk_max == 1) {
2564  return true;
2565  }
2566  }
2567  return false;
2568  }
2569 }
std::vector< int > ChunkKey
Definition: types.h:35
std::shared_ptr< Data_Namespace::DataMgr > dataMgr_
Definition: Catalog.h:376
CHECK(cgen_state)
bool table_is_temporary(const TableDescriptor *const td)
Fragmenter_Namespace::AbstractFragmenter * fragmenter

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::checkpoint ( const int  logicalTableId) const

Definition at line 3357 of file Catalog.cpp.

References Data_Namespace::DataMgr::checkpoint(), getCurrentDB(), getDataMgr(), getMetadataForTable(), and getPhysicalTablesDescriptors().

Referenced by Importer_NS::Loader::checkpoint(), and TableOptimizer::vacuumDeletedRows().

3357  {
3358  const auto td = getMetadataForTable(logicalTableId);
3359  const auto shards = getPhysicalTablesDescriptors(td);
3360  for (const auto shard : shards) {
3361  getDataMgr().checkpoint(getCurrentDB().dbId, shard->tableId);
3362  }
3363 }
Data_Namespace::DataMgr & getDataMgr() const
Definition: Catalog.h:183
void checkpoint(const int db_id, const int tb_id)
Definition: DataMgr.cpp:467
std::vector< const TableDescriptor * > getPhysicalTablesDescriptors(const TableDescriptor *logicalTableDesc) const
Definition: Catalog.cpp:3287
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:182
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32_t Catalog_Namespace::Catalog::createDashboard ( DashboardDescriptor vd)

Definition at line 3086 of file Catalog.cpp.

References addFrontendViewToMap(), createOrUpdateDashboardSystemRole(), currentDB_, DashboardDescriptor::dashboardId, DashboardDescriptor::dashboardMetadata, DashboardDescriptor::dashboardName, DashboardDescriptor::dashboardState, DashboardDescriptor::dashboardSystemRoleName, Catalog_Namespace::DBMetadata::dbId, generate_dashboard_system_rolename(), SqliteConnector::getData(), SqliteConnector::getNumRows(), DashboardDescriptor::imageHash, SqliteConnector::query(), SqliteConnector::query_with_text_params(), sqliteConnector_, to_string(), DashboardDescriptor::updateTime, and DashboardDescriptor::userId.

3086  {
3087  {
3088  cat_write_lock write_lock(this);
3089  cat_sqlite_lock sqlite_lock(this);
3090  sqliteConnector_.query("BEGIN TRANSACTION");
3091  try {
3092  // TODO(andrew): this should be an upsert
3094  "SELECT id FROM mapd_dashboards WHERE name = ? and userid = ?",
3095  std::vector<std::string>{vd.dashboardName, std::to_string(vd.userId)});
3096  if (sqliteConnector_.getNumRows() > 0) {
3098  "UPDATE mapd_dashboards SET state = ?, image_hash = ?, metadata = ?, "
3099  "update_time = "
3100  "datetime('now') where name = ? "
3101  "and userid = ?",
3102  std::vector<std::string>{vd.dashboardState,
3103  vd.imageHash,
3104  vd.dashboardMetadata,
3105  vd.dashboardName,
3106  std::to_string(vd.userId)});
3107  } else {
3109  "INSERT INTO mapd_dashboards (name, state, image_hash, metadata, "
3110  "update_time, "
3111  "userid) "
3112  "VALUES "
3113  "(?,?,?,?, "
3114  "datetime('now'), ?)",
3115  std::vector<std::string>{vd.dashboardName,
3116  vd.dashboardState,
3117  vd.imageHash,
3118  vd.dashboardMetadata,
3119  std::to_string(vd.userId)});
3120  }
3121  } catch (std::exception& e) {
3122  sqliteConnector_.query("ROLLBACK TRANSACTION");
3123  throw;
3124  }
3125  sqliteConnector_.query("END TRANSACTION");
3126 
3127  // now get the auto generated dashboardId
3128  try {
3130  "SELECT id, strftime('%Y-%m-%dT%H:%M:%SZ', update_time) FROM mapd_dashboards "
3131  "WHERE name = ? and userid = ?",
3132  std::vector<std::string>{vd.dashboardName, std::to_string(vd.userId)});
3133  vd.dashboardId = sqliteConnector_.getData<int>(0, 0);
3134  vd.updateTime = sqliteConnector_.getData<std::string>(0, 1);
3135  } catch (std::exception& e) {
3136  throw;
3137  }
3141  }
3142  // NOTE(wamsi): Transactionally unsafe
3145  return vd.dashboardId;
3146 }
T getData(const int row, const int col)
virtual void query_with_text_params(std::string const &query_only)
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
virtual void query(const std::string &queryString)
void addFrontendViewToMap(DashboardDescriptor &vd)
Definition: Catalog.cpp:1276
std::string to_string(char const *&&v)
std::string dashboardSystemRoleName
void createOrUpdateDashboardSystemRole(const std::string &view_meta, const int32_t &user_id, const std::string &dash_role_name)
Definition: Catalog.cpp:1317
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110
sqlite_lock< Catalog > cat_sqlite_lock
Definition: Catalog.cpp:111
virtual size_t getNumRows() const
std::string generate_dashboard_system_rolename(const std::string &db_id, const std::string &dash_id)

+ Here is the call graph for this function:

void Catalog_Namespace::Catalog::createDashboardSystemRoles ( )
protected

Definition at line 817 of file Catalog.cpp.

References createOrUpdateDashboardSystemRole(), currentDB_, Catalog_Namespace::DBMetadata::dbId, logger::ERROR, generate_dashboard_system_rolename(), SqliteConnector::getData(), Catalog_Namespace::SysCatalog::getGranteesOfSharedDashboards(), SqliteConnector::getNumRows(), Catalog_Namespace::SysCatalog::getRoleGrantee(), Catalog_Namespace::SysCatalog::grantRoleBatch(), logger::INFO, Catalog_Namespace::SysCatalog::instance(), LOG, MAPD_VERSION, SqliteConnector::query(), SqliteConnector::query_with_text_params(), run_benchmark_import::result, sqliteConnector_, and to_string().

Referenced by CheckAndExecuteMigrationsPostBuildMaps().

817  {
818  std::unordered_map<std::string, std::pair<int, std::string>> dashboards;
819  std::vector<std::string> dashboard_ids;
820  static const std::string migration_name{"dashboard_roles_migration"};
821  {
822  cat_sqlite_lock sqlite_lock(this);
823  sqliteConnector_.query("BEGIN TRANSACTION");
824  try {
825  // migration_history should be present in all catalogs by now
826  // if not then would be created before this migration
828  "select * from mapd_version_history where migration_history = '" +
829  migration_name + "'");
830  if (sqliteConnector_.getNumRows() != 0) {
831  // no need for further execution
832  sqliteConnector_.query("END TRANSACTION");
833  return;
834  }
835  LOG(INFO) << "Performing dashboard internal roles Migration.";
836  sqliteConnector_.query("select id, userid, metadata from mapd_dashboards");
837  for (size_t i = 0; i < sqliteConnector_.getNumRows(); ++i) {
840  sqliteConnector_.getData<string>(i, 0)))) {
841  // Successfully created roles during previous migration/crash
842  // No need to include them
843  continue;
844  }
845  dashboards[sqliteConnector_.getData<string>(i, 0)] = std::make_pair(
846  sqliteConnector_.getData<int>(i, 1), sqliteConnector_.getData<string>(i, 2));
847  dashboard_ids.push_back(sqliteConnector_.getData<string>(i, 0));
848  }
849  } catch (const std::exception& e) {
850  sqliteConnector_.query("ROLLBACK TRANSACTION");
851  throw;
852  }
853  sqliteConnector_.query("END TRANSACTION");
854  }
855  // All current grantees with shared dashboards.
856  const auto active_grantees =
858 
859  try {
860  // NOTE(wamsi): Transactionally unsafe
861  for (auto dash : dashboards) {
862  createOrUpdateDashboardSystemRole(dash.second.second,
863  dash.second.first,
865  std::to_string(currentDB_.dbId), dash.first));
866  auto result = active_grantees.find(dash.first);
867  if (result != active_grantees.end()) {
870  dash.first)},
871  result->second);
872  }
873  }
875  "INSERT INTO mapd_version_history(version, migration_history) values(?,?)",
876  std::vector<std::string>{std::to_string(MAPD_VERSION), migration_name});
877  } catch (const std::exception& e) {
878  LOG(ERROR) << "Failed to create dashboard system roles during migration: "
879  << e.what();
880  throw;
881  }
882  LOG(INFO) << "Successfully created dashboard system roles during migration.";
883 }
T getData(const int row, const int col)
virtual void query_with_text_params(std::string const &query_only)
#define LOG(tag)
Definition: Logger.h:188
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
virtual void query(const std::string &queryString)
std::string to_string(char const *&&v)
void grantRoleBatch(const std::vector< std::string > &roles, const std::vector< std::string > &grantees)
static SysCatalog & instance()
Definition: SysCatalog.h:256
static const int32_t MAPD_VERSION
Definition: release.h:33
Role * getRoleGrantee(const std::string &name) const
void createOrUpdateDashboardSystemRole(const std::string &view_meta, const int32_t &user_id, const std::string &dash_role_name)
Definition: Catalog.cpp:1317
std::unordered_map< std::string, std::vector< std::string > > getGranteesOfSharedDashboards(const std::vector< std::string > &dashboard_ids)
sqlite_lock< Catalog > cat_sqlite_lock
Definition: Catalog.cpp:111
virtual size_t getNumRows() const
std::string generate_dashboard_system_rolename(const std::string &db_id, const std::string &dash_id)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::createDefaultServersIfNotExists ( )

Creates default local file servers (if they don't already exist).

Definition at line 3529 of file Catalog.cpp.

References foreign_storage::ForeignServer::BASE_PATH_KEY, createForeignServerNoLocks(), foreign_storage::DataWrapper::CSV_WRAPPER_NAME, foreign_storage::ForeignServer::LOCAL_FILE_STORAGE_TYPE, OMNISCI_ROOT_USER_ID, foreign_storage::DataWrapper::PARQUET_WRAPPER_NAME, and foreign_storage::ForeignServer::STORAGE_TYPE_KEY.

Referenced by createFsiSchemasAndDefaultServers().

3529  {
3530  auto local_csv_server = std::make_unique<foreign_storage::ForeignServer>(
3532  local_csv_server->name = "omnisci_local_csv";
3533  local_csv_server
3534  ->options[std::string{foreign_storage::ForeignServer::STORAGE_TYPE_KEY}] =
3536  local_csv_server->user_id = OMNISCI_ROOT_USER_ID;
3537  local_csv_server->options[std::string{foreign_storage::ForeignServer::BASE_PATH_KEY}] =
3538  "/";
3539  local_csv_server->validate();
3540  createForeignServerNoLocks(std::move(local_csv_server), true);
3541 
3542  auto local_parquet_server = std::make_unique<foreign_storage::ForeignServer>(
3544  local_parquet_server->name = "omnisci_local_parquet";
3545  local_parquet_server
3546  ->options[std::string{foreign_storage::ForeignServer::STORAGE_TYPE_KEY}] =
3548  local_parquet_server->user_id = OMNISCI_ROOT_USER_ID;
3549  local_parquet_server
3550  ->options[std::string{foreign_storage::ForeignServer::BASE_PATH_KEY}] = "/";
3551  local_parquet_server->validate();
3552  createForeignServerNoLocks(std::move(local_parquet_server), true);
3553 }
static constexpr char const * PARQUET_WRAPPER_NAME
Definition: ForeignServer.h:32
static constexpr char const * CSV_WRAPPER_NAME
Definition: ForeignServer.h:31
static constexpr std::string_view STORAGE_TYPE_KEY
Definition: ForeignServer.h:50
void createForeignServerNoLocks(std::unique_ptr< foreign_storage::ForeignServer > foreign_server, bool if_not_exists)
Definition: Catalog.cpp:2392
static constexpr std::string_view LOCAL_FILE_STORAGE_TYPE
Definition: ForeignServer.h:52
const int OMNISCI_ROOT_USER_ID
Definition: SysCatalog.h:60
static constexpr std::string_view BASE_PATH_KEY
Definition: ForeignServer.h:51

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::createForeignServer ( std::unique_ptr< foreign_storage::ForeignServer foreign_server,
bool  if_not_exists 
)

Creates a new foreign server DB object.

Parameters
foreign_server- unique pointer to struct containing foreign server details
if_not_exists- flag indicating whether or not an attempt to create a new foreign server should occur if a server with the same name already exists. An exception is thrown if this flag is set to "false" and an attempt is made to create a pre-existing foreign server

Definition at line 2384 of file Catalog.cpp.

References createForeignServerNoLocks().

2386  {
2387  cat_write_lock write_lock(this);
2388  cat_sqlite_lock sqlite_lock(this);
2389  createForeignServerNoLocks(std::move(foreign_server), if_not_exists);
2390 }
void createForeignServerNoLocks(std::unique_ptr< foreign_storage::ForeignServer > foreign_server, bool if_not_exists)
Definition: Catalog.cpp:2392
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110
sqlite_lock< Catalog > cat_sqlite_lock
Definition: Catalog.cpp:111

+ Here is the call graph for this function:

void Catalog_Namespace::Catalog::createForeignServerNoLocks ( std::unique_ptr< foreign_storage::ForeignServer foreign_server,
bool  if_not_exists 
)
private

Same as createForeignServer() but without acquiring locks. This should only be called from within a function/code block that already acquires appropriate locks.

Definition at line 2392 of file Catalog.cpp.

References CHECK_EQ, foreignServerMap_, foreignServerMapById_, SqliteConnector::getData(), SqliteConnector::getNumRows(), SqliteConnector::query_with_text_params(), sqliteConnector_, and to_string().

Referenced by createDefaultServersIfNotExists(), and createForeignServer().

2394  {
2396  "SELECT name from omnisci_foreign_servers where name = ?",
2397  std::vector<std::string>{foreign_server->name});
2398 
2399  if (sqliteConnector_.getNumRows() == 0) {
2401  "INSERT INTO omnisci_foreign_servers (name, data_wrapper_type, owner_user_id, "
2402  "options) "
2403  "VALUES (?, ?, ?, ?)",
2404  std::vector<std::string>{foreign_server->name,
2405  foreign_server->data_wrapper.name,
2406  std::to_string(foreign_server->user_id),
2407  foreign_server->getOptionsAsJsonString()});
2409  "SELECT id from omnisci_foreign_servers where name = ?",
2410  std::vector<std::string>{foreign_server->name});
2411  CHECK_EQ(sqliteConnector_.getNumRows(), size_t(1));
2412  foreign_server->id = sqliteConnector_.getData<int>(0, 0);
2413  } else if (!if_not_exists) {
2414  throw std::runtime_error{"A foreign server with name \"" + foreign_server->name +
2415  "\" already exists."};
2416  }
2417 
2418  std::shared_ptr<foreign_storage::ForeignServer> foreign_server_shared =
2419  std::move(foreign_server);
2420  foreignServerMap_[foreign_server_shared->name] = foreign_server_shared;
2421  foreignServerMapById_[foreign_server_shared->id] = foreign_server_shared;
2422 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
T getData(const int row, const int col)
virtual void query_with_text_params(std::string const &query_only)
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
std::string to_string(char const *&&v)
ForeignServerMapById foreignServerMapById_
Definition: Catalog.h:372
ForeignServerMap foreignServerMap_
Definition: Catalog.h:371
virtual size_t getNumRows() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::createFsiSchemasAndDefaultServers ( )
protected

Definition at line 608 of file Catalog.cpp.

References createDefaultServersIfNotExists(), SqliteConnector::query(), and sqliteConnector_.

Referenced by CheckAndExecuteMigrations().

608  {
609  cat_sqlite_lock sqlite_lock(this);
610  sqliteConnector_.query("BEGIN TRANSACTION");
611  try {
613  "CREATE TABLE IF NOT EXISTS omnisci_foreign_servers("
614  "id integer primary key, "
615  "name text unique, "
616  "data_wrapper_type text, "
617  "owner_user_id integer, "
618  "options text)");
621  "CREATE TABLE IF NOT EXISTS omnisci_foreign_tables("
622  "table_id integer unique, "
623  "server_id integer, "
624  "options text, "
625  "FOREIGN KEY(table_id) REFERENCES mapd_tables(tableid), "
626  "FOREIGN KEY(server_id) REFERENCES omnisci_foreign_servers(id))");
627  } catch (std::exception& e) {
628  sqliteConnector_.query("ROLLBACK TRANSACTION");
629  throw;
630  }
631  sqliteConnector_.query("END TRANSACTION");
632 }
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
virtual void query(const std::string &queryString)
sqlite_lock< Catalog > cat_sqlite_lock
Definition: Catalog.cpp:111
void createDefaultServersIfNotExists()
Definition: Catalog.cpp:3529

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string Catalog_Namespace::Catalog::createLink ( LinkDescriptor ld,
size_t  min_length 
)

Definition at line 3232 of file Catalog.cpp.

References addLinkToMap(), calculateSHA1(), SqliteConnector::getData(), SqliteConnector::getNumRows(), LinkDescriptor::link, LinkDescriptor::linkId, SqliteConnector::query(), SqliteConnector::query_with_text_param(), SqliteConnector::query_with_text_params(), sqliteConnector_, to_string(), LinkDescriptor::updateTime, LinkDescriptor::userId, LinkDescriptor::viewMetadata, and LinkDescriptor::viewState.

3232  {
3233  cat_write_lock write_lock(this);
3234  cat_sqlite_lock sqlite_lock(this);
3235  sqliteConnector_.query("BEGIN TRANSACTION");
3236  try {
3238  .substr(0, 8);
3240  "SELECT linkid FROM mapd_links WHERE link = ? and userid = ?",
3241  std::vector<std::string>{ld.link, std::to_string(ld.userId)});
3242  if (sqliteConnector_.getNumRows() > 0) {
3244  "UPDATE mapd_links SET update_time = datetime('now') WHERE userid = ? AND link "
3245  "= ?",
3246  std::vector<std::string>{std::to_string(ld.userId), ld.link});
3247  } else {
3249  "INSERT INTO mapd_links (userid, link, view_state, view_metadata, update_time) "
3250  "VALUES (?,?,?,?, "
3251  "datetime('now'))",
3252  std::vector<std::string>{
3253  std::to_string(ld.userId), ld.link, ld.viewState, ld.viewMetadata});
3254  }
3255  // now get the auto generated dashid
3257  "SELECT linkid, strftime('%Y-%m-%dT%H:%M:%SZ', update_time) FROM mapd_links "
3258  "WHERE link = ?",
3259  ld.link);
3260  ld.linkId = sqliteConnector_.getData<int>(0, 0);
3261  ld.updateTime = sqliteConnector_.getData<std::string>(0, 1);
3262  } catch (std::exception& e) {
3263  sqliteConnector_.query("ROLLBACK TRANSACTION");
3264  throw;
3265  }
3266  sqliteConnector_.query("END TRANSACTION");
3267  addLinkToMap(ld);
3268  return ld.link;
3269 }
T getData(const int row, const int col)
virtual void query_with_text_params(std::string const &query_only)
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
virtual void query(const std::string &queryString)
std::string to_string(char const *&&v)
std::string calculateSHA1(const std::string &data)
Definition: Catalog.cpp:3220
void addLinkToMap(LinkDescriptor &ld)
Definition: Catalog.cpp:1358
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110
sqlite_lock< Catalog > cat_sqlite_lock
Definition: Catalog.cpp:111
virtual void query_with_text_param(const std::string &queryString, const std::string &text_param)
virtual size_t getNumRows() const

+ Here is the call graph for this function:

void Catalog_Namespace::Catalog::createOrUpdateDashboardSystemRole ( const std::string &  view_meta,
const int32_t &  user_id,
const std::string &  dash_role_name 
)
protected

Definition at line 1317 of file Catalog.cpp.

References Catalog_Namespace::SysCatalog::createRole(), Grantee::findDbObject(), Grantee::getDbObjects(), Catalog_Namespace::SysCatalog::getRoleGrantee(), Catalog_Namespace::SysCatalog::grantDBObjectPrivilegesBatch(), Catalog_Namespace::SysCatalog::instance(), parseDashboardObjects(), Catalog_Namespace::SysCatalog::revokeDBObjectPrivileges(), TableDBObjectType, and ViewDBObjectType.

Referenced by createDashboard(), createDashboardSystemRoles(), and replaceDashboard().

1319  {
1320  auto objects = parseDashboardObjects(view_meta, user_id);
1321  Role* rl = SysCatalog::instance().getRoleGrantee(dash_role_name);
1322  if (!rl) {
1323  // Dashboard role does not exist
1324  // create role and grant privileges
1325  // NOTE(wamsi): Transactionally unsafe
1326  SysCatalog::instance().createRole(dash_role_name, false);
1327  SysCatalog::instance().grantDBObjectPrivilegesBatch({dash_role_name}, objects, *this);
1328  } else {
1329  // Dashboard system role already exists
1330  // Add/remove privileges on objects
1331  auto ex_objects = rl->getDbObjects(true);
1332  for (auto key : *ex_objects | boost::adaptors::map_keys) {
1333  if (key.permissionType != TableDBObjectType &&
1334  key.permissionType != ViewDBObjectType) {
1335  continue;
1336  }
1337  bool found = false;
1338  for (auto obj : objects) {
1339  found = key == obj.getObjectKey() ? true : false;
1340  if (found) {
1341  break;
1342  }
1343  }
1344  if (!found) {
1345  // revoke privs on object since the object is no
1346  // longer used by the dashboard as source
1347  // NOTE(wamsi): Transactionally unsafe
1349  dash_role_name, *rl->findDbObject(key, true), *this);
1350  }
1351  }
1352  // Update privileges on remaining objects
1353  // NOTE(wamsi): Transactionally unsafe
1354  SysCatalog::instance().grantDBObjectPrivilegesBatch({dash_role_name}, objects, *this);
1355  }
1356 }
void revokeDBObjectPrivileges(const std::string &grantee, const DBObject &object, const Catalog_Namespace::Catalog &catalog)
Definition: Grantee.h:76
DBObject * findDbObject(const DBObjectKey &objectKey, bool only_direct) const
Definition: Grantee.cpp:72
void createRole(const std::string &roleName, const bool &userPrivateRole=false)
static SysCatalog & instance()
Definition: SysCatalog.h:256
Role * getRoleGrantee(const std::string &name) const
void grantDBObjectPrivilegesBatch(const std::vector< std::string > &grantees, const std::vector< DBObject > &objects, const Catalog_Namespace::Catalog &catalog)
const DBObjectMap * getDbObjects(bool only_direct) const
Definition: Grantee.h:56
std::vector< DBObject > parseDashboardObjects(const std::string &view_meta, const int &user_id)
Definition: Catalog.cpp:1287

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::createShardedTable ( TableDescriptor td,
const std::list< ColumnDescriptor > &  columns,
const std::vector< Parser::SharedDictionaryDef > &  shared_dict_defs 
)

Definition at line 2763 of file Catalog.cpp.

References CHECK(), createTable(), generatePhysicalTableName(), logicalToPhysicalTableMapById_, TableDescriptor::nShards, TableDescriptor::shard, table_is_temporary(), TableDescriptor::tableId, TableDescriptor::tableName, and updateLogicalToPhysicalTableMap().

2766  {
2767  cat_write_lock write_lock(this);
2768 
2769  /* create logical table */
2770  TableDescriptor tdl(td);
2771  createTable(tdl, cols, shared_dict_defs, true); // create logical table
2772  int32_t logical_tb_id = tdl.tableId;
2773 
2774  /* create physical tables and link them to the logical table */
2775  std::vector<int32_t> physicalTables;
2776  for (int32_t i = 1; i <= td.nShards; i++) {
2777  TableDescriptor tdp(td);
2778  tdp.tableName = generatePhysicalTableName(tdp.tableName, i);
2779  tdp.shard = i - 1;
2780  createTable(tdp, cols, shared_dict_defs, false); // create physical table
2781  int32_t physical_tb_id = tdp.tableId;
2782 
2783  /* add physical table to the vector of physical tables */
2784  physicalTables.push_back(physical_tb_id);
2785  }
2786 
2787  if (!physicalTables.empty()) {
2788  /* add logical to physical tables correspondence to the map */
2789  const auto it_ok =
2790  logicalToPhysicalTableMapById_.emplace(logical_tb_id, physicalTables);
2791  CHECK(it_ok.second);
2792  /* update sqlite mapd_logical_to_physical in sqlite database */
2793  if (!table_is_temporary(&td)) {
2794  updateLogicalToPhysicalTableMap(logical_tb_id);
2795  }
2796  }
2797 }
void createTable(TableDescriptor &td, const std::list< ColumnDescriptor > &columns, const std::vector< Parser::SharedDictionaryDef > &shared_dict_defs, bool isLogicalTable)
Definition: Catalog.cpp:2080
std::string generatePhysicalTableName(const std::string &logicalTableName, const int32_t &shardNumber)
Definition: Catalog.cpp:3407
CHECK(cgen_state)
bool table_is_temporary(const TableDescriptor *const td)
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110
specifies the content in-memory of a row in the table metadata table
LogicalToPhysicalTableMapById logicalToPhysicalTableMapById_
Definition: Catalog.h:381
void updateLogicalToPhysicalTableMap(const int32_t logical_tb_id)
Definition: Catalog.cpp:561

+ Here is the call graph for this function:

void Catalog_Namespace::Catalog::createTable ( TableDescriptor td,
const std::list< ColumnDescriptor > &  columns,
const std::vector< Parser::SharedDictionaryDef > &  shared_dict_defs,
bool  isLogicalTable 
)

Definition at line 2080 of file Catalog.cpp.

References addTableToMap(), calciteMgr_, ColumnDescriptor::columnId, TableDescriptor::columnIdBySpi_, ColumnDescriptor::columnName, ColumnDescriptor::columnType, currentDB_, Catalog_Namespace::DBMetadata::dbId, Catalog_Namespace::DBMetadata::dbName, dict_ref_t::dictId, Data_Namespace::DISK_LEVEL, expandGeoColumn(), StorageType::FOREIGN_TABLE, TableDescriptor::fragPageSize, TableDescriptor::fragType, g_enable_fsi, g_serialize_temp_tables, g_test_against_columnId_gap, SQLTypeInfo::get_comp_param(), SQLTypeInfo::get_compression(), SQLTypeInfo::get_dimension(), SQLTypeInfo::get_notnull(), SQLTypeInfo::get_scale(), SQLTypeInfo::get_size(), SQLTypeInfo::get_subtype(), SQLTypeInfo::get_type(), getCurrentDB(), SqliteConnector::getData(), TableDescriptor::hasDeletedCol, SQLTypeInfo::is_array(), IS_GEO, ColumnDescriptor::isDeletedCol, ColumnDescriptor::isGeoPhyCol, ColumnDescriptor::isSystemCol, TableDescriptor::isView, ColumnDescriptor::isVirtualCol, kBIGINT, kBOOLEAN, kENCODING_DICT, TableDescriptor::keyMetainfo, TableDescriptor::maxChunkSize, TableDescriptor::maxFragRows, TableDescriptor::maxRows, TableDescriptor::nColumns, nextTempDictId_, nextTempTableId_, TableDescriptor::nShards, TableDescriptor::partitions, TableDescriptor::persistenceLevel, ForeignStorageInterface::prepareTable(), SqliteConnector::query(), SqliteConnector::query_with_text_param(), SqliteConnector::query_with_text_params(), ForeignStorageInterface::registerTable(), removeTableFromMap(), serializeTableJsonUnlocked(), SQLTypeInfo::set_comp_param(), SQLTypeInfo::set_size(), setColumnDictionary(), setColumnSharedDictionary(), TableDescriptor::shard, TableDescriptor::shardedColumnId, TableDescriptor::sortedColumnId, sqliteConnector_, TableDescriptor::storageType, ColumnDescriptor::tableId, TableDescriptor::tableId, TableDescriptor::tableName, to_string(), TableDescriptor::userId, TableDescriptor::viewSQL, and ColumnDescriptor::virtualExpr.

Referenced by createShardedTable().

2084  {
2085  cat_write_lock write_lock(this);
2086  list<ColumnDescriptor> cds = cols;
2087  list<DictDescriptor> dds;
2088  std::set<std::string> toplevel_column_names;
2089  list<ColumnDescriptor> columns;
2090 
2091  if (!td.storageType.empty() &&
2094  throw std::runtime_error("Only temporary tables can be backed by foreign storage.");
2095  }
2097  }
2098 
2099  for (auto cd : cds) {
2100  if (cd.columnName == "rowid") {
2101  throw std::runtime_error(
2102  "Cannot create column with name rowid. rowid is a system defined column.");
2103  }
2104  columns.push_back(cd);
2105  toplevel_column_names.insert(cd.columnName);
2106  if (cd.columnType.is_geometry()) {
2107  expandGeoColumn(cd, columns);
2108  }
2109  }
2110  cds.clear();
2111 
2112  ColumnDescriptor cd;
2113  // add row_id column -- Must be last column in the table
2114  cd.columnName = "rowid";
2115  cd.isSystemCol = true;
2116  cd.columnType = SQLTypeInfo(kBIGINT, true);
2117 #ifdef MATERIALIZED_ROWID
2118  cd.isVirtualCol = false;
2119 #else
2120  cd.isVirtualCol = true;
2121  cd.virtualExpr = "MAPD_FRAG_ID * MAPD_ROWS_PER_FRAG + MAPD_FRAG_ROW_ID";
2122 #endif
2123  columns.push_back(cd);
2124  toplevel_column_names.insert(cd.columnName);
2125 
2126  if (td.hasDeletedCol) {
2127  ColumnDescriptor cd_del;
2128  cd_del.columnName = "$deleted$";
2129  cd_del.isSystemCol = true;
2130  cd_del.isVirtualCol = false;
2131  cd_del.columnType = SQLTypeInfo(kBOOLEAN, true);
2132  cd_del.isDeletedCol = true;
2133 
2134  columns.push_back(cd_del);
2135  }
2136 
2137  td.nColumns = columns.size();
2138  cat_sqlite_lock sqlite_lock(this);
2139  sqliteConnector_.query("BEGIN TRANSACTION");
2141  try {
2143  R"(INSERT INTO mapd_tables (name, userid, ncolumns, isview, fragments, frag_type, max_frag_rows, max_chunk_size, frag_page_size, max_rows, partitions, shard_column_id, shard, num_shards, sort_column_id, storage_type, key_metainfo) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?))",
2144  std::vector<std::string>{td.tableName,
2145  std::to_string(td.userId),
2147  std::to_string(td.isView),
2148  "",
2153  std::to_string(td.maxRows),
2154  td.partitions,
2156  std::to_string(td.shard),
2157  std::to_string(td.nShards),
2159  td.storageType,
2160  td.keyMetainfo});
2161 
2162  // now get the auto generated tableid
2164  "SELECT tableid FROM mapd_tables WHERE name = ?", td.tableName);
2165  td.tableId = sqliteConnector_.getData<int>(0, 0);
2166  int colId = 1;
2167  for (auto cd : columns) {
2169  const bool is_foreign_col =
2170  setColumnSharedDictionary(cd, cds, dds, td, shared_dict_defs);
2171  if (!is_foreign_col) {
2172  setColumnDictionary(cd, dds, td, isLogicalTable);
2173  }
2174  }
2175 
2176  if (toplevel_column_names.count(cd.columnName)) {
2177  // make up colId gap for sanity test (begin with 1 bc much code depends on it!)
2178  if (colId > 1) {
2179  colId += g_test_against_columnId_gap;
2180  }
2181  if (!cd.isGeoPhyCol) {
2182  td.columnIdBySpi_.push_back(colId);
2183  }
2184  }
2185 
2187  "INSERT INTO mapd_columns (tableid, columnid, name, coltype, colsubtype, "
2188  "coldim, colscale, is_notnull, "
2189  "compression, comp_param, size, chunks, is_systemcol, is_virtualcol, "
2190  "virtual_expr, is_deletedcol) "
2191  "VALUES (?, ?, ?, ?, ?, "
2192  "?, "
2193  "?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
2194  std::vector<std::string>{std::to_string(td.tableId),
2195  std::to_string(colId),
2196  cd.columnName,
2205  "",
2208  cd.virtualExpr,
2210  cd.tableId = td.tableId;
2211  cd.columnId = colId++;
2212  cds.push_back(cd);
2213  }
2214  if (td.isView) {
2216  "INSERT INTO mapd_views (tableid, sql) VALUES (?,?)",
2217  std::vector<std::string>{std::to_string(td.tableId), td.viewSQL});
2218  }
2220  auto& foreignTable = dynamic_cast<foreign_storage::ForeignTable&>(td);
2222  "INSERT INTO omnisci_foreign_tables (table_id, server_id, options) VALUES "
2223  "(?, ?, ?)",
2224  std::vector<std::string>{std::to_string(foreignTable.tableId),
2225  std::to_string(foreignTable.foreign_server->id),
2226  foreignTable.getOptionsAsJsonString()});
2227  }
2228  } catch (std::exception& e) {
2229  sqliteConnector_.query("ROLLBACK TRANSACTION");
2230  throw;
2231  }
2232  } else { // Temporary table
2233  td.tableId = nextTempTableId_++;
2234  int colId = 1;
2235  for (auto cd : columns) {
2236  auto col_ti = cd.columnType;
2237  if (IS_GEO(col_ti.get_type())) {
2238  throw runtime_error("Geometry types in temporary tables are not supported.");
2239  }
2240 
2242  const bool is_foreign_col =
2243  setColumnSharedDictionary(cd, cds, dds, td, shared_dict_defs);
2244 
2245  if (!is_foreign_col) {
2246  // Create a new temporary dictionary
2247  std::string fileName("");
2248  std::string folderPath("");
2250  nextTempDictId_++;
2251  DictDescriptor dd(dict_ref,
2252  fileName,
2254  false,
2255  1,
2256  folderPath,
2257  true); // Is dictName (2nd argument) used?
2258  dds.push_back(dd);
2259  if (!cd.columnType.is_array()) {
2261  }
2262  cd.columnType.set_comp_param(dict_ref.dictId);
2263  }
2264  }
2265  cd.tableId = td.tableId;
2266  cd.columnId = colId++;
2267  td.columnIdBySpi_.push_back(cd.columnId);
2268  cds.push_back(cd);
2269  }
2270 
2272  serializeTableJsonUnlocked(&td, cds);
2273  }
2274  }
2275 
2276  try {
2277  addTableToMap(&td, cds, dds);
2278  calciteMgr_->updateMetadata(currentDB_.dbName, td.tableName);
2279  if (!td.storageType.empty() && td.storageType != StorageType::FOREIGN_TABLE) {
2281  }
2282  } catch (std::exception& e) {
2283  sqliteConnector_.query("ROLLBACK TRANSACTION");
2284  removeTableFromMap(td.tableName, td.tableId, true);
2285  throw;
2286  }
2287  sqliteConnector_.query("END TRANSACTION");
2288 }
void serializeTableJsonUnlocked(const TableDescriptor *td, const std::list< ColumnDescriptor > &cds) const
Definition: Catalog.cpp:2290
std::string virtualExpr
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:249
void set_size(int s)
Definition: sqltypes.h:346
std::string partitions
HOST DEVICE int get_size() const
Definition: sqltypes.h:258
T getData(const int row, const int col)
std::string tableName
virtual void query_with_text_params(std::string const &query_only)
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
HOST DEVICE int get_scale() const
Definition: sqltypes.h:253
std::string storageType
virtual void query(const std::string &queryString)
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:248
std::vector< int > columnIdBySpi_
std::string to_string(char const *&&v)
void addTableToMap(const TableDescriptor *td, const std::list< ColumnDescriptor > &columns, const std::list< DictDescriptor > &dicts)
Definition: Catalog.cpp:1134
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:182
specifies the content in-memory of a row in the column metadata table
static void registerTable(Catalog_Namespace::Catalog *catalog, const TableDescriptor &td, const std::list< ColumnDescriptor > &cols)
ids are created
static void expandGeoColumn(const ColumnDescriptor &cd, std::list< ColumnDescriptor > &columns)
Definition: Catalog.cpp:1950
std::string keyMetainfo
int g_test_against_columnId_gap
Definition: Catalog.cpp:88
bool g_serialize_temp_tables
Definition: Catalog.cpp:94
void set_comp_param(int p)
Definition: sqltypes.h:349
std::shared_ptr< Calcite > calciteMgr_
Definition: Catalog.h:379
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:256
Fragmenter_Namespace::FragmenterType fragType
Data_Namespace::MemoryLevel persistenceLevel
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:250
void removeTableFromMap(const std::string &tableName, const int tableId, const bool is_on_error=false)
Definition: Catalog.cpp:1194
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:257
bool setColumnSharedDictionary(ColumnDescriptor &cd, std::list< ColumnDescriptor > &cdd, std::list< DictDescriptor > &dds, const TableDescriptor td, const std::vector< Parser::SharedDictionaryDef > &shared_dict_defs)
Definition: Catalog.cpp:2653
Descriptor for a dictionary for a string columne.
std::string viewSQL
SQLTypeInfo columnType
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:255
sqlite_lock< Catalog > cat_sqlite_lock
Definition: Catalog.cpp:111
void setColumnDictionary(ColumnDescriptor &cd, std::list< DictDescriptor > &dds, const TableDescriptor &td, const bool isLogicalTable)
Definition: Catalog.cpp:2722
static constexpr char const * FOREIGN_TABLE
bool g_enable_fsi
Definition: Catalog.cpp:89
std::string columnName
virtual void query_with_text_param(const std::string &queryString, const std::string &text_param)
#define IS_GEO(T)
Definition: sqltypes.h:163
bool is_array() const
Definition: sqltypes.h:407
static void prepareTable(const int db_id, TableDescriptor &td, std::list< ColumnDescriptor > &cols)
prepare table options and modify columns

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::delDictionary ( const ColumnDescriptor cd)

Definition at line 1733 of file Catalog.cpp.

References basePath_, CHECK(), CHECK_GT, ColumnDescriptor::columnType, currentDB_, Catalog_Namespace::DBMetadata::dbId, dictDescriptorMapByRef_, SQLTypeInfo::get_comp_param(), SQLTypeInfo::get_compression(), SqliteConnector::getData(), getMetadataForTable(), SQLTypeInfo::is_string(), SQLTypeInfo::is_string_array(), kENCODING_DICT, SqliteConnector::query_with_text_param(), File_Namespace::renameForDelete(), sqliteConnector_, string_dict_hosts_, ColumnDescriptor::tableId, to_string(), and VLOG.

Referenced by roll().

1733  {
1734  cat_write_lock write_lock(this);
1735  cat_sqlite_lock sqlite_lock(this);
1736  if (!(cd.columnType.is_string() || cd.columnType.is_string_array())) {
1737  return;
1738  }
1739  if (!(cd.columnType.get_compression() == kENCODING_DICT)) {
1740  return;
1741  }
1742  const auto dictId = cd.columnType.get_comp_param();
1743  CHECK_GT(dictId, 0);
1744  // decrement and zero check dict ref count
1745  const auto td = getMetadataForTable(cd.tableId);
1746  CHECK(td);
1748  "UPDATE mapd_dictionaries SET refcount = refcount - 1 WHERE dictid = ?",
1749  std::to_string(dictId));
1751  "SELECT refcount FROM mapd_dictionaries WHERE dictid = ?", std::to_string(dictId));
1752  const auto refcount = sqliteConnector_.getData<int>(0, 0);
1753  VLOG(3) << "Dictionary " << dictId << "from dropped table has reference count "
1754  << refcount;
1755  if (refcount > 0) {
1756  return;
1757  }
1758  const DictRef dictRef(currentDB_.dbId, dictId);
1759  sqliteConnector_.query_with_text_param("DELETE FROM mapd_dictionaries WHERE dictid = ?",
1760  std::to_string(dictId));
1761  File_Namespace::renameForDelete(basePath_ + "/mapd_data/DB_" +
1762  std::to_string(currentDB_.dbId) + "_DICT_" +
1763  std::to_string(dictId));
1764 
1765  std::unique_ptr<StringDictionaryClient> client;
1766  if (!string_dict_hosts_.empty()) {
1767  client.reset(new StringDictionaryClient(string_dict_hosts_.front(), dictRef, true));
1768  }
1769  if (client) {
1770  client->drop(dictRef);
1771  }
1772 
1773  dictDescriptorMapByRef_.erase(dictRef);
1774 }
T getData(const int row, const int col)
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
const std::vector< LeafHostInfo > string_dict_hosts_
Definition: Catalog.h:378
DictDescriptorMapById dictDescriptorMapByRef_
Definition: Catalog.h:367
#define CHECK_GT(x, y)
Definition: Logger.h:209
std::string to_string(char const *&&v)
CHECK(cgen_state)
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:256
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:257
SQLTypeInfo columnType
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
bool is_string() const
Definition: sqltypes.h:399
void renameForDelete(const std::string directoryName)
Renames a directory to DELETE_ME_&lt;EPOCH&gt;_&lt;oldname&gt;.
Definition: File.cpp:182
sqlite_lock< Catalog > cat_sqlite_lock
Definition: Catalog.cpp:111
bool is_string_array() const
Definition: sqltypes.h:400
virtual void query_with_text_param(const std::string &queryString, const std::string &text_param)
#define VLOG(n)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::deleteMetadataForDashboard ( const std::string &  userId,
const std::string &  dashName 
)

Definition at line 1541 of file Catalog.cpp.

References dashboardDescriptorMap_, logger::ERROR, LOG, SqliteConnector::query(), SqliteConnector::query_with_text_params(), and sqliteConnector_.

Referenced by deleteMetadataForDashboard().

1542  {
1543  cat_write_lock write_lock(this);
1544 
1545  auto viewDescIt = dashboardDescriptorMap_.find(userId + ":" + dashName);
1546  if (viewDescIt == dashboardDescriptorMap_.end()) { // check to make sure view exists
1547  LOG(ERROR) << "No metadata for dashboard for user " << userId << " dashboard "
1548  << dashName << " does not exist in map";
1549  throw runtime_error("No metadata for dashboard for user " + userId + " dashboard " +
1550  dashName + " does not exist in map");
1551  }
1552  // found view in Map now remove it
1553  dashboardDescriptorMap_.erase(viewDescIt);
1554  // remove from DB
1555  cat_sqlite_lock sqlite_lock(this);
1556  sqliteConnector_.query("BEGIN TRANSACTION");
1557  try {
1559  "DELETE FROM mapd_dashboards WHERE name = ? and userid = ?",
1560  std::vector<std::string>{dashName, userId});
1561  } catch (std::exception& e) {
1562  sqliteConnector_.query("ROLLBACK TRANSACTION");
1563  throw;
1564  }
1565  sqliteConnector_.query("END TRANSACTION");
1566 }
virtual void query_with_text_params(std::string const &query_only)
#define LOG(tag)
Definition: Logger.h:188
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
virtual void query(const std::string &queryString)
DashboardDescriptorMap dashboardDescriptorMap_
Definition: Catalog.h:368
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110
sqlite_lock< Catalog > cat_sqlite_lock
Definition: Catalog.cpp:111

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::deleteMetadataForDashboard ( const int32_t  dashboard_id)

Definition at line 1602 of file Catalog.cpp.

References DashboardDBObjectType, dashboardDescriptorMap_, deleteMetadataForDashboard(), Catalog_Namespace::SysCatalog::instance(), name(), Catalog_Namespace::SysCatalog::revokeDBObjectPrivilegesFromAll(), and to_string().

1602  {
1603  std::string userId;
1604  std::string name;
1605  bool found{false};
1606  {
1607  cat_read_lock read_lock(this);
1608  for (auto descp : dashboardDescriptorMap_) {
1609  auto dash = descp.second.get();
1610  if (dash->dashboardId == id) {
1611  userId = std::to_string(dash->userId);
1612  name = dash->dashboardName;
1613  found = true;
1614  break;
1615  }
1616  }
1617  }
1618  if (found) {
1619  // TODO: transactionally unsafe
1621  DBObject(id, DashboardDBObjectType), this);
1622  deleteMetadataForDashboard(userId, name);
1623  }
1624 }
void revokeDBObjectPrivilegesFromAll(DBObject object, Catalog *catalog)
read_lock< Catalog > cat_read_lock
Definition: Catalog.cpp:109
void deleteMetadataForDashboard(const std::string &userId, const std::string &dashName)
Definition: Catalog.cpp:1541
DashboardDescriptorMap dashboardDescriptorMap_
Definition: Catalog.h:368
std::string to_string(char const *&&v)
std::string name() const
Definition: Catalog.h:236
static SysCatalog & instance()
Definition: SysCatalog.h:256

+ Here is the call graph for this function:

void Catalog_Namespace::Catalog::doDropTable ( const TableDescriptor td)
protected

Definition at line 2939 of file Catalog.cpp.

References dropTableFromJsonUnlocked(), eraseTablePhysicalData(), executeDropTableSqliteQueries(), g_serialize_temp_tables, table_is_temporary(), and TableDescriptor::tableName.

Referenced by dropTable().

2939  {
2943  }
2945 }
void executeDropTableSqliteQueries(const TableDescriptor *td)
Definition: Catalog.cpp:2947
void eraseTablePhysicalData(const TableDescriptor *td)
Definition: Catalog.cpp:3377
std::string tableName
void dropTableFromJsonUnlocked(const std::string &table_name) const
Definition: Catalog.cpp:2352
bool g_serialize_temp_tables
Definition: Catalog.cpp:94
bool table_is_temporary(const TableDescriptor *const td)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::doTruncateTable ( const TableDescriptor td)
protected

Definition at line 2817 of file Catalog.cpp.

References CHECK(), CHECK_GE, ColumnDescriptor::columnType, Data_Namespace::CPU_LEVEL, currentDB_, dataMgr_, Catalog_Namespace::DBMetadata::dbId, dictDescriptorMapByRef_, dict_ref_t::dictId, DictDescriptor::dictIsTemp, DictDescriptor::dictRef, TableDescriptor::fragmenter, SQLTypeInfo::get_comp_param(), SQLTypeInfo::get_compression(), getMetadataForDict(), Data_Namespace::GPU_LEVEL, Catalog_Namespace::SysCatalog::instance(), kENCODING_DICT, File_Namespace::renameForDelete(), string_dict_hosts_, tableDescriptorMapById_, ColumnDescriptor::tableId, and TableDescriptor::tableId.

Referenced by truncateTable().

2817  {
2818  cat_write_lock write_lock(this);
2819 
2820  const int tableId = td->tableId;
2821  // must destroy fragmenter before deleteChunks is called.
2822  if (td->fragmenter != nullptr) {
2823  auto tableDescIt = tableDescriptorMapById_.find(tableId);
2824  delete td->fragmenter;
2825  tableDescIt->second->fragmenter = nullptr; // get around const-ness
2826  }
2827  ChunkKey chunkKeyPrefix = {currentDB_.dbId, tableId};
2828  // assuming deleteChunksWithPrefix is atomic
2829  dataMgr_->deleteChunksWithPrefix(chunkKeyPrefix, MemoryLevel::CPU_LEVEL);
2830  dataMgr_->deleteChunksWithPrefix(chunkKeyPrefix, MemoryLevel::GPU_LEVEL);
2831 
2832  dataMgr_->removeTableRelatedDS(currentDB_.dbId, tableId);
2833 
2834  std::unique_ptr<StringDictionaryClient> client;
2835  if (SysCatalog::instance().isAggregator()) {
2836  CHECK(!string_dict_hosts_.empty());
2837  DictRef dict_ref(currentDB_.dbId, -1);
2838  client.reset(new StringDictionaryClient(string_dict_hosts_.front(), dict_ref, true));
2839  }
2840  // clean up any dictionaries
2841  // delete all column descriptors for the table
2842  for (const auto& columnDescriptor : columnDescriptorMapById_) {
2843  auto cd = columnDescriptor.second;
2844  if (cd->tableId != td->tableId) {
2845  continue;
2846  }
2847  const int dict_id = cd->columnType.get_comp_param();
2848  // Dummy dictionaries created for a shard of a logical table have the id set to zero.
2849  if (cd->columnType.get_compression() == kENCODING_DICT && dict_id) {
2850  const DictRef dict_ref(currentDB_.dbId, dict_id);
2851  const auto dictIt = dictDescriptorMapByRef_.find(dict_ref);
2852  CHECK(dictIt != dictDescriptorMapByRef_.end());
2853  const auto& dd = dictIt->second;
2854  CHECK_GE(dd->refcount, 1);
2855  // if this is the only table using this dict reset the dict
2856  if (dd->refcount == 1) {
2857  // close the dictionary
2858  dd->stringDict.reset();
2859  File_Namespace::renameForDelete(dd->dictFolderPath);
2860  if (client) {
2861  client->drop(dd->dictRef);
2862  }
2863  if (!dd->dictIsTemp) {
2864  boost::filesystem::create_directory(dd->dictFolderPath);
2865  }
2866  }
2867 
2868  DictDescriptor* new_dd = new DictDescriptor(dd->dictRef,
2869  dd->dictName,
2870  dd->dictNBits,
2871  dd->dictIsShared,
2872  dd->refcount,
2873  dd->dictFolderPath,
2874  dd->dictIsTemp);
2875  dictDescriptorMapByRef_.erase(dictIt);
2876  // now create new Dict -- need to figure out what to do here for temp tables
2877  if (client) {
2878  client->create(new_dd->dictRef, new_dd->dictIsTemp);
2879  }
2880  dictDescriptorMapByRef_[new_dd->dictRef].reset(new_dd);
2882  }
2883  }
2884 }
std::vector< int > ChunkKey
Definition: types.h:35
const std::vector< LeafHostInfo > string_dict_hosts_
Definition: Catalog.h:378
DictDescriptorMapById dictDescriptorMapByRef_
Definition: Catalog.h:367
std::shared_ptr< Data_Namespace::DataMgr > dataMgr_
Definition: Catalog.h:376
#define CHECK_GE(x, y)
Definition: Logger.h:210
ColumnDescriptorMapById columnDescriptorMapById_
Definition: Catalog.h:366
static SysCatalog & instance()
Definition: SysCatalog.h:256
CHECK(cgen_state)
TableDescriptorMapById tableDescriptorMapById_
Definition: Catalog.h:364
const DictDescriptor * getMetadataForDict(int dict_ref, bool loadDict=true) const
Definition: Catalog.cpp:1444
int32_t dictId
Definition: DictRef.h:10
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110
Descriptor for a dictionary for a string columne.
void renameForDelete(const std::string directoryName)
Renames a directory to DELETE_ME_&lt;EPOCH&gt;_&lt;oldname&gt;.
Definition: File.cpp:182
Fragmenter_Namespace::AbstractFragmenter * fragmenter

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::dropColumn ( const TableDescriptor td,
const ColumnDescriptor cd 
)

Definition at line 1861 of file Catalog.cpp.

References CHECK(), columnDescriptorMap_, columnDescriptorsForRoll, ColumnDescriptor::columnId, ColumnDescriptor::columnName, getMetadataForColumn(), getPhysicalTablesDescriptors(), TableDescriptor::nShards, SqliteConnector::query_with_text_params(), TableDescriptor::shard, sqliteConnector_, tableDescriptorMapById_, ColumnDescriptor::tableId, TableDescriptor::tableId, to_string(), and to_upper().

1861  {
1862  cat_write_lock write_lock(this);
1863  cat_sqlite_lock sqlite_lock(this);
1864  // caller must handle sqlite/chunk transaction TOGETHER
1866  "DELETE FROM mapd_columns where tableid = ? and columnid = ?",
1867  std::vector<std::string>{std::to_string(td.tableId), std::to_string(cd.columnId)});
1868 
1870  "UPDATE mapd_tables SET ncolumns = ncolumns - 1 WHERE tableid = ?",
1871  std::vector<std::string>{std::to_string(td.tableId)});
1872 
1873  ColumnDescriptorMap::iterator columnDescIt =
1875  CHECK(columnDescIt != columnDescriptorMap_.end());
1876 
1877  columnDescriptorsForRoll.emplace_back(columnDescIt->second, nullptr);
1878 
1879  columnDescriptorMap_.erase(columnDescIt);
1881  --tableDescriptorMapById_[td.tableId]->nColumns;
1882  // for each shard
1883  if (td.nShards > 0 && td.shard < 0) {
1884  for (const auto shard : getPhysicalTablesDescriptors(&td)) {
1885  const auto shard_cd = getMetadataForColumn(shard->tableId, cd.columnId);
1886  CHECK(shard_cd);
1887  dropColumn(*shard, *shard_cd);
1888  }
1889  }
1890 }
std::tuple< int, std::string > ColumnKey
Definition: Types.h:36
ColumnDescriptorMap columnDescriptorMap_
Definition: Catalog.h:365
virtual void query_with_text_params(std::string const &query_only)
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
std::vector< const TableDescriptor * > getPhysicalTablesDescriptors(const TableDescriptor *logicalTableDesc) const
Definition: Catalog.cpp:3287
void dropColumn(const TableDescriptor &td, const ColumnDescriptor &cd)
Definition: Catalog.cpp:1861
ColumnDescriptorMapById columnDescriptorMapById_
Definition: Catalog.h:366
std::string to_string(char const *&&v)
CHECK(cgen_state)
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
TableDescriptorMapById tableDescriptorMapById_
Definition: Catalog.h:364
std::string to_upper(const std::string &str)
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110
sqlite_lock< Catalog > cat_sqlite_lock
Definition: Catalog.cpp:111
ColumnDescriptorsForRoll columnDescriptorsForRoll
Definition: Catalog.h:393
std::string columnName
std::tuple< int, int > ColumnIdKey
Definition: Types.h:38

+ Here is the call graph for this function:

void Catalog_Namespace::Catalog::dropForeignServer ( const std::string &  server_name)

Drops/deletes a foreign server DB object.

Parameters
server_name- Name of foreign server that will be deleted

Definition at line 2457 of file Catalog.cpp.

References CHECK_EQ, foreignServerMap_, foreignServerMapById_, SqliteConnector::getData(), SqliteConnector::getNumRows(), num_rows, SqliteConnector::query_with_text_param(), SqliteConnector::query_with_text_params(), sqliteConnector_, and to_string().

2457  {
2458  cat_write_lock write_lock(this);
2459  cat_sqlite_lock sqlite_lock(this);
2460 
2462  "SELECT id from omnisci_foreign_servers where name = ?",
2463  std::vector<std::string>{server_name});
2465  if (num_rows > 0) {
2466  CHECK_EQ(size_t(1), num_rows);
2467  auto server_id = sqliteConnector_.getData<int>(0, 0);
2469  "SELECT table_id from omnisci_foreign_tables where server_id = ?",
2470  std::to_string(server_id));
2471  if (sqliteConnector_.getNumRows() > 0) {
2472  throw std::runtime_error{"Foreign server \"" + server_name +
2473  "\" is referenced "
2474  "by existing foreign tables and cannot be dropped."};
2475  }
2477  "DELETE FROM omnisci_foreign_servers WHERE name = ?",
2478  std::vector<std::string>{server_name});
2479  foreignServerMap_.erase(server_name);
2480  foreignServerMapById_.erase(server_id);
2481  }
2482 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
T getData(const int row, const int col)
const int8_t const int64_t * num_rows
virtual void query_with_text_params(std::string const &query_only)
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
std::string to_string(char const *&&v)
ForeignServerMapById foreignServerMapById_
Definition: Catalog.h:372
ForeignServerMap foreignServerMap_
Definition: Catalog.h:371
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110
sqlite_lock< Catalog > cat_sqlite_lock
Definition: Catalog.cpp:111
virtual void query_with_text_param(const std::string &queryString, const std::string &text_param)
virtual size_t getNumRows() const

+ Here is the call graph for this function:

void Catalog_Namespace::Catalog::dropFsiSchemasAndTables ( )
protected

Definition at line 634 of file Catalog.cpp.

References CHECK_EQ, executeDropTableSqliteQueries(), SqliteConnector::getData(), SqliteConnector::getNumRows(), Catalog_Namespace::SysCatalog::instance(), num_rows, SqliteConnector::query(), Catalog_Namespace::SysCatalog::revokeDBObjectPrivilegesFromAll(), sqliteConnector_, TableDBObjectType, tableDescriptorMap_, tableDescriptorMapById_, TableDescriptor::tableId, and to_upper().

Referenced by CheckAndExecuteMigrations().

634  {
635  std::vector<foreign_storage::ForeignTable> foreign_tables{};
636  {
637  cat_sqlite_lock sqlite_lock(this);
638  sqliteConnector_.query("BEGIN TRANSACTION");
639  try {
641  "SELECT name FROM sqlite_master WHERE type='table' AND "
642  "name IN ('omnisci_foreign_servers', 'omnisci_foreign_tables')");
643  if (sqliteConnector_.getNumRows() > 0) {
645  "SELECT tableid, name, isview, storage_type FROM mapd_tables "
646  "WHERE storage_type = 'FOREIGN_TABLE'");
648  for (size_t r = 0; r < num_rows; r++) {
649  foreign_storage::ForeignTable foreign_table{};
650  foreign_table.tableId = sqliteConnector_.getData<int>(r, 0);
651  foreign_table.tableName = sqliteConnector_.getData<std::string>(r, 1);
652  foreign_table.isView = sqliteConnector_.getData<bool>(r, 2);
653  foreign_table.storageType = sqliteConnector_.getData<std::string>(r, 3);
654  foreign_tables.emplace_back(foreign_table);
655  }
656  for (auto& foreign_table : foreign_tables) {
657  tableDescriptorMap_[to_upper(foreign_table.tableName)] = &foreign_table;
658  tableDescriptorMapById_[foreign_table.tableId] = &foreign_table;
659  executeDropTableSqliteQueries(&foreign_table);
660  }
661  sqliteConnector_.query("SELECT COUNT(*) FROM omnisci_foreign_tables");
662  CHECK_EQ(size_t(1), sqliteConnector_.getNumRows());
663  CHECK_EQ(0, sqliteConnector_.getData<int>(0, 0));
664 
665  sqliteConnector_.query("DROP TABLE omnisci_foreign_tables");
666  sqliteConnector_.query("DROP TABLE omnisci_foreign_servers");
667  }
668  } catch (std::exception& e) {
669  sqliteConnector_.query("ROLLBACK TRANSACTION");
670  throw;
671  }
672  sqliteConnector_.query("END TRANSACTION");
673  }
674 
675  for (auto& foreign_table : foreign_tables) {
677  DBObject(foreign_table.tableName, TableDBObjectType), this);
678  tableDescriptorMap_.erase(to_upper(foreign_table.tableName));
679  tableDescriptorMapById_.erase(foreign_table.tableId);
680  }
681 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
void executeDropTableSqliteQueries(const TableDescriptor *td)
Definition: Catalog.cpp:2947
T getData(const int row, const int col)
const int8_t const int64_t * num_rows
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
void revokeDBObjectPrivilegesFromAll(DBObject object, Catalog *catalog)
virtual void query(const std::string &queryString)
static SysCatalog & instance()
Definition: SysCatalog.h:256
TableDescriptorMapById tableDescriptorMapById_
Definition: Catalog.h:364
std::string to_upper(const std::string &str)
sqlite_lock< Catalog > cat_sqlite_lock
Definition: Catalog.cpp:111
virtual size_t getNumRows() const
TableDescriptorMap tableDescriptorMap_
Definition: Catalog.h:363

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::dropTable ( const TableDescriptor td)

Definition at line 2906 of file Catalog.cpp.

References CHECK(), doDropTable(), getMetadataForTable(), Catalog_Namespace::SysCatalog::instance(), TableDescriptor::isView, logicalToPhysicalTableMapById_, SqliteConnector::query(), SqliteConnector::query_with_text_param(), Catalog_Namespace::SysCatalog::revokeDBObjectPrivilegesFromAll(), sqliteConnector_, TableDBObjectType, TableDescriptor::tableId, TableDescriptor::tableName, to_string(), and ViewDBObjectType.

2906  {
2909  cat_write_lock write_lock(this);
2910  cat_sqlite_lock sqlite_lock(this);
2911  const auto physicalTableIt = logicalToPhysicalTableMapById_.find(td->tableId);
2912  sqliteConnector_.query("BEGIN TRANSACTION");
2913  try {
2914  if (physicalTableIt != logicalToPhysicalTableMapById_.end()) {
2915  // remove all corresponding physical tables if this is a logical table
2916  const auto physicalTables = physicalTableIt->second;
2917  CHECK(!physicalTables.empty());
2918  for (size_t i = 0; i < physicalTables.size(); i++) {
2919  int32_t physical_tb_id = physicalTables[i];
2920  const TableDescriptor* phys_td = getMetadataForTable(physical_tb_id);
2921  CHECK(phys_td);
2922  doDropTable(phys_td);
2923  }
2924 
2925  // remove corresponding record from the logicalToPhysicalTableMap in sqlite database
2927  "DELETE FROM mapd_logical_to_physical WHERE logical_table_id = ?",
2928  std::to_string(td->tableId));
2930  }
2931  doDropTable(td);
2932  } catch (std::exception& e) {
2933  sqliteConnector_.query("ROLLBACK TRANSACTION");
2934  throw;
2935  }
2936  sqliteConnector_.query("END TRANSACTION");
2937 }
void doDropTable(const TableDescriptor *td)
Definition: Catalog.cpp:2939
std::string tableName
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
void revokeDBObjectPrivilegesFromAll(DBObject object, Catalog *catalog)
virtual void query(const std::string &queryString)
std::string to_string(char const *&&v)
static SysCatalog & instance()
Definition: SysCatalog.h:256
CHECK(cgen_state)
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
specifies the content in-memory of a row in the table metadata table
sqlite_lock< Catalog > cat_sqlite_lock
Definition: Catalog.cpp:111
virtual void query_with_text_param(const std::string &queryString, const std::string &text_param)
LogicalToPhysicalTableMapById logicalToPhysicalTableMapById_
Definition: Catalog.h:381

+ Here is the call graph for this function:

void Catalog_Namespace::Catalog::dropTableFromJsonUnlocked ( const std::string &  table_name) const
protected

Definition at line 2352 of file Catalog.cpp.

References basePath_, CHECK(), currentDB_, Catalog_Namespace::DBMetadata::dbName, Catalog_Namespace::anonymous_namespace{Catalog.cpp}::table_json_filepath(), and VLOG.

Referenced by doDropTable().

2352  {
2353  // relies on the catalog write lock
2354  using namespace rapidjson;
2355 
2356  VLOG(1) << "Dropping temporary table " << table_name << " to JSON for Calcite.";
2357 
2358  const auto db_name = currentDB_.dbName;
2359  const auto file_path = table_json_filepath(basePath_, db_name);
2360 
2361  CHECK(boost::filesystem::exists(file_path));
2362  Document d;
2363 
2364  std::ifstream reader(file_path.string());
2365  CHECK(reader.is_open());
2366  IStreamWrapper json_read_wrapper(reader);
2367  d.ParseStream(json_read_wrapper);
2368 
2369  CHECK(d.IsObject());
2370  auto table_name_ref = StringRef(table_name.c_str());
2371  CHECK(d.HasMember(table_name_ref));
2372  CHECK(d.RemoveMember(table_name_ref));
2373 
2374  // Overwrite the existing file
2375  std::ofstream writer(file_path.string(), writer.trunc | writer.out);
2376  CHECK(writer.is_open());
2377  OStreamWrapper json_wrapper(writer);
2378 
2379  Writer<OStreamWrapper> json_writer(json_wrapper);
2380  d.Accept(json_writer);
2381  writer.close();
2382 }
auto table_json_filepath(const std::string &base_path, const std::string &db_name)
Definition: Catalog.cpp:150
CHECK(cgen_state)
#define VLOG(n)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string Catalog_Namespace::Catalog::dumpSchema ( const TableDescriptor td) const

Definition at line 3610 of file Catalog.cpp.

References CHECK(), ColumnDescriptor::columnName, ColumnDescriptor::columnType, currentDB_, Catalog_Namespace::DBMetadata::dbId, dictDescriptorMapByRef_, TableDescriptor::fragPageSize, getAllColumnMetadataForTable(), getMetadataForColumn(), TableDescriptor::hasDeletedCol, ColumnDescriptor::isSystemCol, ColumnDescriptor::isVirtualCol, join(), kCHAR, kENCODING_DICT, TableDescriptor::maxChunkSize, TableDescriptor::maxFragRows, TableDescriptor::maxRows, TableDescriptor::nShards, TableDescriptor::partitions, TableDescriptor::shardedColumnId, TableDescriptor::sortedColumnId, TableDescriptor::tableId, and to_string().

Referenced by TableArchiver::dumpTable().

3610  {
3611  cat_read_lock read_lock(this);
3612 
3613  std::ostringstream os;
3614  os << "CREATE TABLE @T (";
3615  // gather column defines
3616  const auto cds = getAllColumnMetadataForTable(td->tableId, false, false, false);
3617  std::string comma;
3618  std::vector<std::string> shared_dicts;
3619  std::map<const std::string, const ColumnDescriptor*> dict_root_cds;
3620  for (const auto cd : cds) {
3621  if (!(cd->isSystemCol || cd->isVirtualCol)) {
3622  const auto& ti = cd->columnType;
3623  os << comma << cd->columnName;
3624  // CHAR is perculiar... better dump it as TEXT(32) like \d does
3625  if (ti.get_type() == SQLTypes::kCHAR) {
3626  os << " "
3627  << "TEXT";
3628  } else if (ti.get_subtype() == SQLTypes::kCHAR) {
3629  os << " "
3630  << "TEXT[]";
3631  } else {
3632  os << " " << ti.get_type_name();
3633  }
3634  os << (ti.get_notnull() ? " NOT NULL" : "");
3635  if (ti.is_string()) {
3636  if (ti.get_compression() == kENCODING_DICT) {
3637  // if foreign reference, get referenced tab.col
3638  const auto dict_id = ti.get_comp_param();
3639  const DictRef dict_ref(currentDB_.dbId, dict_id);
3640  const auto dict_it = dictDescriptorMapByRef_.find(dict_ref);
3641  CHECK(dict_it != dictDescriptorMapByRef_.end());
3642  const auto dict_name = dict_it->second->dictName;
3643  // when migrating a table, any foreign dict ref will be dropped
3644  // and the first cd of a dict will become root of the dict
3645  if (dict_root_cds.end() == dict_root_cds.find(dict_name)) {
3646  dict_root_cds[dict_name] = cd;
3647  os << " ENCODING " << ti.get_compression_name() << "(" << (ti.get_size() * 8)
3648  << ")";
3649  } else {
3650  const auto dict_root_cd = dict_root_cds[dict_name];
3651  shared_dicts.push_back("SHARED DICTIONARY (" + cd->columnName +
3652  ") REFERENCES @T(" + dict_root_cd->columnName + ")");
3653  // "... shouldn't specify an encoding, it borrows from the referenced column"
3654  }
3655  } else {
3656  os << " ENCODING NONE";
3657  }
3658  } else if (ti.get_size() > 0 && ti.get_size() != ti.get_logical_size()) {
3659  const auto comp_param = ti.get_comp_param() ? ti.get_comp_param() : 32;
3660  os << " ENCODING " << ti.get_compression_name() << "(" << comp_param << ")";
3661  }
3662  comma = ", ";
3663  }
3664  }
3665  // gather SHARED DICTIONARYs
3666  if (shared_dicts.size()) {
3667  os << ", " << boost::algorithm::join(shared_dicts, ", ");
3668  }
3669  // gather WITH options ...
3670  std::vector<std::string> with_options;
3671  with_options.push_back("FRAGMENT_SIZE=" + std::to_string(td->maxFragRows));
3672  with_options.push_back("MAX_CHUNK_SIZE=" + std::to_string(td->maxChunkSize));
3673  with_options.push_back("PAGE_SIZE=" + std::to_string(td->fragPageSize));
3674  with_options.push_back("MAX_ROWS=" + std::to_string(td->maxRows));
3675  with_options.emplace_back(td->hasDeletedCol ? "VACUUM='DELAYED'"
3676  : "VACUUM='IMMEDIATE'");
3677  if (!td->partitions.empty()) {
3678  with_options.push_back("PARTITIONS='" + td->partitions + "'");
3679  }
3680  if (td->nShards > 0) {
3681  const auto shard_cd = getMetadataForColumn(td->tableId, td->shardedColumnId);
3682  CHECK(shard_cd);
3683  os << ", SHARD KEY(" << shard_cd->columnName << ")";
3684  with_options.push_back("SHARD_COUNT=" + std::to_string(td->nShards));
3685  }
3686  if (td->sortedColumnId > 0) {
3687  const auto sort_cd = getMetadataForColumn(td->tableId, td->sortedColumnId);
3688  CHECK(sort_cd);
3689  with_options.push_back("SORT_COLUMN='" + sort_cd->columnName + "'");
3690  }
3691  os << ") WITH (" + boost::algorithm::join(with_options, ", ") + ");";
3692  return os.str();
3693 }
std::string partitions
DictDescriptorMapById dictDescriptorMapByRef_
Definition: Catalog.h:367
std::string join(T const &container, std::string const &delim)
read_lock< Catalog > cat_read_lock
Definition: Catalog.cpp:109
std::string to_string(char const *&&v)
CHECK(cgen_state)
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
std::list< const ColumnDescriptor * > getAllColumnMetadataForTable(const int tableId, const bool fetchSystemColumns, const bool fetchVirtualColumns, const bool fetchPhysicalColumns) const
Returns a list of pointers to constant ColumnDescriptor structs for all the columns from a particular...
Definition: Catalog.cpp:1675
Definition: sqltypes.h:42

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::eraseDBData ( )

Definition at line 3365 of file Catalog.cpp.

References basePath_, calciteMgr_, currentDB_, Catalog_Namespace::DBMetadata::dbName, eraseTablePhysicalData(), getAllTableMetadata(), and run_benchmark_import::tables.

3365  {
3366  cat_write_lock write_lock(this);
3367  // Physically erase all tables and dictionaries from disc and memory
3368  const auto tables = getAllTableMetadata();
3369  for (const auto table : tables) {
3370  eraseTablePhysicalData(table);
3371  }
3372  // Physically erase database metadata
3373  boost::filesystem::remove(basePath_ + "/mapd_catalogs/" + currentDB_.dbName);
3374  calciteMgr_->updateMetadata(currentDB_.dbName, "");
3375 }
void eraseTablePhysicalData(const TableDescriptor *td)
Definition: Catalog.cpp:3377
std::list< const TableDescriptor * > getAllTableMetadata() const
Definition: Catalog.cpp:1692
std::shared_ptr< Calcite > calciteMgr_
Definition: Catalog.h:379
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110

+ Here is the call graph for this function:

void Catalog_Namespace::Catalog::eraseTablePhysicalData ( const TableDescriptor td)

Definition at line 3377 of file Catalog.cpp.

References calciteMgr_, Data_Namespace::CPU_LEVEL, currentDB_, dataMgr_, Catalog_Namespace::DBMetadata::dbId, Catalog_Namespace::DBMetadata::dbName, TableDescriptor::fragmenter, Data_Namespace::GPU_LEVEL, INJECT_TIMER, TableDescriptor::isView, removeTableFromMap(), tableDescriptorMapById_, TableDescriptor::tableId, and TableDescriptor::tableName.

Referenced by doDropTable(), and eraseDBData().

3377  {
3378  cat_write_lock write_lock(this);
3379  const int tableId = td->tableId;
3380  // must destroy fragmenter before deleteChunks is called.
3381  if (td->fragmenter != nullptr) {
3382  auto tableDescIt = tableDescriptorMapById_.find(tableId);
3383  {
3384  INJECT_TIMER(deleting_fragmenter);
3385  delete td->fragmenter;
3386  }
3387  tableDescIt->second->fragmenter = nullptr; // get around const-ness
3388  }
3389  ChunkKey chunkKeyPrefix = {currentDB_.dbId, tableId};
3390  {
3391  INJECT_TIMER(deleteChunksWithPrefix);
3392  // assuming deleteChunksWithPrefix is atomic
3393  dataMgr_->deleteChunksWithPrefix(chunkKeyPrefix, MemoryLevel::CPU_LEVEL);
3394  dataMgr_->deleteChunksWithPrefix(chunkKeyPrefix, MemoryLevel::GPU_LEVEL);
3395  }
3396  if (!td->isView) {
3397  INJECT_TIMER(Remove_Table);
3398  dataMgr_->removeTableRelatedDS(currentDB_.dbId, tableId);
3399  }
3400  calciteMgr_->updateMetadata(currentDB_.dbName, td->tableName);
3401  {
3402  INJECT_TIMER(removeTableFromMap_);
3403  removeTableFromMap(td->tableName, tableId);
3404  }
3405 }
std::vector< int > ChunkKey
Definition: types.h:35
std::string tableName
std::shared_ptr< Data_Namespace::DataMgr > dataMgr_
Definition: Catalog.h:376
#define INJECT_TIMER(DESC)
Definition: measure.h:91
TableDescriptorMapById tableDescriptorMapById_
Definition: Catalog.h:364
std::shared_ptr< Calcite > calciteMgr_
Definition: Catalog.h:379
void removeTableFromMap(const std::string &tableName, const int tableId, const bool is_on_error=false)
Definition: Catalog.cpp:1194
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110
Fragmenter_Namespace::AbstractFragmenter * fragmenter

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::executeDropTableSqliteQueries ( const TableDescriptor td)
protected

Definition at line 2947 of file Catalog.cpp.

References StorageType::FOREIGN_TABLE, SqliteConnector::getData(), SqliteConnector::getNumRows(), TableDescriptor::isView, kENCODING_DICT, SqliteConnector::query_with_text_param(), SqliteConnector::query_with_text_params(), sqliteConnector_, TableDescriptor::storageType, TableDescriptor::tableId, and to_string().

Referenced by doDropTable(), and dropFsiSchemasAndTables().

2947  {
2948  const int tableId = td->tableId;
2949  sqliteConnector_.query_with_text_param("DELETE FROM mapd_tables WHERE tableid = ?",
2950  std::to_string(tableId));
2952  "select comp_param from mapd_columns where compression = ? and tableid = ?",
2953  std::vector<std::string>{std::to_string(kENCODING_DICT), std::to_string(tableId)});
2954  int numRows = sqliteConnector_.getNumRows();
2955  std::vector<int> dict_id_list;
2956  for (int r = 0; r < numRows; ++r) {
2957  dict_id_list.push_back(sqliteConnector_.getData<int>(r, 0));
2958  }
2959  for (auto dict_id : dict_id_list) {
2961  "UPDATE mapd_dictionaries SET refcount = refcount - 1 WHERE dictid = ?",
2962  std::vector<std::string>{std::to_string(dict_id)});
2963  }
2965  "DELETE FROM mapd_dictionaries WHERE dictid in (select comp_param from "
2966  "mapd_columns where compression = ? "
2967  "and tableid = ?) and refcount = 0",
2968  std::vector<std::string>{std::to_string(kENCODING_DICT), std::to_string(tableId)});
2969  sqliteConnector_.query_with_text_param("DELETE FROM mapd_columns WHERE tableid = ?",
2970  std::to_string(tableId));
2971  if (td->isView) {
2972  sqliteConnector_.query_with_text_param("DELETE FROM mapd_views WHERE tableid = ?",
2973  std::to_string(tableId));
2974  }
2977  "DELETE FROM omnisci_foreign_tables WHERE table_id = ?", std::to_string(tableId));
2978  }
2979 }
T getData(const int row, const int col)
virtual void query_with_text_params(std::string const &query_only)
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
std::string storageType
std::string to_string(char const *&&v)
static constexpr char const * FOREIGN_TABLE
virtual void query_with_text_param(const std::string &queryString, const std::string &text_param)
virtual size_t getNumRows() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::expandGeoColumn ( const ColumnDescriptor cd,
std::list< ColumnDescriptor > &  columns 
)
static

Definition at line 1950 of file Catalog.cpp.

References CHECK(), ColumnDescriptor::columnName, ColumnDescriptor::columnType, IS_GEO, kARRAY, kDOUBLE, kENCODING_GEOINT, kENCODING_NONE, kINT, kLINESTRING, kMULTIPOLYGON, kPOINT, kPOLYGON, kTINYINT, SQLTypeInfo::set_size(), and SQLTypeInfo::set_subtype().

Referenced by createTable().

1951  {
1952  const auto& col_ti = cd.columnType;
1953  if (IS_GEO(col_ti.get_type())) {
1954  switch (col_ti.get_type()) {
1955  case kPOINT: {
1956  ColumnDescriptor physical_cd_coords(true);
1957  physical_cd_coords.columnName = cd.columnName + "_coords";
1958  SQLTypeInfo coords_ti = SQLTypeInfo(kARRAY, col_ti.get_notnull());
1959  // Raw data: compressed/uncompressed coords
1960  coords_ti.set_subtype(kTINYINT);
1961  size_t unit_size;
1962  if (col_ti.get_compression() == kENCODING_GEOINT &&
1963  col_ti.get_comp_param() == 32) {
1964  unit_size = 4 * sizeof(int8_t);
1965  } else {
1966  CHECK(col_ti.get_compression() == kENCODING_NONE);
1967  unit_size = 8 * sizeof(int8_t);
1968  }
1969  coords_ti.set_size(2 * unit_size);
1970  physical_cd_coords.columnType = coords_ti;
1971  columns.push_back(physical_cd_coords);
1972 
1973  // If adding more physical columns - update SQLTypeInfo::get_physical_cols()
1974 
1975  break;
1976  }
1977  case kLINESTRING: {
1978  ColumnDescriptor physical_cd_coords(true);
1979  physical_cd_coords.columnName = cd.columnName + "_coords";
1980  SQLTypeInfo coords_ti = SQLTypeInfo(kARRAY, col_ti.get_notnull());
1981  // Raw data: compressed/uncompressed coords
1982  coords_ti.set_subtype(kTINYINT);
1983  physical_cd_coords.columnType = coords_ti;
1984  columns.push_back(physical_cd_coords);
1985 
1986  ColumnDescriptor physical_cd_bounds(true);
1987  physical_cd_bounds.columnName = cd.columnName + "_bounds";
1988  SQLTypeInfo bounds_ti = SQLTypeInfo(kARRAY, col_ti.get_notnull());
1989  bounds_ti.set_subtype(kDOUBLE);
1990  bounds_ti.set_size(4 * sizeof(double));
1991  physical_cd_bounds.columnType = bounds_ti;
1992  columns.push_back(physical_cd_bounds);
1993 
1994  // If adding more physical columns - update SQLTypeInfo::get_physical_cols()
1995 
1996  break;
1997  }
1998  case kPOLYGON: {
1999  ColumnDescriptor physical_cd_coords(true);
2000  physical_cd_coords.columnName = cd.columnName + "_coords";
2001  SQLTypeInfo coords_ti = SQLTypeInfo(kARRAY, col_ti.get_notnull());
2002  // Raw data: compressed/uncompressed coords
2003  coords_ti.set_subtype(kTINYINT);
2004  physical_cd_coords.columnType = coords_ti;
2005  columns.push_back(physical_cd_coords);
2006 
2007  ColumnDescriptor physical_cd_ring_sizes(true);
2008  physical_cd_ring_sizes.columnName = cd.columnName + "_ring_sizes";
2009  SQLTypeInfo ring_sizes_ti = SQLTypeInfo(kARRAY, col_ti.get_notnull());
2010  ring_sizes_ti.set_subtype(kINT);
2011  physical_cd_ring_sizes.columnType = ring_sizes_ti;
2012  columns.push_back(physical_cd_ring_sizes);
2013 
2014  ColumnDescriptor physical_cd_bounds(true);
2015  physical_cd_bounds.columnName = cd.columnName + "_bounds";
2016  SQLTypeInfo bounds_ti = SQLTypeInfo(kARRAY, col_ti.get_notnull());
2017  bounds_ti.set_subtype(kDOUBLE);
2018  bounds_ti.set_size(4 * sizeof(double));
2019  physical_cd_bounds.columnType = bounds_ti;
2020  columns.push_back(physical_cd_bounds);
2021 
2022  ColumnDescriptor physical_cd_render_group(true);
2023  physical_cd_render_group.columnName = cd.columnName + "_render_group";
2024  SQLTypeInfo render_group_ti = SQLTypeInfo(kINT, col_ti.get_notnull());
2025  physical_cd_render_group.columnType = render_group_ti;
2026  columns.push_back(physical_cd_render_group);
2027 
2028  // If adding more physical columns - update SQLTypeInfo::get_physical_cols()
2029 
2030  break;
2031  }
2032  case kMULTIPOLYGON: {
2033  ColumnDescriptor physical_cd_coords(true);
2034  physical_cd_coords.columnName = cd.columnName + "_coords";
2035  SQLTypeInfo coords_ti = SQLTypeInfo(kARRAY, col_ti.get_notnull());
2036  // Raw data: compressed/uncompressed coords
2037  coords_ti.set_subtype(kTINYINT);
2038  physical_cd_coords.columnType = coords_ti;
2039  columns.push_back(physical_cd_coords);
2040 
2041  ColumnDescriptor physical_cd_ring_sizes(true);
2042  physical_cd_ring_sizes.columnName = cd.columnName + "_ring_sizes";
2043  SQLTypeInfo ring_sizes_ti = SQLTypeInfo(kARRAY, col_ti.get_notnull());
2044  ring_sizes_ti.set_subtype(kINT);
2045  physical_cd_ring_sizes.columnType = ring_sizes_ti;
2046  columns.push_back(physical_cd_ring_sizes);
2047 
2048  ColumnDescriptor physical_cd_poly_rings(true);
2049  physical_cd_poly_rings.columnName = cd.columnName + "_poly_rings";
2050  SQLTypeInfo poly_rings_ti = SQLTypeInfo(kARRAY, col_ti.get_notnull());
2051  poly_rings_ti.set_subtype(kINT);
2052  physical_cd_poly_rings.columnType = poly_rings_ti;
2053  columns.push_back(physical_cd_poly_rings);
2054 
2055  ColumnDescriptor physical_cd_bounds(true);
2056  physical_cd_bounds.columnName = cd.columnName + "_bounds";
2057  SQLTypeInfo bounds_ti = SQLTypeInfo(kARRAY, col_ti.get_notnull());
2058  bounds_ti.set_subtype(kDOUBLE);
2059  bounds_ti.set_size(4 * sizeof(double));
2060  physical_cd_bounds.columnType = bounds_ti;
2061  columns.push_back(physical_cd_bounds);
2062 
2063  ColumnDescriptor physical_cd_render_group(true);
2064  physical_cd_render_group.columnName = cd.columnName + "_render_group";
2065  SQLTypeInfo render_group_ti = SQLTypeInfo(kINT, col_ti.get_notnull());
2066  physical_cd_render_group.columnType = render_group_ti;
2067  columns.push_back(physical_cd_render_group);
2068 
2069  // If adding more physical columns - update SQLTypeInfo::get_physical_cols()
2070 
2071  break;
2072  }
2073  default:
2074  throw runtime_error("Unrecognized geometry type.");
2075  break;
2076  }
2077  }
2078 }
void set_size(int s)
Definition: sqltypes.h:346
HOST DEVICE void set_subtype(SQLTypes st)
Definition: sqltypes.h:339
CHECK(cgen_state)
specifies the content in-memory of a row in the column metadata table
Definition: sqltypes.h:46
SQLTypeInfo columnType
std::string columnName
#define IS_GEO(T)
Definition: sqltypes.h:163

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string Catalog_Namespace::Catalog::generatePhysicalTableName ( const std::string &  logicalTableName,
const int32_t &  shardNumber 
)
protected

Definition at line 3407 of file Catalog.cpp.

References physicalTableNameTag_, and to_string().

Referenced by createShardedTable(), and renameTable().

3408  {
3409  std::string physicalTableName =
3410  logicalTableName + physicalTableNameTag_ + std::to_string(shardNumber);
3411  return (physicalTableName);
3412 }
std::string to_string(char const *&&v)
static const std::string physicalTableNameTag_
Definition: Catalog.h:383

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr< Catalog > Catalog_Namespace::Catalog::get ( const std::string &  dbName)
static

Definition at line 3418 of file Catalog.cpp.

References mapd_cat_map_.

Referenced by main().

3418  {
3419  auto cat_it = mapd_cat_map_.find(dbName);
3420  if (cat_it != mapd_cat_map_.end()) {
3421  return cat_it->second;
3422  }
3423  return nullptr;
3424 }
static std::map< std::string, std::shared_ptr< Catalog > > mapd_cat_map_
Definition: Catalog.h:396

+ Here is the caller graph for this function:

static std::shared_ptr<Catalog> Catalog_Namespace::Catalog::get ( const std::string &  basePath,
const DBMetadata curDB,
std::shared_ptr< Data_Namespace::DataMgr dataMgr,
const std::vector< LeafHostInfo > &  string_dict_hosts,
std::shared_ptr< Calcite calcite,
bool  is_new_db 
)
static
list< const ColumnDescriptor * > Catalog_Namespace::Catalog::getAllColumnMetadataForTable ( const int  tableId,
const bool  fetchSystemColumns,
const bool  fetchVirtualColumns,
const bool  fetchPhysicalColumns 
) const

Returns a list of pointers to constant ColumnDescriptor structs for all the columns from a particular table specified by table id.

Parameters
tableIdtable id we want the column metadata for
Returns
list of pointers to const ColumnDescriptor structs - one for each and every column in the table

Definition at line 1675 of file Catalog.cpp.

References getMetadataForTableImpl().

Referenced by Analyzer::RangeTableEntry::add_all_column_descs(), Parser::InsertStmt::analyze(), Parser::InsertValuesStmt::analyze(), Fragmenter_Namespace::copyDataOfShard(), Parser::InsertValuesStmt::determineLeafIndex(), dumpSchema(), TableArchiver::dumpTable(), Analyzer::RangeTableEntry::expand_star_in_targetlist(), getShardColumnMetadataForTable(), getTableDictDirectories(), instantiateFragmenter(), TableOptimizer::recomputeMetadata(), TableArchiver::restoreTable(), and validate_shared_dictionary().

1679  {
1680  cat_read_lock read_lock(this);
1681  list<const ColumnDescriptor*> columnDescriptors;
1682  const TableDescriptor* td =
1683  getMetadataForTableImpl(tableId, false); // dont instantiate fragmenter
1685  columnDescriptors,
1686  fetchSystemColumns,
1687  fetchVirtualColumns,
1688  fetchPhysicalColumns);
1689  return columnDescriptors;
1690 }
read_lock< Catalog > cat_read_lock
Definition: Catalog.cpp:109
std::list< const ColumnDescriptor * > getAllColumnMetadataForTable(const int tableId, const bool fetchSystemColumns, const bool fetchVirtualColumns, const bool fetchPhysicalColumns) const
Returns a list of pointers to constant ColumnDescriptor structs for all the columns from a particular...
Definition: Catalog.cpp:1675
const TableDescriptor * getMetadataForTableImpl(int tableId, const bool populateFragmenter) const
Definition: Catalog.cpp:1424
specifies the content in-memory of a row in the table metadata table

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::Catalog::getAllColumnMetadataForTable ( const TableDescriptor td,
std::list< const ColumnDescriptor * > &  colDescs,
const bool  fetchSystemColumns,
const bool  fetchVirtualColumns,
const bool  fetchPhysicalColumns 
) const
protected
list< const DashboardDescriptor * > Catalog_Namespace::Catalog::getAllDashboardsMetadata ( ) const

Definition at line 1701 of file Catalog.cpp.

References dashboardDescriptorMap_.

1701  {
1702  list<const DashboardDescriptor*> view_list;
1703  for (auto p : dashboardDescriptorMap_) {
1704  view_list.push_back(p.second.get());
1705  }
1706  return view_list;
1707 }
DashboardDescriptorMap dashboardDescriptorMap_
Definition: Catalog.h:368
list< const TableDescriptor * > Catalog_Namespace::Catalog::getAllTableMetadata ( ) const

Definition at line 1692 of file Catalog.cpp.

References tableDescriptorMapById_.

Referenced by eraseDBData(), and getTableNamesForUser().

1692  {
1693  cat_read_lock read_lock(this);
1694  list<const TableDescriptor*> table_list;
1695  for (auto p : tableDescriptorMapById_) {
1696  table_list.push_back(p.second);
1697  }
1698  return table_list;
1699 }
read_lock< Catalog > cat_read_lock
Definition: Catalog.cpp:109
TableDescriptorMapById tableDescriptorMapById_
Definition: Catalog.h:364

+ Here is the caller graph for this function:

const std::string& Catalog_Namespace::Catalog::getBasePath ( ) const
inline

Definition at line 185 of file Catalog.h.

References basePath_.

185 { return basePath_; }
std::shared_ptr<Calcite> Catalog_Namespace::Catalog::getCalciteMgr ( ) const
inline

Definition at line 184 of file Catalog.h.

References calciteMgr_.

184 { return calciteMgr_; }
std::shared_ptr< Calcite > calciteMgr_
Definition: Catalog.h:379
std::string Catalog_Namespace::Catalog::getColumnDictDirectory ( const ColumnDescriptor cd) const

Definition at line 3580 of file Catalog.cpp.

References CHECK(), ColumnDescriptor::columnType, currentDB_, Catalog_Namespace::DBMetadata::dbId, dictDescriptorMapByRef_, SQLTypeInfo::get_comp_param(), SQLTypeInfo::get_compression(), SQLTypeInfo::is_string(), SQLTypeInfo::is_string_array(), and kENCODING_DICT.

Referenced by TableArchiver::dumpTable(), getTableDictDirectories(), and TableArchiver::restoreTable().

3580  {
3581  if ((cd->columnType.is_string() || cd->columnType.is_string_array()) &&
3583  cd->columnType.get_comp_param() > 0) {
3584  const auto dictId = cd->columnType.get_comp_param();
3585  const DictRef dictRef(currentDB_.dbId, dictId);
3586  const auto dit = dictDescriptorMapByRef_.find(dictRef);
3587  CHECK(dit != dictDescriptorMapByRef_.end());
3588  CHECK(dit->second);
3589  boost::filesystem::path file_path(dit->second->dictFolderPath);
3590  return file_path.filename().string();
3591  }
3592  return std::string();
3593 }
DictDescriptorMapById dictDescriptorMapByRef_
Definition: Catalog.h:367
CHECK(cgen_state)
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:256
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:257
SQLTypeInfo columnType
bool is_string() const
Definition: sqltypes.h:399
bool is_string_array() const
Definition: sqltypes.h:400

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const int Catalog_Namespace::Catalog::getColumnIdBySpi ( const int  tableId,
const size_t  spi 
) const

Definition at line 1526 of file Catalog.cpp.

References getColumnIdBySpiUnlocked().

Referenced by anonymous_namespace{RelAlgExecutor.cpp}::collect_used_input_desc(), and anonymous_namespace{RelAlgExecutor.cpp}::get_physical_inputs().

1526  {
1527  cat_read_lock read_lock(this);
1528  return getColumnIdBySpiUnlocked(table_id, spi);
1529 }
read_lock< Catalog > cat_read_lock
Definition: Catalog.cpp:109
const int getColumnIdBySpiUnlocked(const int table_id, const size_t spi) const
Definition: Catalog.cpp:1509

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const int Catalog_Namespace::Catalog::getColumnIdBySpiUnlocked ( const int  table_id,
const size_t  spi 
) const
protected

Definition at line 1509 of file Catalog.cpp.

References CHECK(), SPIMAP_MAGIC1, SPIMAP_MAGIC2, and tableDescriptorMapById_.

Referenced by getColumnIdBySpi(), and getMetadataForColumnBySpi().

1509  {
1510  const auto tabDescIt = tableDescriptorMapById_.find(table_id);
1511  CHECK(tableDescriptorMapById_.end() != tabDescIt);
1512  const auto& columnIdBySpi = tabDescIt->second->columnIdBySpi_;
1513 
1514  auto spx = spi;
1515  int phi = 0;
1516  if (spx >= SPIMAP_MAGIC1) // see Catalog.h
1517  {
1518  phi = (spx - SPIMAP_MAGIC1) % SPIMAP_MAGIC2;
1519  spx = (spx - SPIMAP_MAGIC1) / SPIMAP_MAGIC2;
1520  }
1521 
1522  CHECK(0 < spx && spx <= columnIdBySpi.size());
1523  return columnIdBySpi[spx - 1] + phi;
1524 }
#define SPIMAP_MAGIC1
Definition: Catalog.h:73
#define SPIMAP_MAGIC2
Definition: Catalog.h:74
CHECK(cgen_state)
TableDescriptorMapById tableDescriptorMapById_
Definition: Catalog.h:364

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int Catalog_Namespace::Catalog::getDatabaseId ( ) const
inline

Definition at line 210 of file Catalog.h.

References currentDB_, and Catalog_Namespace::DBMetadata::dbId.

Referenced by RelAlgTranslator::getInIntegerSetExpr().

210 { return currentDB_.dbId; }

+ Here is the caller graph for this function:

const ColumnDescriptor * Catalog_Namespace::Catalog::getDeletedColumn ( const TableDescriptor td) const

Definition at line 2539 of file Catalog.cpp.

References deletedColumnPerTable_.

Referenced by RelAlgExecutor::executeDelete(), TableOptimizer::recomputeMetadata(), and vacuumDeletedRows().

2539  {
2540  cat_read_lock read_lock(this);
2541  const auto it = deletedColumnPerTable_.find(td);
2542  return it != deletedColumnPerTable_.end() ? it->second : nullptr;
2543 }
read_lock< Catalog > cat_read_lock
Definition: Catalog.cpp:109
DeletedColumnPerTableMap deletedColumnPerTable_
Definition: Catalog.h:397

+ Here is the caller graph for this function:

const ColumnDescriptor * Catalog_Namespace::Catalog::getDeletedColumnIfRowsDeleted ( const TableDescriptor td) const

Definition at line 2571 of file Catalog.cpp.

References CHECK(), checkMetadataForDeletedRecs(), ColumnDescriptor::columnId, deletedColumnPerTable_, getMetadataForTable(), logicalToPhysicalTableMapById_, and TableDescriptor::tableId.

2572  {
2573  cat_read_lock read_lock(this);
2574 
2575  const auto it = deletedColumnPerTable_.find(td);
2576  // if not a table that supports delete return nullptr, nothing more to do
2577  if (it == deletedColumnPerTable_.end()) {
2578  return nullptr;
2579  }
2580  const ColumnDescriptor* cd = it->second;
2581 
2582  const auto physicalTableIt = logicalToPhysicalTableMapById_.find(td->tableId);
2583 
2584  if (physicalTableIt != logicalToPhysicalTableMapById_.end()) {
2585  // check all shards
2586  const auto physicalTables = physicalTableIt->second;
2587  CHECK(!physicalTables.empty());
2588  for (size_t i = 0; i < physicalTables.size(); i++) {
2589  int32_t physical_tb_id = physicalTables[i];
2590  const TableDescriptor* phys_td = getMetadataForTable(physical_tb_id);
2591  CHECK(phys_td);
2592  if (checkMetadataForDeletedRecs(phys_td, cd->columnId)) {
2593  return cd;
2594  }
2595  }
2596  } else {
2597  if (checkMetadataForDeletedRecs(td, cd->columnId)) {
2598  return cd;
2599  }
2600  }
2601  // no deletes so far recorded in metadata
2602  return nullptr;
2603 }
read_lock< Catalog > cat_read_lock
Definition: Catalog.cpp:109
DeletedColumnPerTableMap deletedColumnPerTable_
Definition: Catalog.h:397
const bool checkMetadataForDeletedRecs(const TableDescriptor *td, int column_id) const
Definition: Catalog.cpp:2545
CHECK(cgen_state)
specifies the content in-memory of a row in the column metadata table
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
specifies the content in-memory of a row in the table metadata table
LogicalToPhysicalTableMapById logicalToPhysicalTableMapById_
Definition: Catalog.h:381

+ Here is the call graph for this function:

void Catalog_Namespace::Catalog::getDictionary ( const ColumnDescriptor cd,
std::map< int, StringDictionary * > &  stringDicts 
)

Definition at line 1776 of file Catalog.cpp.

References CHECK(), columnDescriptorMap_, ColumnDescriptor::columnName, currentDB_, Catalog_Namespace::DBMetadata::dbId, dictDescriptorMapByRef_, getMetadataForDict(), kENCODING_DICT, ColumnDescriptor::tableId, and to_upper().

1777  {
1778  // learn 'committed' ColumnDescriptor of this column
1779  auto cit = columnDescriptorMap_.find(ColumnKey(cd.tableId, to_upper(cd.columnName)));
1780  CHECK(cit != columnDescriptorMap_.end());
1781  auto& ccd = *cit->second;
1782 
1783  if (!(ccd.columnType.is_string() || ccd.columnType.is_string_array())) {
1784  return;
1785  }
1786  if (!(ccd.columnType.get_compression() == kENCODING_DICT)) {
1787  return;
1788  }
1789  if (!(ccd.columnType.get_comp_param() > 0)) {
1790  return;
1791  }
1792 
1793  auto dictId = ccd.columnType.get_comp_param();
1794  getMetadataForDict(dictId);
1795 
1796  const DictRef dictRef(currentDB_.dbId, dictId);
1797  auto dit = dictDescriptorMapByRef_.find(dictRef);
1798  CHECK(dit != dictDescriptorMapByRef_.end());
1799  CHECK(dit->second);
1800  CHECK(dit->second.get()->stringDict);
1801  stringDicts[ccd.columnId] = dit->second.get()->stringDict.get();
1802 }
std::tuple< int, std::string > ColumnKey
Definition: Types.h:36
ColumnDescriptorMap columnDescriptorMap_
Definition: Catalog.h:365
DictDescriptorMapById dictDescriptorMapByRef_
Definition: Catalog.h:367
CHECK(cgen_state)
const DictDescriptor * getMetadataForDict(int dict_ref, bool loadDict=true) const
Definition: Catalog.cpp:1444
std::string to_upper(const std::string &str)
std::string columnName

+ Here is the call graph for this function:

foreign_storage::ForeignServer * Catalog_Namespace::Catalog::getForeignServer ( const std::string &  server_name) const

Gets a pointer to a struct containing foreign server details.

Parameters
server_name- Name of foreign server whose details will be fetched
Returns
pointer to a struct containing foreign server details. nullptr is returned if no foreign server exists with the given name

Definition at line 2424 of file Catalog.cpp.

References foreignServerMap_.

Referenced by DBObject::loadKey().

2425  {
2426  foreign_storage::ForeignServer* foreign_server = nullptr;
2427  cat_read_lock read_lock(this);
2428  if (foreignServerMap_.find(server_name) != foreignServerMap_.end()) {
2429  foreign_server = foreignServerMap_.find(server_name)->second.get();
2430  }
2431  return foreign_server;
2432 }
read_lock< Catalog > cat_read_lock
Definition: Catalog.cpp:109
ForeignServerMap foreignServerMap_
Definition: Catalog.h:371

+ Here is the caller graph for this function:

foreign_storage::ForeignServer * Catalog_Namespace::Catalog::getForeignServerSkipCache ( const std::string &  server_name)

Gets a pointer to a struct containing foreign server details. Skip in-memory cache of foreign server struct when attempting to fetch foreign server details. This is mainly used for testing.

Parameters
server_name- Name of foreign server whose details will be fetched
Returns
pointer to a struct containing foreign server details. nullptr is returned if no foreign server exists with the given name

Definition at line 2434 of file Catalog.cpp.

References foreignServerMap_, foreignServerMapById_, SqliteConnector::getData(), SqliteConnector::getNumRows(), SqliteConnector::query_with_text_params(), and sqliteConnector_.

2435  {
2436  foreign_storage::ForeignServer* foreign_server = nullptr;
2437  cat_write_lock write_lock(this);
2438  cat_sqlite_lock sqlite_lock(this);
2440  "SELECT id, name, data_wrapper_type, options, owner_user_id "
2441  "FROM omnisci_foreign_servers WHERE name = ?",
2442  std::vector<std::string>{server_name});
2443  if (sqliteConnector_.getNumRows() > 0) {
2444  auto server = std::make_shared<foreign_storage::ForeignServer>(
2446  server->id = sqliteConnector_.getData<int>(0, 0);
2447  server->name = sqliteConnector_.getData<std::string>(0, 1);
2448  server->user_id = sqliteConnector_.getData<std::int32_t>(0, 4);
2449  server->populateOptionsMap(sqliteConnector_.getData<std::string>(0, 3));
2450  foreign_server = server.get();
2451  foreignServerMap_[server->name] = server;
2452  foreignServerMapById_[server->id] = server;
2453  }
2454  return foreign_server;
2455 }
T getData(const int row, const int col)
virtual void query_with_text_params(std::string const &query_only)
SqliteConnector sqliteConnector_
Definition: Catalog.h:374
ForeignServerMapById foreignServerMapById_
Definition: Catalog.h:372
ForeignServerMap foreignServerMap_
Definition: Catalog.h:371
write_lock< Catalog > cat_write_lock
Definition: Catalog.cpp:110
sqlite_lock< Catalog > cat_sqlite_lock
Definition: Catalog.cpp:111
virtual size_t getNumRows() const

+ Here is the call graph for this function:

int Catalog_Namespace::Catalog::getLogicalTableId ( const int  physicalTableId) const

Definition at line 3343 of file Catalog.cpp.

References logicalToPhysicalTableMapById_.

Referenced by Fragmenter_Namespace::InsertOrderFragmenter::updateColumn(), Fragmenter_Namespace::InsertOrderFragmenter::updateColumns(), and vacuumDeletedRows().

3343  {
3344  cat_read_lock read_lock(this);
3345  for (const auto& l : logicalToPhysicalTableMapById_) {
3346  if (l.second.end() != std::find_if(l.second.begin(),
3347  l.second.end(),
3348  [&](decltype(*l.second.begin()) tid) -> bool {
3349  return physicalTableId == tid;
3350  })) {
3351  return l.first;
3352  }
3353  }
3354  return physicalTableId;
3355 }
read_lock< Catalog > cat_read_lock
Definition: Catalog.cpp:109
LogicalToPhysicalTableMapById logicalToPhysicalTableMapById_
Definition: Catalog.h:381

+ Here is the caller graph for this function:

const ColumnDescriptor * Catalog_Namespace::Catalog::getMetadataForColumn ( int  tableId,
int  columnId 
) const

Definition at line 1497 of file Catalog.cpp.

References columnDescriptorMapById_.

1497  {
1498  cat_read_lock read_lock(this);
1499 
1500  ColumnIdKey columnIdKey(tableId, columnId);
1501  auto colDescIt = columnDescriptorMapById_.find(columnIdKey);
1502  if (colDescIt == columnDescriptorMapById_
1503  .end()) { // need to check to make sure column exists for table
1504  return nullptr;
1505  }
1506  return colDescIt->second;
1507 }
read_lock< Catalog > cat_read_lock
Definition: Catalog.cpp:109
ColumnDescriptorMapById columnDescriptorMapById_
Definition: Catalog.h:366
std::tuple< int, int > ColumnIdKey
Definition: Types.h:38
const ColumnDescriptor * Catalog_Namespace::Catalog::getMetadataForColumnBySpi ( const int  tableId,
const size_t  spi 
) const

Definition at line 1531 of file Catalog.cpp.

References columnDescriptorMapById_, and getColumnIdBySpiUnlocked().

Referenced by RelAlgTranslator::translateGeoColumn(), RelAlgTranslator::translateInput(), and anonymous_namespace{RelAlgExecutor.cpp}::RexUsedInputsVisitor::visitInput().

1532  {
1533  cat_read_lock read_lock(this);
1534 
1535  const auto columnId = getColumnIdBySpiUnlocked(tableId, spi);
1536  ColumnIdKey columnIdKey(tableId, columnId);
1537  const auto colDescIt = columnDescriptorMapById_.find(columnIdKey);
1538  return columnDescriptorMapById_.end() == colDescIt ? nullptr : colDescIt->second;
1539 }
read_lock< Catalog > cat_read_lock
Definition: Catalog.cpp:109
ColumnDescriptorMapById columnDescriptorMapById_
Definition: Catalog.h:366
const int getColumnIdBySpiUnlocked(const int table_id, const size_t spi) const
Definition: Catalog.cpp:1509
std::tuple< int, int > ColumnIdKey
Definition: Types.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const DashboardDescriptor* Catalog_Namespace::Catalog::getMetadataForDashboard ( const std::string &  userId,
const std::string &  dashName 
) const

Referenced by getMetadataForDashboard(), and DBObject::loadKey().

+ Here is the caller graph for this function:

const DashboardDescriptor * Catalog_Namespace::Catalog::getMetadataForDashboard ( const int32_t  dashboard_id) const

Definition at line 1580 of file Catalog.cpp.

References dashboardDescriptorMap_, getMetadataForDashboard(), name(), and to_string().

1580  {
1581  cat_read_lock read_lock(this);
1582  std::string userId;
1583  std::string name;
1584  bool found{false};
1585  {
1586  for (auto descp : dashboardDescriptorMap_) {
1587  auto dash = descp.second.get();
1588  if (dash->dashboardId == id) {
1589  userId = std::to_string(dash->userId);
1590  name = dash->dashboardName;
1591  found = true;
1592  break;
1593  }
1594  }
1595  }
1596  if (found) {
1597  return getMetadataForDashboard(userId, name);
1598  }
1599  return nullptr;
1600 }
read_lock< Catalog > cat_read_lock
Definition: Catalog.cpp:109
DashboardDescriptorMap dashboardDescriptorMap_
Definition: Catalog.h:368
std::string to_string(char const *&&v)
std::string name() const
Definition: Catalog.h:236
const DashboardDescriptor * getMetadataForDashboard(const std::string &userId, const std::string &dashName) const

+ Here is the call graph for this function:

const DictDescriptor * Catalog_Namespace::Catalog::getMetadataForDict ( int  dict_ref,
bool  loadDict = true 
) const

Definition at line 1444 of file Catalog.cpp.

References currentDB_, Catalog_Namespace::DBMetadata::dbId, dictDescriptorMapByRef_, measure< TimeT >::execution(), g_cache_string_hash, logger::INFO, LOG, and string_dict_hosts_.

Referenced by Parser::InsertValuesStmt::determineLeafIndex(), DictionaryValueConverter< TARGET_TYPE >::DictionaryValueConverter(), doTruncateTable(), RelAlgExecutor::executeSimpleInsert(), MapDHandler::fixup_row_descriptor(), getDictionary(), Importer_NS::Loader::init(), anonymous_namespace{RelAlgExecutor.cpp}::insert_one_dict_str(), MapDHandler::populateThriftColumnType(), ArrowCsvForeignStorage::registerTable(), StringValueConverter::StringValueConverter(), and Fragmenter_Namespace::InsertOrderFragmenter::updateColumn().

1445  {
1446  const DictRef dictRef(currentDB_.dbId, dictId);
1447  cat_read_lock read_lock(this);
1448  auto dictDescIt = dictDescriptorMapByRef_.find(dictRef);
1449  if (dictDescIt ==
1450  dictDescriptorMapByRef_.end()) { // check to make sure dictionary exists
1451  return nullptr;
1452  }
1453  auto& dd = dictDescIt->second;
1454 
1455  if (loadDict) {
1456  cat_sqlite_lock sqlite_lock(this);
1457  if (!dd->stringDict) {
1458  auto time_ms = measure<>::execution([&]() {
1459  if (string_dict_hosts_.empty()) {
1460  if (dd->dictIsTemp) {
1461  dd->stringDict = std::make_shared<StringDictionary>(
1462  dd->dictFolderPath, true, true, g_cache_string_hash);
1463  } else {
1464  dd->stringDict = std::make_shared<StringDictionary>(
1465  dd->dictFolderPath, false, true, g_cache_string_hash);
1466  }
1467  } else {
1468  dd->stringDict =
1469  std::make_shared<StringDictionary>(string_dict_hosts_.front(), dd->dictRef);
1470  }
1471  });
1472  LOG(INFO) << "Time to load Dictionary " << dd->dictRef.dbId << "_"
1473  << dd->dictRef.dictId << " was " << time_ms << "ms";
1474  }
1475  }
1476 
1477  return dd.get();
1478 }
static TimeT::rep execution(F func, Args &&...args)
Definition: sample.cpp:29
#define LOG(tag)
Definition: Logger.h:188