OmniSciDB  94e8789169
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Catalog.h
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  * http://www.apache.org/licenses/LICENSE-2.0
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  */
16 
29 #pragma once
30 
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>
41 
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/TableMetadata.h"
53 #include "Catalog/Types.h"
54 #include "DataMgr/DataMgr.h"
58 
59 #include "LeafHostInfo.h"
60 
62 
63 namespace Parser {
64 
66 
67 } // namespace Parser
68 
69 class TableArchiver;
70 
71 // SPI means Sequential Positional Index which is equivalent to the input index in a
72 // RexInput node
73 #define SPIMAP_MAGIC1 (std::numeric_limits<unsigned>::max() / 4)
74 #define SPIMAP_MAGIC2 8
75 #define SPIMAP_GEO_PHYSICAL_INPUT(c, i) \
76  (SPIMAP_MAGIC1 + (unsigned)(SPIMAP_MAGIC2 * ((c) + 1) + (i)))
77 
78 namespace File_Namespace {
79 struct FileMgrParams;
80 }
81 namespace Catalog_Namespace {
84 
85  TableEpochInfo(const int32_t table_id_param, const int32_t table_epoch_param)
86  : table_id(table_id_param), table_epoch(table_epoch_param) {}
87  TableEpochInfo(const int32_t table_id_param,
88  const int32_t table_epoch_param,
89  const size_t leaf_index_param)
90  : table_id(table_id_param)
91  , table_epoch(table_epoch_param)
92  , leaf_index(leaf_index_param) {}
93 };
94 
101 class Catalog final {
102  public:
111  Catalog(const std::string& basePath,
112  const DBMetadata& curDB,
113  std::shared_ptr<Data_Namespace::DataMgr> dataMgr,
114  const std::vector<LeafHostInfo>& string_dict_hosts,
115  std::shared_ptr<Calcite> calcite,
116  bool is_new_db);
121  Catalog();
122 
129  ~Catalog();
130 
131  static void expandGeoColumn(const ColumnDescriptor& cd,
132  std::list<ColumnDescriptor>& columns);
133  void createTable(TableDescriptor& td,
134  const std::list<ColumnDescriptor>& columns,
135  const std::vector<Parser::SharedDictionaryDef>& shared_dict_defs,
136  bool isLogicalTable);
137  void createShardedTable(
138  TableDescriptor& td,
139  const std::list<ColumnDescriptor>& columns,
140  const std::vector<Parser::SharedDictionaryDef>& shared_dict_defs);
143  std::string createLink(LinkDescriptor& ld, size_t min_length);
144  void dropTable(const TableDescriptor* td);
145  void truncateTable(const TableDescriptor* td);
146  void renameTable(const TableDescriptor* td, const std::string& newTableName);
147  void renameColumn(const TableDescriptor* td,
148  const ColumnDescriptor* cd,
149  const std::string& newColumnName);
150  void addColumn(const TableDescriptor& td, ColumnDescriptor& cd);
151  void dropColumn(const TableDescriptor& td, const ColumnDescriptor& cd);
152  void removeChunks(const int table_id);
153  void removeFragmenterForTable(const int table_id);
154 
155  const std::map<int, const ColumnDescriptor*> getDictionaryToColumnMapping();
156 
165  const TableDescriptor* getMetadataForTable(const std::string& tableName,
166  const bool populateFragmenter = true) const;
167  const TableDescriptor* getMetadataForTableImpl(int tableId,
168  const bool populateFragmenter) const;
169  const TableDescriptor* getMetadataForTable(int tableId,
170  bool populateFragmenter = true) const;
171 
172  const ColumnDescriptor* getMetadataForColumn(int tableId,
173  const std::string& colName) const;
174  const ColumnDescriptor* getMetadataForColumn(int tableId, int columnId) const;
175  const ColumnDescriptor* getMetadataForColumnUnlocked(int tableId, int columnId) const;
176 
177  const int getColumnIdBySpi(const int tableId, const size_t spi) const;
178  const ColumnDescriptor* getMetadataForColumnBySpi(const int tableId,
179  const size_t spi) const;
180 
181  const DashboardDescriptor* getMetadataForDashboard(const std::string& userId,
182  const std::string& dashName) const;
183 
184  const DashboardDescriptor* getMetadataForDashboard(const int32_t dashboard_id) const;
185  void deleteMetadataForDashboards(const std::vector<int32_t> ids,
186  const UserMetadata& user);
187 
188  const LinkDescriptor* getMetadataForLink(const std::string& link) const;
189  const LinkDescriptor* getMetadataForLink(int linkId) const;
190 
191  const foreign_storage::ForeignTable* getForeignTableUnlocked(int tableId) const;
193  const std::string& tableName) const;
194 
195  const foreign_storage::ForeignTable* getForeignTable(int table_id) const;
196 
205  std::list<const ColumnDescriptor*> getAllColumnMetadataForTable(
206  const int tableId,
207  const bool fetchSystemColumns,
208  const bool fetchVirtualColumns,
209  const bool fetchPhysicalColumns) const;
213  std::list<const ColumnDescriptor*> getAllColumnMetadataForTableUnlocked(
214  const int tableId,
215  const bool fetchSystemColumns,
216  const bool fetchVirtualColumns,
217  const bool fetchPhysicalColumns) const;
218 
219  std::list<const TableDescriptor*> getAllTableMetadata() const;
220  std::list<const DashboardDescriptor*> getAllDashboardsMetadata() const;
221  const DBMetadata& getCurrentDB() const { return currentDB_; }
223  std::shared_ptr<Calcite> getCalciteMgr() const { return calciteMgr_; }
224  const std::string& getBasePath() const { return basePath_; }
225 
226  const DictDescriptor* getMetadataForDict(int dict_ref, bool loadDict = true) const;
227  const DictDescriptor* getMetadataForDictUnlocked(int dict_ref, bool loadDict) const;
228 
229  const std::vector<LeafHostInfo>& getStringDictionaryHosts() const;
230 
232 
233  std::vector<const TableDescriptor*> getPhysicalTablesDescriptors(
234  const TableDescriptor* logicalTableDesc) const;
235 
244  std::vector<std::string> getTableNamesForUser(
245  const UserMetadata& user,
246  const GetTablesType get_tables_type) const;
247 
257  std::vector<TableMetadata> getTablesMetadataForUser(
258  const UserMetadata& user_metadata,
259  const GetTablesType get_tables_type,
260  const std::string& filter_table_name) const;
261 
262  int32_t getTableEpoch(const int32_t db_id, const int32_t table_id) const;
263  void setTableEpoch(const int db_id, const int table_id, const int new_epoch);
264  void setMaxRollbackEpochs(const int32_t table_id, const int32_t max_rollback_epochs);
265 
266  std::vector<TableEpochInfo> getTableEpochs(const int32_t db_id,
267  const int32_t table_id) const;
268  void setTableEpochs(const int32_t db_id,
269  const std::vector<TableEpochInfo>& table_epochs);
270 
271  void setTableEpochsLogExceptions(const int32_t db_id,
272  const std::vector<TableEpochInfo>& table_epochs);
273 
274  int getDatabaseId() const { return currentDB_.dbId; }
276  void roll(const bool forward);
278  void delDictionary(const ColumnDescriptor& cd);
279  void getDictionary(const ColumnDescriptor& cd,
280  std::map<int, StringDictionary*>& stringDicts);
281 
282  const bool checkMetadataForDeletedRecs(const TableDescriptor* td, int column_id) const;
283  const ColumnDescriptor* getDeletedColumn(const TableDescriptor* td) const;
285 
286  void setDeletedColumn(const TableDescriptor* td, const ColumnDescriptor* cd);
287  void setDeletedColumnUnlocked(const TableDescriptor* td, const ColumnDescriptor* cd);
288  int getLogicalTableId(const int physicalTableId) const;
289  void checkpoint(const int logicalTableId) const;
290  void checkpointWithAutoRollback(const int logical_table_id);
291  std::string name() const { return getCurrentDB().dbName; }
292  void eraseDBData();
293  void eraseTablePhysicalData(const TableDescriptor* td);
294  void vacuumDeletedRows(const TableDescriptor* td) const;
295  void vacuumDeletedRows(const int logicalTableId) const;
296  void setForReload(const int32_t tableId);
297 
298  std::vector<std::string> getTableDataDirectories(const TableDescriptor* td) const;
299  std::vector<std::string> getTableDictDirectories(const TableDescriptor* td) const;
300  std::string getColumnDictDirectory(const ColumnDescriptor* cd) const;
301  std::string dumpSchema(const TableDescriptor* td) const;
302  std::string dumpCreateTable(const TableDescriptor* td,
303  bool multiline_formatting = true,
304  bool dump_defaults = false) const;
305 
313  static const std::string getForeignTableSchema(bool if_not_exists = false);
314 
322  static const std::string getForeignServerSchema(bool if_not_exists = false);
323 
333  void createForeignServer(std::unique_ptr<foreign_storage::ForeignServer> foreign_server,
334  bool if_not_exists);
335 
344  const std::string& server_name) const;
345 
355  const std::unique_ptr<const foreign_storage::ForeignServer> getForeignServerFromStorage(
356  const std::string& server_name);
357 
367  const std::unique_ptr<const foreign_storage::ForeignTable> getForeignTableFromStorage(
368  int table_id);
369 
376  void changeForeignServerOwner(const std::string& server_name, const int new_owner_id);
377 
384  void setForeignServerDataWrapper(const std::string& server_name,
385  const std::string& data_wrapper);
392  void setForeignServerOptions(const std::string& server_name,
393  const std::string& options);
400  void renameForeignServer(const std::string& server_name, const std::string& name);
401 
407  void dropForeignServer(const std::string& server_name);
408 
422  const rapidjson::Value* filters,
423  const UserMetadata& user,
424  std::vector<const foreign_storage::ForeignServer*>& results);
425 
430 
441  bool validateNonExistentTableOrView(const std::string& name, const bool if_not_exists);
442 
450  std::vector<const TableDescriptor*> getAllForeignTablesForRefresh() const;
451 
458  void updateForeignTableRefreshTimes(const int32_t table_id);
459 
466  void setForeignTableOptions(const std::string& table_name,
467  foreign_storage::OptionsMap& options_map,
468  bool clear_existing_options = true);
469 
470  void updateLeaf(const LeafHostInfo& string_dict_host);
471 
472  protected:
475  void updateDictionaryNames();
478  void updateGeoColumns();
480  void updateLinkSchema();
483  void updateLogicalToPhysicalTableMap(const int32_t logical_tb_id);
484  void updateDictionarySchema();
485  void updatePageSize();
488  void createFsiSchemas();
493  void buildMaps();
494  void addTableToMap(const TableDescriptor* td,
495  const std::list<ColumnDescriptor>& columns,
496  const std::list<DictDescriptor>& dicts);
497  void addReferenceToForeignDict(ColumnDescriptor& referencing_column,
498  Parser::SharedDictionaryDef shared_dict_def,
499  const bool persist_reference);
501  ColumnDescriptor& cd,
502  std::list<ColumnDescriptor>& cdd,
503  std::list<DictDescriptor>& dds,
504  const TableDescriptor td,
505  const std::vector<Parser::SharedDictionaryDef>& shared_dict_defs);
507  std::list<DictDescriptor>& dds,
508  const TableDescriptor& td,
509  const bool isLogicalTable);
512  void addLinkToMap(LinkDescriptor& ld);
513  void removeTableFromMap(const std::string& tableName,
514  const int tableId,
515  const bool is_on_error = false);
516  void doDropTable(const TableDescriptor* td);
518  void doTruncateTable(const TableDescriptor* td);
519  void renamePhysicalTable(const TableDescriptor* td, const std::string& newTableName);
520  void instantiateFragmenter(TableDescriptor* td) const;
522  std::list<const ColumnDescriptor*>& colDescs,
523  const bool fetchSystemColumns,
524  const bool fetchVirtualColumns,
525  const bool fetchPhysicalColumns) const;
526  std::string calculateSHA1(const std::string& data);
527  std::string generatePhysicalTableName(const std::string& logicalTableName,
528  const int32_t& shardNumber);
529  std::vector<DBObject> parseDashboardObjects(const std::string& view_meta,
530  const int& user_id);
531  void createOrUpdateDashboardSystemRole(const std::string& view_meta,
532  const int32_t& user_id,
533  const std::string& dash_role_name);
534 
535  const int getColumnIdBySpiUnlocked(const int table_id, const size_t spi) const;
536 
538  const std::list<ColumnDescriptor>& cds) const;
539  void dropTableFromJsonUnlocked(const std::string& table_name) const;
540 
541  std::string basePath_;
552 
555  std::shared_ptr<Data_Namespace::DataMgr> dataMgr_;
556 
557  const std::vector<LeafHostInfo> string_dict_hosts_;
558  std::shared_ptr<Calcite> calciteMgr_;
559 
561  static const std::string
562  physicalTableNameTag_; // extra component added to the name of each physical table
565 
566  // this tuple is for rolling forw/back once after ALTER ADD/DEL/MODIFY columns
567  // succeeds/fails
568  // get(0) = old ColumnDescriptor*
569  // get(1) = new ColumnDescriptor*
571  std::vector<std::pair<ColumnDescriptor*, ColumnDescriptor*>>;
573 
574  private:
577  const std::string& temp_data_dir,
578  const std::unordered_map<int, int>& all_column_ids_map) const;
579  void renameTableDirectories(const std::string& temp_data_dir,
580  const std::vector<std::string>& target_paths,
581  const std::string& name_prefix) const;
582  void buildForeignServerMap();
583  void addForeignTableDetails();
584 
585  void setForeignServerProperty(const std::string& server_name,
586  const std::string& property,
587  const std::string& value);
588 
590  const std::string& property,
591  const std::string& value);
592 
594  const TableDescriptorUpdateParams& table_update_params);
595  void alterTableMetadata(const TableDescriptor* td,
596  const TableDescriptorUpdateParams& table_update_params);
597  void setTableFileMgrParams(const int table_id,
598  const File_Namespace::FileMgrParams& file_mgr_params);
600  const UserMetadata& user_metadata,
601  const GetTablesType get_tables_type) const;
602 
604 
610  std::unique_ptr<foreign_storage::ForeignServer> foreign_server,
611  bool if_not_exists);
612 
614  const std::string& tableName) const;
615 
616  const Catalog* getObjForLock();
617 
618  public:
619  mutable std::mutex sqliteMutex_;
621  mutable std::atomic<std::thread::id> thread_holding_sqlite_lock;
622  mutable std::atomic<std::thread::id> thread_holding_write_lock;
623  // assuming that you never call into a catalog from another catalog via the same thread
624  static thread_local bool thread_holds_read_lock;
625  bool initialized_ = false;
626 };
627 
628 } // namespace Catalog_Namespace
std::string dumpCreateTable(const TableDescriptor *td, bool multiline_formatting=true, bool dump_defaults=false) const
Definition: Catalog.cpp:4333
std::list< const ColumnDescriptor * > getAllColumnMetadataForTableUnlocked(const int tableId, const bool fetchSystemColumns, const bool fetchVirtualColumns, const bool fetchPhysicalColumns) const
Definition: Catalog.cpp:1730
void serializeTableJsonUnlocked(const TableDescriptor *td, const std::list< ColumnDescriptor > &cds) const
Definition: Catalog.cpp:2364
std::unordered_map< const TableDescriptor *, const ColumnDescriptor * > DeletedColumnPerTableMap
Definition: Types.h:46
void instantiateFragmenter(TableDescriptor *td) const
Definition: Catalog.cpp:1347
const foreign_storage::ForeignTable * getForeignTable(const std::string &tableName) const
Definition: Catalog.cpp:1397
void deleteMetadataForDashboards(const std::vector< int32_t > ids, const UserMetadata &user)
Definition: Catalog.cpp:1557
void executeDropTableSqliteQueries(const TableDescriptor *td)
Definition: Catalog.cpp:3446
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:3958
void doDropTable(const TableDescriptor *td)
Definition: Catalog.cpp:3438
~Catalog()
Destructor - deletes all ColumnDescriptor and TableDescriptor structures which were allocated on the ...
Definition: Catalog.cpp:195
void getDictionary(const ColumnDescriptor &cd, std::map< int, StringDictionary * > &stringDicts)
Definition: Catalog.cpp:1830
mapd_shared_mutex sharedMutex_
Definition: Catalog.h:620
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:101
void addReferenceToForeignDict(ColumnDescriptor &referencing_column, Parser::SharedDictionaryDef shared_dict_def, const bool persist_reference)
Definition: Catalog.cpp:3118
const ColumnDescriptor * getDeletedColumn(const TableDescriptor *td) const
Definition: Catalog.cpp:3026
void setDeletedColumn(const TableDescriptor *td, const ColumnDescriptor *cd)
Definition: Catalog.cpp:3092
ColumnDescriptorMap columnDescriptorMap_
Definition: Catalog.h:544
const foreign_storage::ForeignTable * getForeignTableUnlocked(int tableId) const
Definition: Catalog.cpp:1676
void createTable(TableDescriptor &td, const std::list< ColumnDescriptor > &columns, const std::vector< Parser::SharedDictionaryDef > &shared_dict_defs, bool isLogicalTable)
Definition: Catalog.cpp:2147
void updateFrontendViewAndLinkUsers()
Definition: Catalog.cpp:426
void setTableEpochs(const int32_t db_id, const std::vector< TableEpochInfo > &table_epochs)
Definition: Catalog.cpp:2977
void createForeignServer(std::unique_ptr< foreign_storage::ForeignServer > foreign_server, bool if_not_exists)
Definition: Catalog.cpp:2458
TableEpochInfo(const int32_t table_id_param, const int32_t table_epoch_param, const size_t leaf_index_param)
Definition: Catalog.h:87
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:222
void addColumn(const TableDescriptor &td, ColumnDescriptor &cd)
Definition: Catalog.cpp:1858
void roll(const bool forward)
Definition: Catalog.cpp:1946
bool validateNonExistentTableOrView(const std::string &name, const bool if_not_exists)
Definition: Catalog.cpp:4496
void setTableFileMgrParams(const int table_id, const File_Namespace::FileMgrParams &file_mgr_params)
Definition: Catalog.cpp:2914
std::vector< const TableDescriptor * > getAllForeignTablesForRefresh() const
Definition: Catalog.cpp:4507
const foreign_storage::ForeignServer * getForeignServer(const std::string &server_name) const
Definition: Catalog.cpp:2503
std::list< const TableDescriptor * > getAllTableMetadata() const
Definition: Catalog.cpp:1746
SqliteConnector sqliteConnector_
Definition: Catalog.h:553
const std::vector< LeafHostInfo > string_dict_hosts_
Definition: Catalog.h:557
const DBMetadata currentDB_
Definition: Catalog.h:554
std::vector< const TableDescriptor * > getPhysicalTablesDescriptors(const TableDescriptor *logicalTableDesc) const
Definition: Catalog.cpp:3791
DictDescriptorMapById dictDescriptorMapByRef_
Definition: Catalog.h:546
void checkpointWithAutoRollback(const int logical_table_id)
Definition: Catalog.cpp:3936
std::shared_ptr< Data_Namespace::DataMgr > dataMgr_
Definition: Catalog.h:555
const LinkDescriptor * getMetadataForLink(const std::string &link) const
void dropTableFromJsonUnlocked(const std::string &table_name) const
Definition: Catalog.cpp:2426
void setForReload(const int32_t tableId)
Definition: Catalog.cpp:4126
int32_t getTableEpoch(const int32_t db_id, const int32_t table_id) const
Definition: Catalog.cpp:2745
void replaceDashboard(DashboardDescriptor &vd)
Definition: Catalog.cpp:3647
std::vector< std::string > getTableDataDirectories(const TableDescriptor *td) const
Definition: Catalog.cpp:4136
std::string generatePhysicalTableName(const std::string &logicalTableName, const int32_t &shardNumber)
Definition: Catalog.cpp:3987
void dropColumn(const TableDescriptor &td, const ColumnDescriptor &cd)
Definition: Catalog.cpp:1915
void checkDateInDaysColumnMigration()
Definition: Catalog.cpp:783
void addFrontendViewToMap(DashboardDescriptor &vd)
Definition: Catalog.cpp:1253
std::vector< TableMetadata > getTablesMetadataForUser(const UserMetadata &user_metadata, const GetTablesType get_tables_type, const std::string &filter_table_name) const
Definition: Catalog.cpp:3890
const ColumnDescriptor * getShardColumnMetadataForTable(const TableDescriptor *td) const
Definition: Catalog.cpp:3773
void changeForeignServerOwner(const std::string &server_name, const int new_owner_id)
Definition: Catalog.cpp:2555
std::atomic< std::thread::id > thread_holding_sqlite_lock
Definition: Catalog.h:621
void renameColumn(const TableDescriptor *td, const ColumnDescriptor *cd, const std::string &newColumnName)
Definition: Catalog.cpp:3546
DeletedColumnPerTableMap deletedColumnPerTable_
Definition: Catalog.h:575
ColumnDescriptorMapById columnDescriptorMapById_
Definition: Catalog.h:545
DashboardDescriptorMap dashboardDescriptorMap_
Definition: Catalog.h:547
void setForeignServerOptions(const std::string &server_name, const std::string &options)
Definition: Catalog.cpp:2587
std::vector< std::string > getTableNamesForUser(const UserMetadata &user, const GetTablesType get_tables_type) const
Definition: Catalog.cpp:3874
void addTableToMap(const TableDescriptor *td, const std::list< ColumnDescriptor > &columns, const std::list< DictDescriptor > &dicts)
Definition: Catalog.cpp:1112
void getAllColumnMetadataForTableImpl(const TableDescriptor *td, std::list< const ColumnDescriptor * > &colDescs, const bool fetchSystemColumns, const bool fetchVirtualColumns, const bool fetchPhysicalColumns) const
Definition: Catalog.cpp:1690
TableEpochInfo(const int32_t table_id_param, const int32_t table_epoch_param)
Definition: Catalog.h:85
void setForeignTableOptions(const std::string &table_name, foreign_storage::OptionsMap &options_map, bool clear_existing_options=true)
Definition: Catalog.cpp:4556
void recordOwnershipOfObjectsInObjectPermissions()
Definition: Catalog.cpp:655
void updateFrontendViewsToDashboards()
Definition: Catalog.cpp:120
bool filterTableByTypeAndUser(const TableDescriptor *td, const UserMetadata &user_metadata, const GetTablesType get_tables_type) const
Definition: Catalog.cpp:3841
const bool checkMetadataForDeletedRecs(const TableDescriptor *td, int column_id) const
Definition: Catalog.cpp:3032
std::string getColumnDictDirectory(const ColumnDescriptor *cd) const
Definition: Catalog.cpp:4150
std::string name() const
Definition: Catalog.h:291
std::list< const DashboardDescriptor * > getAllDashboardsMetadata() const
Definition: Catalog.cpp:1755
void updateLeaf(const LeafHostInfo &string_dict_host)
const ColumnDescriptor * getMetadataForColumnUnlocked(int tableId, int columnId) const
Definition: Catalog.cpp:1514
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:3722
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:221
void addLinkToMap(LinkDescriptor &ld)
Definition: Catalog.cpp:1339
std::shared_ptr< Calcite > getCalciteMgr() const
Definition: Catalog.h:223
static const std::string getForeignTableSchema(bool if_not_exists=false)
Definition: Catalog.cpp:647
std::map< int, TableDescriptor * > TableDescriptorMapById
Definition: Types.h:34
const ColumnDescriptor * getDeletedColumnIfRowsDeleted(const TableDescriptor *td) const
Definition: Catalog.cpp:3058
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:1787
GetTablesType
Definition: Catalog.h:61
std::shared_timed_mutex mapd_shared_mutex
void removeChunks(const int table_id)
Definition: Catalog.cpp:3387
void dropForeignServer(const std::string &server_name)
Definition: Catalog.cpp:2619
void setDeletedColumnUnlocked(const TableDescriptor *td, const ColumnDescriptor *cd)
Definition: Catalog.cpp:3097
void dropTable(const TableDescriptor *td)
Definition: Catalog.cpp:3405
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
const std::string & getBasePath() const
Definition: Catalog.h:224
static const std::string getForeignServerSchema(bool if_not_exists=false)
Definition: Catalog.cpp:640
int getDatabaseId() const
Definition: Catalog.h:274
const DashboardDescriptor * getMetadataForDashboard(const std::string &userId, const std::string &dashName) const
TableDescriptorMapById tableDescriptorMapById_
Definition: Catalog.h:543
int getLogicalTableId(const int physicalTableId) const
Definition: Catalog.cpp:3914
const DictDescriptor * getMetadataForDict(int dict_ref, bool loadDict=true) const
Definition: Catalog.cpp:1443
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:4576
static void expandGeoColumn(const ColumnDescriptor &cd, std::list< ColumnDescriptor > &columns)
Definition: Catalog.cpp:2004
const std::vector< LeafHostInfo > & getStringDictionaryHosts() const
Definition: Catalog.cpp:1492
void createOrUpdateDashboardSystemRole(const std::string &view_meta, const int32_t &user_id, const std::string &dash_role_name)
Definition: Catalog.cpp:1294
const ColumnDescriptor * getMetadataForColumnBySpi(const int tableId, const size_t spi) const
Definition: Catalog.cpp:1547
ForeignServerMapById foreignServerMapById_
Definition: Catalog.h:551
void alterPhysicalTableMetadata(const TableDescriptor *td, const TableDescriptorUpdateParams &table_update_params)
Definition: Catalog.cpp:2840
ForeignServerMap foreignServerMap_
Definition: Catalog.h:550
void createShardedTable(TableDescriptor &td, const std::list< ColumnDescriptor > &columns, const std::vector< Parser::SharedDictionaryDef > &shared_dict_defs)
Definition: Catalog.cpp:3250
std::map< std::string, std::shared_ptr< foreign_storage::ForeignServer >> ForeignServerMap
Definition: Types.h:48
void checkpoint(const int logicalTableId) const
Definition: Catalog.cpp:3928
const DictDescriptor * getMetadataForDictUnlocked(int dict_ref, bool loadDict) const
Definition: Catalog.cpp:1457
void createForeignServerNoLocks(std::unique_ptr< foreign_storage::ForeignServer > foreign_server, bool if_not_exists)
Definition: Catalog.cpp:2466
std::vector< std::pair< ColumnDescriptor *, ColumnDescriptor * >> ColumnDescriptorsForRoll
Definition: Catalog.h:571
std::shared_ptr< Calcite > calciteMgr_
Definition: Catalog.h:558
static const std::string physicalTableNameTag_
Definition: Catalog.h:562
void addFrontendViewToMapNoLock(DashboardDescriptor &vd)
Definition: Catalog.cpp:1258
void setTableEpoch(const int db_id, const int table_id, const int new_epoch)
Definition: Catalog.cpp:2796
void alterTableMetadata(const TableDescriptor *td, const TableDescriptorUpdateParams &table_update_params)
Definition: Catalog.cpp:2859
TableDescriptor * getMutableMetadataForTableUnlocked(int tableId)
Definition: Catalog.cpp:1449
std::vector< std::string > getTableDictDirectories(const TableDescriptor *td) const
Definition: Catalog.cpp:4166
void getForeignServersForUser(const rapidjson::Value *filters, const UserMetadata &user, std::vector< const foreign_storage::ForeignServer * > &results)
Definition: Catalog.cpp:2653
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:4003
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:1720
const Catalog * getObjForLock()
Definition: Catalog.cpp:220
int32_t createDashboard(DashboardDescriptor &vd)
Definition: Catalog.cpp:3585
void removeTableFromMap(const std::string &tableName, const int tableId, const bool is_on_error=false)
Definition: Catalog.cpp:1172
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:1525
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:3140
void removeFragmenterForTable(const int table_id)
Definition: Catalog.cpp:3375
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:3014
void setMaxRollbackEpochs(const int32_t table_id, const int32_t max_rollback_epochs)
Definition: Catalog.cpp:2884
const TableDescriptor * getMetadataForTableImpl(int tableId, const bool populateFragmenter) const
Definition: Catalog.cpp:1420
std::string createLink(LinkDescriptor &ld, size_t min_length)
Definition: Catalog.cpp:3734
Descriptor for a dictionary for a string columne.
void updateLogicalToPhysicalTableLinkSchema()
Definition: Catalog.cpp:566
std::atomic< std::thread::id > thread_holding_write_lock
Definition: Catalog.h:622
void setForeignServerDataWrapper(const std::string &server_name, const std::string &data_wrapper)
Definition: Catalog.cpp:2566
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:275
DictRef addDictionary(ColumnDescriptor &cd)
Definition: Catalog.cpp:1763
const std::unique_ptr< const foreign_storage::ForeignTable > getForeignTableFromStorage(int table_id)
Definition: Catalog.cpp:2535
void renameTable(const TableDescriptor *td, const std::string &newTableName)
Definition: Catalog.cpp:3506
LinkDescriptorMapById linkDescriptorMapById_
Definition: Catalog.h:549
std::string dumpSchema(const TableDescriptor *td) const
Definition: Catalog.cpp:4182
void setColumnDictionary(ColumnDescriptor &cd, std::list< DictDescriptor > &dds, const TableDescriptor &td, const bool isLogicalTable)
Definition: Catalog.cpp:3209
void updateForeignTableRefreshTimes(const int32_t table_id)
Definition: Catalog.cpp:4531
ColumnDescriptorsForRoll columnDescriptorsForRoll
Definition: Catalog.h:572
void doTruncateTable(const TableDescriptor *td)
Definition: Catalog.cpp:3305
const std::map< int, const ColumnDescriptor * > getDictionaryToColumnMapping()
Definition: Catalog.cpp:3810
void renamePhysicalTable(const TableDescriptor *td, const std::string &newTableName)
Definition: Catalog.cpp:3480
void renameForeignServer(const std::string &server_name, const std::string &name)
Definition: Catalog.cpp:2607
std::vector< DBObject > parseDashboardObjects(const std::string &view_meta, const int &user_id)
Definition: Catalog.cpp:1264
const std::unique_ptr< const foreign_storage::ForeignServer > getForeignServerFromStorage(const std::string &server_name)
Definition: Catalog.cpp:2515
LogicalToPhysicalTableMapById logicalToPhysicalTableMapById_
Definition: Catalog.h:560
Catalog()
Constructor builds a hollow catalog used during constructor of other catalogs.
Definition: Catalog.cpp:193
TableDescriptorMap tableDescriptorMap_
Definition: Catalog.h:542
void setForeignServerProperty(const std::string &server_name, const std::string &property, const std::string &value)
Definition: Catalog.cpp:4081
static thread_local bool thread_holds_read_lock
Definition: Catalog.h:624
std::map< std::string, TableDescriptor * > TableDescriptorMap
Definition: Types.h:33
LinkDescriptorMap linkDescriptorMap_
Definition: Catalog.h:548
void CheckAndExecuteMigrationsPostBuildMaps()
Definition: Catalog.cpp:884
std::vector< TableEpochInfo > getTableEpochs(const int32_t db_id, const int32_t table_id) const
Definition: Catalog.cpp:2949
const int getColumnIdBySpi(const int tableId, const size_t spi) const
Definition: Catalog.cpp:1542
void createDefaultServersIfNotExists()
Definition: Catalog.cpp:4102
void truncateTable(const TableDescriptor *td)
Definition: Catalog.cpp:3287
void updateLogicalToPhysicalTableMap(const int32_t logical_tb_id)
Definition: Catalog.cpp:580