Kùzu C++ API
Loading...
Searching...
No Matches
table_catalog_entry.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include "bound_alter_info.h"
7#include "catalog_entry.h"
8#include "property.h"
9#include "table_type.h"
10#include "table_functions.h"
11
12namespace kuzu {
13namespace binder {
14struct BoundExtraCreateCatalogEntryInfo;
15} // namespace binder
16
17namespace transaction {
18class Transaction;
19} // namespace transaction
20
21namespace catalog {
22
23class CatalogSet;
25public:
26 //===--------------------------------------------------------------------===//
27 // constructors
28 //===--------------------------------------------------------------------===//
29 TableCatalogEntry() = default;
30 TableCatalogEntry(CatalogSet* set, CatalogEntryType catalogType, std::string name,
31 common::table_id_t tableID)
32 : CatalogEntry{catalogType, std::move(name)}, set{set}, tableID{tableID}, nextPID{0},
33 nextColumnID{0} {}
35
36 std::unique_ptr<TableCatalogEntry> alter(const binder::BoundAlterInfo& alterInfo);
37
38 //===--------------------------------------------------------------------===//
39 // getter & setter
40 //===--------------------------------------------------------------------===//
41 common::table_id_t getTableID() const { return tableID; }
42 std::string getComment() const { return comment; }
43 void setComment(std::string newComment) { comment = std::move(newComment); }
44 virtual bool isParent(common::table_id_t /*tableID*/) { return false; };
45 virtual common::TableType getTableType() const = 0;
47 binder::BoundAlterInfo* getAlterInfo() const { return alterInfo.get(); }
48 void resetAlterInfo() { alterInfo = nullptr; }
49 void setAlterInfo(const binder::BoundAlterInfo& alterInfo_) {
50 alterInfo = std::make_unique<binder::BoundAlterInfo>(alterInfo_.copy());
51 }
52
53 //===--------------------------------------------------------------------===//
54 // properties functions
55 //===--------------------------------------------------------------------===//
56 uint32_t getNumProperties() const { return properties.size(); }
57 const std::vector<Property>& getPropertiesRef() const { return properties; }
58 std::vector<Property>& getPropertiesUnsafe() { return properties; }
59 bool containProperty(const std::string& propertyName) const;
60 common::property_id_t getPropertyID(const std::string& propertyName) const;
61 const Property* getProperty(common::property_id_t propertyID) const;
62 uint32_t getPropertyPos(common::property_id_t propertyID) const;
64 void addProperty(std::string propertyName, common::LogicalType dataType,
65 std::unique_ptr<parser::ParsedExpression> defaultExpr);
67 void renameProperty(common::property_id_t propertyID, const std::string& newName);
69
70 //===--------------------------------------------------------------------===//
71 // serialization & deserialization
72 //===--------------------------------------------------------------------===//
73 void serialize(common::Serializer& serializer) const override;
74 static std::unique_ptr<TableCatalogEntry> deserialize(common::Deserializer& deserializer,
75 CatalogEntryType type);
76 virtual std::unique_ptr<TableCatalogEntry> copy() const = 0;
77
79 transaction::Transaction* transaction) const;
80
81protected:
82 void copyFrom(const CatalogEntry& other) override;
83 virtual std::unique_ptr<binder::BoundExtraCreateCatalogEntryInfo> getBoundExtraCreateInfo(
84 transaction::Transaction* transaction) const = 0;
85
86protected:
89 std::string comment;
92 std::vector<Property> properties;
93 std::unique_ptr<binder::BoundAlterInfo> alterInfo;
94};
95
97 std::size_t operator()(TableCatalogEntry* entry) const {
98 return std::hash<common::table_id_t>{}(entry->getTableID());
99 }
100};
101
104 return left->getTableID() == right->getTableID();
105 }
106};
107
109 std::unordered_set<TableCatalogEntry*, TableCatalogEntryHasher, TableCatalogEntryEquality>;
110
111} // namespace catalog
112} // namespace kuzu
#define KUZU_API
Definition api.h:25
#define KU_UNREACHABLE
Definition assert.h:28
Definition catalog_entry.h:18
Definition catalog_set.h:24
Definition property.h:15
Definition table_catalog_entry.h:24
std::string comment
Definition table_catalog_entry.h:89
void renameProperty(common::property_id_t propertyID, const std::string &newName)
common::property_id_t getPropertyID(const std::string &propertyName) const
common::column_id_t nextColumnID
Definition table_catalog_entry.h:91
std::string getComment() const
Definition table_catalog_entry.h:42
const Property * getProperty(common::property_id_t propertyID) const
uint32_t getPropertyPos(common::property_id_t propertyID) const
std::unique_ptr< TableCatalogEntry > alter(const binder::BoundAlterInfo &alterInfo)
virtual common::column_id_t getColumnID(common::property_id_t propertyID) const
static std::unique_ptr< TableCatalogEntry > deserialize(common::Deserializer &deserializer, CatalogEntryType type)
void serialize(common::Serializer &serializer) const override
virtual common::TableType getTableType() const =0
virtual std::unique_ptr< binder::BoundExtraCreateCatalogEntryInfo > getBoundExtraCreateInfo(transaction::Transaction *transaction) const =0
TableCatalogEntry(CatalogSet *set, CatalogEntryType catalogType, std::string name, common::table_id_t tableID)
Definition table_catalog_entry.h:30
virtual bool isParent(common::table_id_t)
Definition table_catalog_entry.h:44
void addProperty(std::string propertyName, common::LogicalType dataType, std::unique_ptr< parser::ParsedExpression > defaultExpr)
void resetColumnIDs()
TableCatalogEntry()=default
void setComment(std::string newComment)
Definition table_catalog_entry.h:43
const std::vector< Property > & getPropertiesRef() const
Definition table_catalog_entry.h:57
std::vector< Property > & getPropertiesUnsafe()
Definition table_catalog_entry.h:58
virtual std::unique_ptr< TableCatalogEntry > copy() const =0
uint32_t getNumProperties() const
Definition table_catalog_entry.h:56
std::unique_ptr< binder::BoundAlterInfo > alterInfo
Definition table_catalog_entry.h:93
binder::BoundCreateTableInfo getBoundCreateTableInfo(transaction::Transaction *transaction) const
TableCatalogEntry & operator=(const TableCatalogEntry &)=delete
virtual function::TableFunction getScanFunction()
Definition table_catalog_entry.h:46
common::table_id_t tableID
Definition table_catalog_entry.h:88
common::property_id_t nextPID
Definition table_catalog_entry.h:90
CatalogSet * set
Definition table_catalog_entry.h:87
common::table_id_t getTableID() const
Definition table_catalog_entry.h:41
void dropProperty(common::property_id_t propertyID)
void copyFrom(const CatalogEntry &other) override
bool containProperty(const std::string &propertyName) const
void setAlterInfo(const binder::BoundAlterInfo &alterInfo_)
Definition table_catalog_entry.h:49
binder::BoundAlterInfo * getAlterInfo() const
Definition table_catalog_entry.h:47
void resetAlterInfo()
Definition table_catalog_entry.h:48
std::vector< Property > properties
Definition table_catalog_entry.h:92
Definition deserializer.h:15
Definition types.h:201
Definition serializer.h:15
Definition transaction.h:28
std::unordered_set< TableCatalogEntry *, TableCatalogEntryHasher, TableCatalogEntryEquality > table_catalog_entry_set_t
Definition table_catalog_entry.h:108
CatalogEntryType
Definition catalog_entry_type.h:9
property_id_t column_id_t
Definition types.h:36
uint32_t property_id_t
Definition types.h:34
uint64_t table_id_t
Definition internal_id_t.h:14
TableType
Definition table_type.h:10
Definition alter_type.h:5
Definition bound_alter_info.h:25
Definition bound_create_table_info.h:35
Definition table_catalog_entry.h:102
bool operator()(TableCatalogEntry *left, TableCatalogEntry *right) const
Definition table_catalog_entry.h:103
Definition table_catalog_entry.h:96
std::size_t operator()(TableCatalogEntry *entry) const
Definition table_catalog_entry.h:97
Definition table_functions.h:78