OmniSciDB  340b00dbf6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Go to the documentation of this file.
1 /*
2  * Copyright 2017 MapD Technologies, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
29 #pragma once
31 #include <atomic>
32 #include <cstdint>
33 #include <ctime>
34 #include <limits>
35 #include <list>
36 #include <map>
37 #include <mutex>
38 #include <string>
39 #include <utility>
40 #include <vector>
42 #include "Calcite/Calcite.h"
45 #include "Catalog/DictDescriptor.h"
46 #include "Catalog/ForeignServer.h"
47 #include "Catalog/ForeignTable.h"
48 #include "Catalog/LinkDescriptor.h"
49 #include "Catalog/SessionInfo.h"
50 #include "Catalog/SysCatalog.h"
52 #include "Catalog/Types.h"
53 #include "DataMgr/DataMgr.h"
58 #include "LeafHostInfo.h"
62 namespace Parser {
66 } // namespace Parser
68 class TableArchiver;
70 // SPI means Sequential Positional Index which is equivalent to the input index in a
71 // RexInput node
72 #define SPIMAP_MAGIC1 (std::numeric_limits<unsigned>::max() / 4)
73 #define SPIMAP_MAGIC2 8
74 #define SPIMAP_GEO_PHYSICAL_INPUT(c, i) \
75  (SPIMAP_MAGIC1 + (unsigned)(SPIMAP_MAGIC2 * ((c) + 1) + (i)))
77 namespace Catalog_Namespace {
81  TableEpochInfo(const int32_t table_id_param, const int32_t table_epoch_param)
82  : table_id(table_id_param), table_epoch(table_epoch_param) {}
83  TableEpochInfo(const int32_t table_id_param,
84  const int32_t table_epoch_param,
85  const size_t leaf_index_param)
86  : table_id(table_id_param)
87  , table_epoch(table_epoch_param)
88  , leaf_index(leaf_index_param) {}
89 };
97 class Catalog final {
98  public:
107  Catalog(const std::string& basePath,
108  const DBMetadata& curDB,
109  std::shared_ptr<Data_Namespace::DataMgr> dataMgr,
110  const std::vector<LeafHostInfo>& string_dict_hosts,
111  std::shared_ptr<Calcite> calcite,
112  bool is_new_db);
120  ~Catalog();
122  static void expandGeoColumn(const ColumnDescriptor& cd,
123  std::list<ColumnDescriptor>& columns);
124  void createTable(TableDescriptor& td,
125  const std::list<ColumnDescriptor>& columns,
126  const std::vector<Parser::SharedDictionaryDef>& shared_dict_defs,
127  bool isLogicalTable);
128  void createShardedTable(
129  TableDescriptor& td,
130  const std::list<ColumnDescriptor>& columns,
131  const std::vector<Parser::SharedDictionaryDef>& shared_dict_defs);
134  std::string createLink(LinkDescriptor& ld, size_t min_length);
135  void dropTable(const TableDescriptor* td);
136  void truncateTable(const TableDescriptor* td);
137  void renameTable(const TableDescriptor* td, const std::string& newTableName);
138  void renameColumn(const TableDescriptor* td,
139  const ColumnDescriptor* cd,
140  const std::string& newColumnName);
141  void addColumn(const TableDescriptor& td, ColumnDescriptor& cd);
142  void dropColumn(const TableDescriptor& td, const ColumnDescriptor& cd);
143  void removeChunks(const int table_id);
144  void removeFragmenterForTable(const int table_id);
146  const std::map<int, const ColumnDescriptor*> getDictionaryToColumnMapping();
156  const TableDescriptor* getMetadataForTable(const std::string& tableName,
157  const bool populateFragmenter = true) const;
158  const TableDescriptor* getMetadataForTableImpl(int tableId,
159  const bool populateFragmenter) const;
160  const TableDescriptor* getMetadataForTable(int tableId,
161  bool populateFragmenter = true) const;
163  const ColumnDescriptor* getMetadataForColumn(int tableId,
164  const std::string& colName) const;
165  const ColumnDescriptor* getMetadataForColumn(int tableId, int columnId) const;
166  const ColumnDescriptor* getMetadataForColumnUnlocked(int tableId, int columnId) const;
168  const int getColumnIdBySpi(const int tableId, const size_t spi) const;
169  const ColumnDescriptor* getMetadataForColumnBySpi(const int tableId,
170  const size_t spi) const;
172  const DashboardDescriptor* getMetadataForDashboard(const std::string& userId,
173  const std::string& dashName) const;
175  const DashboardDescriptor* getMetadataForDashboard(const int32_t dashboard_id) const;
176  void deleteMetadataForDashboards(const std::vector<int32_t> ids,
177  const UserMetadata& user);
179  const LinkDescriptor* getMetadataForLink(const std::string& link) const;
180  const LinkDescriptor* getMetadataForLink(int linkId) const;
182  const foreign_storage::ForeignTable* getForeignTableUnlocked(int tableId) const;
184  const foreign_storage::ForeignTable* getForeignTable(int table_id) const;
194  std::list<const ColumnDescriptor*> getAllColumnMetadataForTable(
195  const int tableId,
196  const bool fetchSystemColumns,
197  const bool fetchVirtualColumns,
198  const bool fetchPhysicalColumns) const;
202  std::list<const ColumnDescriptor*> getAllColumnMetadataForTableUnlocked(
203  const int tableId,
204  const bool fetchSystemColumns,
205  const bool fetchVirtualColumns,
206  const bool fetchPhysicalColumns) const;
208  std::list<const TableDescriptor*> getAllTableMetadata() const;
209  std::list<const DashboardDescriptor*> getAllDashboardsMetadata() const;
210  const DBMetadata& getCurrentDB() const { return currentDB_; }
212  std::shared_ptr<Calcite> getCalciteMgr() const { return calciteMgr_; }
213  const std::string& getBasePath() const { return basePath_; }
215  const DictDescriptor* getMetadataForDict(int dict_ref, bool loadDict = true) const;
216  const DictDescriptor* getMetadataForDictUnlocked(int dict_ref, bool loadDict) const;
218  const std::vector<LeafHostInfo>& getStringDictionaryHosts() const;
222  std::vector<const TableDescriptor*> getPhysicalTablesDescriptors(
223  const TableDescriptor* logicalTableDesc) const;
233  std::vector<std::string> getTableNamesForUser(
234  const UserMetadata& user,
235  const GetTablesType get_tables_type) const;
237  int32_t getTableEpoch(const int32_t db_id, const int32_t table_id) const;
238  void setTableEpoch(const int db_id, const int table_id, const int new_epoch);
240  std::vector<TableEpochInfo> getTableEpochs(const int32_t db_id,
241  const int32_t table_id) const;
242  void setTableEpochs(const int32_t db_id,
243  const std::vector<TableEpochInfo>& table_epochs);
245  void setTableEpochsLogExceptions(const int32_t db_id,
246  const std::vector<TableEpochInfo>& table_epochs);
248  int getDatabaseId() const { return currentDB_.dbId; }
250  void roll(const bool forward);
252  void delDictionary(const ColumnDescriptor& cd);
253  void getDictionary(const ColumnDescriptor& cd,
254  std::map<int, StringDictionary*>& stringDicts);
256  static void set(const std::string& dbName, std::shared_ptr<Catalog> cat);
257  static std::shared_ptr<Catalog> get(const std::string& dbName);
258  static std::shared_ptr<Catalog> get(const int32_t db_id);
259  static std::shared_ptr<Catalog> checkedGet(const int32_t db_id);
260  static std::shared_ptr<Catalog> get(const std::string& basePath,
261  const DBMetadata& curDB,
262  std::shared_ptr<Data_Namespace::DataMgr> dataMgr,
263  const std::vector<LeafHostInfo>& string_dict_hosts,
264  std::shared_ptr<Calcite> calcite,
265  bool is_new_db);
266  static void remove(const std::string& dbName);
268  const bool checkMetadataForDeletedRecs(const TableDescriptor* td, int column_id) const;
269  const ColumnDescriptor* getDeletedColumn(const TableDescriptor* td) const;
272  void setDeletedColumn(const TableDescriptor* td, const ColumnDescriptor* cd);
273  void setDeletedColumnUnlocked(const TableDescriptor* td, const ColumnDescriptor* cd);
274  int getLogicalTableId(const int physicalTableId) const;
275  void checkpoint(const int logicalTableId) const;
276  void checkpointWithAutoRollback(const int logical_table_id);
277  std::string name() const { return getCurrentDB().dbName; }
278  void eraseDBData();
279  void eraseTablePhysicalData(const TableDescriptor* td);
280  void vacuumDeletedRows(const TableDescriptor* td) const;
281  void vacuumDeletedRows(const int logicalTableId) const;
282  void setForReload(const int32_t tableId);
284  std::vector<std::string> getTableDataDirectories(const TableDescriptor* td) const;
285  std::vector<std::string> getTableDictDirectories(const TableDescriptor* td) const;
286  std::string getColumnDictDirectory(const ColumnDescriptor* cd) const;
287  std::string dumpSchema(const TableDescriptor* td) const;
288  std::string dumpCreateTable(const TableDescriptor* td,
289  bool multiline_formatting = true,
290  bool dump_defaults = false) const;
299  static const std::string getForeignTableSchema(bool if_not_exists = false);
308  static const std::string getForeignServerSchema(bool if_not_exists = false);
319  void createForeignServer(std::unique_ptr<foreign_storage::ForeignServer> foreign_server,
320  bool if_not_exists);
330  const std::string& server_name) const;
341  const std::unique_ptr<const foreign_storage::ForeignServer> getForeignServerFromStorage(
342  const std::string& server_name);
353  const std::unique_ptr<const foreign_storage::ForeignTable> getForeignTableFromStorage(
354  int table_id);
362  void changeForeignServerOwner(const std::string& server_name, const int new_owner_id);
370  void setForeignServerDataWrapper(const std::string& server_name,
371  const std::string& data_wrapper);
378  void setForeignServerOptions(const std::string& server_name,
379  const std::string& options);
386  void renameForeignServer(const std::string& server_name, const std::string& name);
393  void dropForeignServer(const std::string& server_name);
408  const rapidjson::Value* filters,
409  const UserMetadata& user,
410  std::vector<const foreign_storage::ForeignServer*>& results);
427  bool validateNonExistentTableOrView(const std::string& name, const bool if_not_exists);
436  std::vector<const TableDescriptor*> getAllForeignTablesForRefresh() const;
444  void updateForeignTableRefreshTimes(const int32_t table_id);
452  void setForeignTableOptions(const std::string& table_name,
453  foreign_storage::OptionsMap& options_map,
454  bool clear_existing_options = true);
456  protected:
459  void updateDictionaryNames();
462  void updateGeoColumns();
464  void updateLinkSchema();
467  void updateLogicalToPhysicalTableMap(const int32_t logical_tb_id);
468  void updateDictionarySchema();
469  void updatePageSize();
477  void buildMaps();
478  void addTableToMap(const TableDescriptor* td,
479  const std::list<ColumnDescriptor>& columns,
480  const std::list<DictDescriptor>& dicts);
481  void addReferenceToForeignDict(ColumnDescriptor& referencing_column,
482  Parser::SharedDictionaryDef shared_dict_def,
483  const bool persist_reference);
485  ColumnDescriptor& cd,
486  std::list<ColumnDescriptor>& cdd,
487  std::list<DictDescriptor>& dds,
488  const TableDescriptor td,
489  const std::vector<Parser::SharedDictionaryDef>& shared_dict_defs);
491  std::list<DictDescriptor>& dds,
492  const TableDescriptor& td,
493  const bool isLogicalTable);
496  void addLinkToMap(LinkDescriptor& ld);
497  void removeTableFromMap(const std::string& tableName,
498  const int tableId,
499  const bool is_on_error = false);
500  void doDropTable(const TableDescriptor* td);
502  void doTruncateTable(const TableDescriptor* td);
503  void renamePhysicalTable(const TableDescriptor* td, const std::string& newTableName);
504  void instantiateFragmenter(TableDescriptor* td) const;
506  std::list<const ColumnDescriptor*>& colDescs,
507  const bool fetchSystemColumns,
508  const bool fetchVirtualColumns,
509  const bool fetchPhysicalColumns) const;
510  std::string calculateSHA1(const std::string& data);
511  std::string generatePhysicalTableName(const std::string& logicalTableName,
512  const int32_t& shardNumber);
513  std::vector<DBObject> parseDashboardObjects(const std::string& view_meta,
514  const int& user_id);
515  void createOrUpdateDashboardSystemRole(const std::string& view_meta,
516  const int32_t& user_id,
517  const std::string& dash_role_name);
519  const int getColumnIdBySpiUnlocked(const int table_id, const size_t spi) const;
522  const std::list<ColumnDescriptor>& cds) const;
523  void dropTableFromJsonUnlocked(const std::string& table_name) const;
525  std::string basePath_;
539  std::shared_ptr<Data_Namespace::DataMgr> dataMgr_;
541  const std::vector<LeafHostInfo> string_dict_hosts_;
542  std::shared_ptr<Calcite> calciteMgr_;
545  static const std::string
546  physicalTableNameTag_; // extra component added to the name of each physical table
550  // this tuple is for rolling forw/back once after ALTER ADD/DEL/MODIFY columns
551  // succeeds/fails
552  // get(0) = old ColumnDescriptor*
553  // get(1) = new ColumnDescriptor*
555  std::vector<std::pair<ColumnDescriptor*, ColumnDescriptor*>>;
558  private:
559  static std::map<std::string, std::shared_ptr<Catalog>> mapd_cat_map_;
562  const std::string& temp_data_dir,
563  const std::unordered_map<int, int>& all_column_ids_map) const;
564  void renameTableDirectories(const std::string& temp_data_dir,
565  const std::vector<std::string>& target_paths,
566  const std::string& name_prefix) const;
567  void buildForeignServerMap();
568  void addForeignTableDetails();
570  void setForeignServerProperty(const std::string& server_name,
571  const std::string& property,
572  const std::string& value);
575  const std::string& property,
576  const std::string& value);
583  std::unique_ptr<foreign_storage::ForeignServer> foreign_server,
584  bool if_not_exists);
587  const std::string& tableName) const;
589  public:
590  mutable std::mutex sqliteMutex_;
592  mutable std::atomic<std::thread::id> thread_holding_sqlite_lock;
593  mutable std::atomic<std::thread::id> thread_holding_write_lock;
594  // assuming that you never call into a catalog from another catalog via the same thread
595  static thread_local bool thread_holds_read_lock;
596 };
598 } // namespace Catalog_Namespace
std::string dumpCreateTable(const TableDescriptor *td, bool multiline_formatting=true, bool dump_defaults=false) const
Definition: Catalog.cpp:4211
std::list< const ColumnDescriptor * > getAllColumnMetadataForTableUnlocked(const int tableId, const bool fetchSystemColumns, const bool fetchVirtualColumns, const bool fetchPhysicalColumns) const
Definition: Catalog.cpp:1739
void serializeTableJsonUnlocked(const TableDescriptor *td, const std::list< ColumnDescriptor > &cds) const
Definition: Catalog.cpp:2372
std::unordered_map< const TableDescriptor *, const ColumnDescriptor * > DeletedColumnPerTableMap
Definition: Types.h:46
void instantiateFragmenter(TableDescriptor *td) const
Definition: Catalog.cpp:1370
void deleteMetadataForDashboards(const std::vector< int32_t > ids, const UserMetadata &user)
Definition: Catalog.cpp:1566
void executeDropTableSqliteQueries(const TableDescriptor *td)
Definition: Catalog.cpp:3311
void renameTableDirectories(const std::string &temp_data_dir, const std::vector< std::string > &target_paths, const std::string &name_prefix) const
void eraseTablePhysicalData(const TableDescriptor *td)
Definition: Catalog.cpp:3789
void doDropTable(const TableDescriptor *td)
Definition: Catalog.cpp:3303
Destructor - deletes all ColumnDescriptor and TableDescriptor structures which were allocated on the ...
Definition: Catalog.cpp:191
void getDictionary(const ColumnDescriptor &cd, std::map< int, StringDictionary * > &stringDicts)
Definition: Catalog.cpp:1839
std::string cat(Ts &&...args)
mapd_shared_mutex sharedMutex_
Definition: Catalog.h:591
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:97
void addReferenceToForeignDict(ColumnDescriptor &referencing_column, Parser::SharedDictionaryDef shared_dict_def, const bool persist_reference)
Definition: Catalog.cpp:2981
const ColumnDescriptor * getDeletedColumn(const TableDescriptor *td) const
Definition: Catalog.cpp:2889
void setDeletedColumn(const TableDescriptor *td, const ColumnDescriptor *cd)
Definition: Catalog.cpp:2955
ColumnDescriptorMap columnDescriptorMap_
Definition: Catalog.h:528
const foreign_storage::ForeignTable * getForeignTableUnlocked(int tableId) const
Definition: Catalog.cpp:1685
void createTable(TableDescriptor &td, const std::list< ColumnDescriptor > &columns, const std::vector< Parser::SharedDictionaryDef > &shared_dict_defs, bool isLogicalTable)
Definition: Catalog.cpp:2156
void updateFrontendViewAndLinkUsers()
Definition: Catalog.cpp:408
void setTableEpochs(const int32_t db_id, const std::vector< TableEpochInfo > &table_epochs)
Definition: Catalog.cpp:2846
void createForeignServer(std::unique_ptr< foreign_storage::ForeignServer > foreign_server, bool if_not_exists)
Definition: Catalog.cpp:2466
TableEpochInfo(const int32_t table_id_param, const int32_t table_epoch_param, const size_t leaf_index_param)
Definition: Catalog.h:83
std::map< ColumnKey, ColumnDescriptor * > ColumnDescriptorMap
Definition: Types.h:37
std::map< int32_t, std::vector< int32_t >> LogicalToPhysicalTableMapById
Definition: Types.h:35
Data_Namespace::DataMgr & getDataMgr() const
Definition: Catalog.h:211
void addColumn(const TableDescriptor &td, ColumnDescriptor &cd)
Definition: Catalog.cpp:1867
void roll(const bool forward)
Definition: Catalog.cpp:1955
bool validateNonExistentTableOrView(const std::string &name, const bool if_not_exists)
Definition: Catalog.cpp:4370
std::vector< const TableDescriptor * > getAllForeignTablesForRefresh() const
Definition: Catalog.cpp:4381
const foreign_storage::ForeignServer * getForeignServer(const std::string &server_name) const
Definition: Catalog.cpp:2509
std::list< const TableDescriptor * > getAllTableMetadata() const
Definition: Catalog.cpp:1755
SqliteConnector sqliteConnector_
Definition: Catalog.h:537
const std::vector< LeafHostInfo > string_dict_hosts_
Definition: Catalog.h:541
std::vector< const TableDescriptor * > getPhysicalTablesDescriptors(const TableDescriptor *logicalTableDesc) const
Definition: Catalog.cpp:3655
DictDescriptorMapById dictDescriptorMapByRef_
Definition: Catalog.h:530
void checkpointWithAutoRollback(const int logical_table_id)
Definition: Catalog.cpp:3767
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.
Definition: Catalog.cpp:161
std::shared_ptr< Data_Namespace::DataMgr > dataMgr_
Definition: Catalog.h:539
const LinkDescriptor * getMetadataForLink(const std::string &link) const
void dropTableFromJsonUnlocked(const std::string &table_name) const
Definition: Catalog.cpp:2434
void setForReload(const int32_t tableId)
Definition: Catalog.cpp:4008
int32_t getTableEpoch(const int32_t db_id, const int32_t table_id) const
Definition: Catalog.cpp:2750
void replaceDashboard(DashboardDescriptor &vd)
Definition: Catalog.cpp:3512
std::vector< std::string > getTableDataDirectories(const TableDescriptor *td) const
Definition: Catalog.cpp:4018
std::string generatePhysicalTableName(const std::string &logicalTableName, const int32_t &shardNumber)
Definition: Catalog.cpp:3818
void dropColumn(const TableDescriptor &td, const ColumnDescriptor &cd)
Definition: Catalog.cpp:1924
void checkDateInDaysColumnMigration()
Definition: Catalog.cpp:816
void addFrontendViewToMap(DashboardDescriptor &vd)
Definition: Catalog.cpp:1280
const ColumnDescriptor * getShardColumnMetadataForTable(const TableDescriptor *td) const
Definition: Catalog.cpp:3637
void changeForeignServerOwner(const std::string &server_name, const int new_owner_id)
Definition: Catalog.cpp:2560
std::atomic< std::thread::id > thread_holding_sqlite_lock
Definition: Catalog.h:592
const foreign_storage::ForeignTable * getForeignTable(int table_id) const
Definition: Catalog.cpp:1694
void renameColumn(const TableDescriptor *td, const ColumnDescriptor *cd, const std::string &newColumnName)
Definition: Catalog.cpp:3411
DeletedColumnPerTableMap deletedColumnPerTable_
Definition: Catalog.h:560
ColumnDescriptorMapById columnDescriptorMapById_
Definition: Catalog.h:529
DashboardDescriptorMap dashboardDescriptorMap_
Definition: Catalog.h:531
void setForeignServerOptions(const std::string &server_name, const std::string &options)
Definition: Catalog.cpp:2592
std::vector< std::string > getTableNamesForUser(const UserMetadata &user, const GetTablesType get_tables_type) const
Definition: Catalog.cpp:3705
void addTableToMap(const TableDescriptor *td, const std::list< ColumnDescriptor > &columns, const std::list< DictDescriptor > &dicts)
Definition: Catalog.cpp:1139
void getAllColumnMetadataForTableImpl(const TableDescriptor *td, std::list< const ColumnDescriptor * > &colDescs, const bool fetchSystemColumns, const bool fetchVirtualColumns, const bool fetchPhysicalColumns) const
Definition: Catalog.cpp:1699
TableEpochInfo(const int32_t table_id_param, const int32_t table_epoch_param)
Definition: Catalog.h:81
void setForeignTableOptions(const std::string &table_name, foreign_storage::OptionsMap &options_map, bool clear_existing_options=true)
Definition: Catalog.cpp:4430
void recordOwnershipOfObjectsInObjectPermissions()
Definition: Catalog.cpp:688
void updateFrontendViewsToDashboards()
Definition: Catalog.cpp:120
const bool checkMetadataForDeletedRecs(const TableDescriptor *td, int column_id) const
Definition: Catalog.cpp:2895
std::string getColumnDictDirectory(const ColumnDescriptor *cd) const
Definition: Catalog.cpp:4032
std::string name() const
Definition: Catalog.h:277
std::list< const DashboardDescriptor * > getAllDashboardsMetadata() const
Definition: Catalog.cpp:1764
const ColumnDescriptor * getMetadataForColumnUnlocked(int tableId, int columnId) const
Definition: Catalog.cpp:1523
This file contains the class specification and related data structures for SysCatalog.
std::map< ColumnIdKey, ColumnDescriptor * > ColumnDescriptorMapById
Definition: Types.h:39
std::string calculateSHA1(const std::string &data)
Definition: Catalog.cpp:3586
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:210
void addLinkToMap(LinkDescriptor &ld)
Definition: Catalog.cpp:1362
std::shared_ptr< Calcite > getCalciteMgr() const
Definition: Catalog.h:212
static const std::string getForeignTableSchema(bool if_not_exists=false)
Definition: Catalog.cpp:680
std::map< int, TableDescriptor * > TableDescriptorMapById
Definition: Types.h:34
const ColumnDescriptor * getDeletedColumnIfRowsDeleted(const TableDescriptor *td) const
Definition: Catalog.cpp:2921
void adjustAlteredTableFiles(const std::string &temp_data_dir, const std::unordered_map< int, int > &all_column_ids_map) const
std::map< std::string, LinkDescriptor * > LinkDescriptorMap
Definition: Types.h:43
void delDictionary(const ColumnDescriptor &cd)
Definition: Catalog.cpp:1796
Definition: Catalog.h:60
std::shared_timed_mutex mapd_shared_mutex
void removeChunks(const int table_id)
Definition: Catalog.cpp:3249
void dropForeignServer(const std::string &server_name)
Definition: Catalog.cpp:2624
void setDeletedColumnUnlocked(const TableDescriptor *td, const ColumnDescriptor *cd)
Definition: Catalog.cpp:2960
void dropTable(const TableDescriptor *td)
Definition: Catalog.cpp:3270
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
const std::string & getBasePath() const
Definition: Catalog.h:213
static const std::string getForeignServerSchema(bool if_not_exists=false)
Definition: Catalog.cpp:673
int getDatabaseId() const
Definition: Catalog.h:248
const DashboardDescriptor * getMetadataForDashboard(const std::string &userId, const std::string &dashName) const
TableDescriptorMapById tableDescriptorMapById_
Definition: Catalog.h:527
int getLogicalTableId(const int physicalTableId) const
Definition: Catalog.cpp:3745
static std::shared_ptr< Catalog > checkedGet(const int32_t db_id)
Definition: Catalog.cpp:3846
const DictDescriptor * getMetadataForDict(int dict_ref, bool loadDict=true) const
Definition: Catalog.cpp:1460
specifies the content in-memory of a row in the column metadata table
void setForeignTableProperty(const foreign_storage::ForeignTable *table, const std::string &property, const std::string &value)
Definition: Catalog.cpp:4450
static void expandGeoColumn(const ColumnDescriptor &cd, std::list< ColumnDescriptor > &columns)
Definition: Catalog.cpp:2013
const std::vector< LeafHostInfo > & getStringDictionaryHosts() const
Definition: Catalog.cpp:1501
void createOrUpdateDashboardSystemRole(const std::string &view_meta, const int32_t &user_id, const std::string &dash_role_name)
Definition: Catalog.cpp:1321
const ColumnDescriptor * getMetadataForColumnBySpi(const int tableId, const size_t spi) const
Definition: Catalog.cpp:1556
ForeignServerMapById foreignServerMapById_
Definition: Catalog.h:535
ForeignServerMap foreignServerMap_
Definition: Catalog.h:534
void createShardedTable(TableDescriptor &td, const std::list< ColumnDescriptor > &columns, const std::vector< Parser::SharedDictionaryDef > &shared_dict_defs)
Definition: Catalog.cpp:3113
std::map< std::string, std::shared_ptr< foreign_storage::ForeignServer >> ForeignServerMap
Definition: Types.h:48
void checkpoint(const int logicalTableId) const
Definition: Catalog.cpp:3759
const DictDescriptor * getMetadataForDictUnlocked(int dict_ref, bool loadDict) const
Definition: Catalog.cpp:1466
void createForeignServerNoLocks(std::unique_ptr< foreign_storage::ForeignServer > foreign_server, bool if_not_exists)
Definition: Catalog.cpp:2474
std::vector< std::pair< ColumnDescriptor *, ColumnDescriptor * >> ColumnDescriptorsForRoll
Definition: Catalog.h:555
std::shared_ptr< Calcite > calciteMgr_
Definition: Catalog.h:542
static const std::string physicalTableNameTag_
Definition: Catalog.h:546
void addFrontendViewToMapNoLock(DashboardDescriptor &vd)
Definition: Catalog.cpp:1285
void setTableEpoch(const int db_id, const int table_id, const int new_epoch)
Definition: Catalog.cpp:2794
static void set(const std::string &dbName, std::shared_ptr< Catalog > cat)
Definition: Catalog.cpp:3825
std::vector< std::string > getTableDictDirectories(const TableDescriptor *td) const
Definition: Catalog.cpp:4048
void getForeignServersForUser(const rapidjson::Value *filters, const UserMetadata &user, std::vector< const foreign_storage::ForeignServer * > &results)
Definition: Catalog.cpp:2658
std::map< DictRef, std::unique_ptr< DictDescriptor >> DictDescriptorMapById
Definition: Types.h:40
std::map< std::string, std::shared_ptr< DashboardDescriptor >> DashboardDescriptorMap
Definition: Types.h:42
void vacuumDeletedRows(const TableDescriptor *td) const
Definition: Catalog.cpp:3883
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:1729
int32_t createDashboard(DashboardDescriptor &vd)
Definition: Catalog.cpp:3450
void removeTableFromMap(const std::string &tableName, const int tableId, const bool is_on_error=false)
Definition: Catalog.cpp:1199
std::map< int, LinkDescriptor * > LinkDescriptorMapById
Definition: Types.h:44
std::map< int, std::shared_ptr< foreign_storage::ForeignServer >> ForeignServerMapById
Definition: Types.h:50
const int getColumnIdBySpiUnlocked(const int table_id, const size_t spi) const
Definition: Catalog.cpp:1534
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:3003
void removeFragmenterForTable(const int table_id)
Definition: Catalog.cpp:3237
std::map< std::string, std::string, std::less<>> OptionsMap
void setTableEpochsLogExceptions(const int32_t db_id, const std::vector< TableEpochInfo > &table_epochs)
Definition: Catalog.cpp:2877
const TableDescriptor * getMetadataForTableImpl(int tableId, const bool populateFragmenter) const
Definition: Catalog.cpp:1437
std::string createLink(LinkDescriptor &ld, size_t min_length)
Definition: Catalog.cpp:3598
void createFsiSchemasAndDefaultServers()
Definition: Catalog.cpp:609
Descriptor for a dictionary for a string columne.
void updateLogicalToPhysicalTableLinkSchema()
Definition: Catalog.cpp:548
std::atomic< std::thread::id > thread_holding_write_lock
Definition: Catalog.h:593
void setForeignServerDataWrapper(const std::string &server_name, const std::string &data_wrapper)
Definition: Catalog.cpp:2571
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
SqliteConnector & getSqliteConnector()
Definition: Catalog.h:249
DictRef addDictionary(ColumnDescriptor &cd)
Definition: Catalog.cpp:1772
specifies the content in-memory of a row in the table metadata table
const std::unique_ptr< const foreign_storage::ForeignTable > getForeignTableFromStorage(int table_id)
Definition: Catalog.cpp:2540
void renameTable(const TableDescriptor *td, const std::string &newTableName)
Definition: Catalog.cpp:3371
LinkDescriptorMapById linkDescriptorMapById_
Definition: Catalog.h:533
static std::map< std::string, std::shared_ptr< Catalog > > mapd_cat_map_
Definition: Catalog.h:559
std::string dumpSchema(const TableDescriptor *td) const
Definition: Catalog.cpp:4064
void setColumnDictionary(ColumnDescriptor &cd, std::list< DictDescriptor > &dds, const TableDescriptor &td, const bool isLogicalTable)
Definition: Catalog.cpp:3072
void updateForeignTableRefreshTimes(const int32_t table_id)
Definition: Catalog.cpp:4405
ColumnDescriptorsForRoll columnDescriptorsForRoll
Definition: Catalog.h:556
void doTruncateTable(const TableDescriptor *td)
Definition: Catalog.cpp:3167
const std::map< int, const ColumnDescriptor * > getDictionaryToColumnMapping()
Definition: Catalog.cpp:3674
void renamePhysicalTable(const TableDescriptor *td, const std::string &newTableName)
Definition: Catalog.cpp:3345
void renameForeignServer(const std::string &server_name, const std::string &name)
Definition: Catalog.cpp:2612
std::vector< DBObject > parseDashboardObjects(const std::string &view_meta, const int &user_id)
Definition: Catalog.cpp:1291
const std::unique_ptr< const foreign_storage::ForeignServer > getForeignServerFromStorage(const std::string &server_name)
Definition: Catalog.cpp:2520
LogicalToPhysicalTableMapById logicalToPhysicalTableMapById_
Definition: Catalog.h:544
TableDescriptorMap tableDescriptorMap_
Definition: Catalog.h:526
void setForeignServerProperty(const std::string &server_name, const std::string &property, const std::string &value)
Definition: Catalog.cpp:3961
static thread_local bool thread_holds_read_lock
Definition: Catalog.h:595
std::map< std::string, TableDescriptor * > TableDescriptorMap
Definition: Types.h:33
LinkDescriptorMap linkDescriptorMap_
Definition: Catalog.h:532
void CheckAndExecuteMigrationsPostBuildMaps()
Definition: Catalog.cpp:912
std::vector< TableEpochInfo > getTableEpochs(const int32_t db_id, const int32_t table_id) const
Definition: Catalog.cpp:2818
const int getColumnIdBySpi(const int tableId, const size_t spi) const
Definition: Catalog.cpp:1551
void createDefaultServersIfNotExists()
Definition: Catalog.cpp:3982
void truncateTable(const TableDescriptor *td)
Definition: Catalog.cpp:3149
void updateLogicalToPhysicalTableMap(const int32_t logical_tb_id)
Definition: Catalog.cpp:562