14class AttachedKuzuDatabase;
19struct BoundCreateTableInfo;
20struct BoundCreateSequenceInfo;
24class VirtualFileSystem;
28struct ScalarMacroFunction;
35namespace transaction {
41class NodeTableCatalogEntry;
42class RelTableCatalogEntry;
43class RelGroupCatalogEntry;
44class RDFGraphCatalogEntry;
46class SequenceCatalogEntry;
49 friend class main::AttachedKuzuDatabase;
54 Catalog(
const std::string& directory, common::VirtualFileSystem* vfs);
61 const std::string& tableName)
const;
69 const std::string& tableName)
const;
98 const std::string& sequenceName)
const;
101 const std::string& sequenceName)
const;
108 const binder::BoundCreateSequenceInfo& info);
112 static std::string
genSerialName(
const std::string& tableName,
const std::string& propertyName);
133 std::unique_ptr<function::ScalarMacroFunction> macro);
135 const std::string& name)
const;
138 void checkpoint(
const std::string& databasePath, common::VirtualFileSystem* fs)
const;
140 template<
class TARGET>
142 return common::ku_dynamic_cast<Catalog*, TARGET*>(
this);
148 void readFromFile(
const std::string& directory, common::VirtualFileSystem* fs,
150 void saveToFile(
const std::string& directory, common::VirtualFileSystem* fs,
155 void registerBuiltInFunctions();
161 for (
auto& [_, entry] : tables->getEntries(transaction)) {
166 std::vector<T*> getTableCatalogEntries(transaction::Transaction* transaction,
167 CatalogEntryType catalogType)
const {
168 std::vector<T*> result;
169 iterateCatalogEntries(transaction, [&](CatalogEntry* entry) {
170 if (entry->getType() == catalogType) {
171 result.push_back(common::ku_dynamic_cast<CatalogEntry*, T*>(entry));
177 std::vector<common::table_id_t> getTableIDs(transaction::Transaction* transaction,
178 CatalogEntryType catalogType)
const;
180 void alterRdfChildTableEntries(transaction::Transaction* transaction, CatalogEntry* entry,
181 const binder::BoundAlterInfo& info)
const;
182 std::unique_ptr<CatalogEntry> createNodeTableEntry(transaction::Transaction* transaction,
183 common::table_id_t tableID,
const binder::BoundCreateTableInfo& info)
const;
184 std::unique_ptr<CatalogEntry> createRelTableEntry(transaction::Transaction* transaction,
185 common::table_id_t tableID,
const binder::BoundCreateTableInfo& info)
const;
186 std::unique_ptr<CatalogEntry> createRelTableGroupEntry(transaction::Transaction* transaction,
187 common::table_id_t tableID,
const binder::BoundCreateTableInfo& info);
188 std::unique_ptr<CatalogEntry> createRdfGraphEntry(transaction::Transaction* transaction,
189 common::table_id_t tableID,
const binder::BoundCreateTableInfo& info);
192 void iterateSequenceCatalogEntries(transaction::Transaction* transaction,
193 std::function<
void(CatalogEntry*)> func)
const {
194 for (
auto& [_, entry] : sequences->getEntries(transaction)) {
203 std::unique_ptr<CatalogSet> sequences;
204 std::unique_ptr<CatalogSet> functions;
205 std::unique_ptr<CatalogSet> types;
#define KUZU_API
Definition api.h:25
Definition catalog_entry.h:18
static std::string genSerialName(const std::string &tableName, const std::string &propertyName)
TableCatalogEntry * getTableCatalogEntry(transaction::Transaction *transaction, common::table_id_t tableID) const
CatalogEntry * getFunctionEntry(transaction::Transaction *transaction, const std::string &name)
std::vector< common::table_id_t > getNodeTableIDs(transaction::Transaction *transaction) const
std::vector< common::table_id_t > getRelTableIDs(transaction::Transaction *transaction) const
common::table_id_set_t getFwdRelTableIDs(transaction::Transaction *transaction, common::table_id_t nodeTableID) const
std::unique_ptr< CatalogSet > tables
Definition catalog.h:200
void checkpoint(const std::string &databasePath, common::VirtualFileSystem *fs) const
void dropTableEntry(transaction::Transaction *transaction, std::string name)
std::vector< SequenceCatalogEntry * > getSequenceEntries(transaction::Transaction *transaction) const
bool containsMacro(transaction::Transaction *transaction, const std::string ¯oName) const
void dropSequence(transaction::Transaction *transaction, std::string name)
CatalogSet * getFunctions(transaction::Transaction *transaction) const
Catalog(const std::string &directory, common::VirtualFileSystem *vfs)
common::sequence_id_t createSequence(transaction::Transaction *transaction, const binder::BoundCreateSequenceInfo &info)
bool containsTable(transaction::Transaction *transaction, const std::string &tableName) const
void dropFunction(transaction::Transaction *transaction, const std::string &name)
void alterTableEntry(transaction::Transaction *transaction, const binder::BoundAlterInfo &info)
void createType(transaction::Transaction *transaction, std::string name, common::LogicalType type)
std::vector< FunctionCatalogEntry * > getFunctionEntries(transaction::Transaction *transaction) const
common::sequence_id_t getSequenceID(transaction::Transaction *transaction, const std::string &sequenceName) const
SequenceCatalogEntry * getSequenceCatalogEntry(transaction::Transaction *transaction, common::sequence_id_t sequenceID) const
std::vector< RelGroupCatalogEntry * > getRelTableGroupEntries(transaction::Transaction *transaction) const
std::vector< std::string > getMacroNames(transaction::Transaction *transaction) const
bool containsType(transaction::Transaction *transaction, const std::string &typeName)
void dropSequence(transaction::Transaction *transaction, common::sequence_id_t sequenceID)
std::vector< TableCatalogEntry * > getTableEntries(transaction::Transaction *transaction, const common::table_id_vector_t &tableIDs) const
common::table_id_set_t getBwdRelTableIDs(transaction::Transaction *transaction, common::table_id_t nodeTableID) const
common::table_id_t createTableSchema(transaction::Transaction *transaction, const binder::BoundCreateTableInfo &info)
bool tableInRelGroup(transaction::Transaction *transaction, common::table_id_t tableID) const
std::vector< RDFGraphCatalogEntry * > getRdfGraphEntries(transaction::Transaction *transaction) const
virtual ~Catalog()=default
void addFunction(transaction::Transaction *transaction, CatalogEntryType entryType, std::string name, function::function_set functionSet)
bool tableInRDFGraph(transaction::Transaction *transaction, common::table_id_t tableID) const
common::table_id_t getTableID(transaction::Transaction *transaction, const std::string &tableName) const
function::ScalarMacroFunction * getScalarMacroFunction(transaction::Transaction *transaction, const std::string &name) const
void addScalarMacroFunction(transaction::Transaction *transaction, std::string name, std::unique_ptr< function::ScalarMacroFunction > macro)
TARGET * ptrCast()
Definition catalog.h:141
std::string getTableName(transaction::Transaction *transaction, common::table_id_t tableID) const
void dropTableEntry(transaction::Transaction *transaction, common::table_id_t tableID)
TableCatalogEntry * getTableCatalogEntry(transaction::Transaction *transaction, const std::string &tableName) const
void addBuiltInFunction(CatalogEntryType entryType, std::string name, function::function_set functionSet)
std::vector< TableCatalogEntry * > getTableEntries(transaction::Transaction *transaction) const
std::vector< RelTableCatalogEntry * > getRelTableEntries(transaction::Transaction *transaction) const
bool containsSequence(transaction::Transaction *transaction, const std::string &sequenceName) const
common::LogicalType getType(transaction::Transaction *, std::string name)
std::vector< NodeTableCatalogEntry * > getNodeTableEntries(transaction::Transaction *transaction) const
Definition catalog_set.h:24
Definition function_catalog_entry.h:9
Definition table_catalog_entry.h:24
Contain client side configuration. We make profiler associated per query, so profiler is not maintain...
Definition client_context.h:51
Definition transaction.h:28
CatalogEntryType
Definition catalog_entry_type.h:9
FileVersionType
Definition types.h:556
std::unordered_set< table_id_t > table_id_set_t
Definition internal_id_t.h:16
uint64_t table_id_t
Definition internal_id_t.h:14
std::vector< table_id_t > table_id_vector_t
Definition internal_id_t.h:15
uint64_t sequence_id_t
Definition types.h:55
std::vector< std::unique_ptr< Function > > function_set
Definition function.h:43
Definition bind_input.h:10
Definition alter_type.h:5
Definition bound_alter_info.h:25
Definition bound_create_table_info.h:35