Skip to content

Commit

Permalink
Run clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
andyfengHKU committed Aug 19, 2024
1 parent 18041a8 commit 4e36d27
Show file tree
Hide file tree
Showing 25 changed files with 121 additions and 109 deletions.
18 changes: 11 additions & 7 deletions src/binder/bind/bind_ddl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ BoundCreateTableInfo Binder::bindCreateNodeTableInfo(const CreateTableInfo& info
std::move(boundExtraInfo));
}

static PropertyDefinition getDefinition(const std::vector<PropertyDefinition>& definitions, const std::string& name) {
static PropertyDefinition getDefinition(const std::vector<PropertyDefinition>& definitions,
const std::string& name) {
for (auto& definition : definitions) {
if (definition.getName() == name) {
return definition.copy();
Expand All @@ -164,14 +165,17 @@ BoundCreateTableInfo Binder::bindCreateExternalNodeTableInfo(const CreateTableIn
auto pkDefinition = getDefinition(propertyDefinitions, extraInfo.pkName);
std::vector<PropertyDefinition> physicalPropertyDefinitions;
physicalPropertyDefinitions.push_back(pkDefinition.copy());
auto boundPhysicalExtraInfo = std::make_unique<BoundExtraCreateNodeTableInfo>(extraInfo.pkName, std::move(physicalPropertyDefinitions));
auto boundPhysicalCreateInfo = BoundCreateTableInfo(TableType::NODE,
getPhysicalTableName(info.tableName), ConflictAction::ON_CONFLICT_THROW,
std::move(boundPhysicalExtraInfo));
auto boundPhysicalExtraInfo = std::make_unique<BoundExtraCreateNodeTableInfo>(extraInfo.pkName,
std::move(physicalPropertyDefinitions));
auto boundPhysicalCreateInfo =
BoundCreateTableInfo(TableType::NODE, getPhysicalTableName(info.tableName),
ConflictAction::ON_CONFLICT_THROW, std::move(boundPhysicalExtraInfo));
// Bind create node table reference info
auto boundExtraInfo = std::make_unique<BoundExtraCreateExternalNodeTableInfo>(extraInfo.pkName,
extraInfo.dbName, extraInfo.tableName, std::move(boundPhysicalCreateInfo), copyVector(propertyDefinitions));
return BoundCreateTableInfo(TableType::EXTERNAL_NODE, info.tableName, info.onConflict, std::move(boundExtraInfo));
extraInfo.dbName, extraInfo.tableName, std::move(boundPhysicalCreateInfo),
copyVector(propertyDefinitions));
return BoundCreateTableInfo(TableType::EXTERNAL_NODE, info.tableName, info.onConflict,
std::move(boundExtraInfo));
}

BoundCreateTableInfo Binder::bindCreateRelTableInfo(const CreateTableInfo& info) {
Expand Down
15 changes: 8 additions & 7 deletions src/binder/bind/bind_external.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "binder/binder.h"
#include "main/database_manager.h"
#include "catalog/catalog_entry/external_node_table_catalog_entry.h"
#include "common/exception/binder.h"
#include "main/client_context.h"
#include "catalog/catalog_entry/external_node_table_catalog_entry.h"
#include "main/database_manager.h"

using namespace kuzu::common;
using namespace kuzu::catalog;
Expand All @@ -23,19 +23,20 @@ catalog::TableCatalogEntry* Binder::bindExternalTableEntry(const std::string& db

void Binder::bindExternalTableEntry(NodeOrRelExpression& nodeOrRel) {
if (nodeOrRel.isMultiLabeled() || nodeOrRel.isEmpty()) {
return ;
return;
}
auto entry = nodeOrRel.getSingleEntry();
switch (entry->getType()) {
case CatalogEntryType::EXTERNAL_NODE_TABLE_ENTRY: {
auto& tableEntry = entry->constCast<ExternalNodeTableCatalogEntry>();
auto externalEntry = bindExternalTableEntry(tableEntry.getExternalDBName(), tableEntry.getExternalTableName());
auto externalEntry = bindExternalTableEntry(tableEntry.getExternalDBName(),
tableEntry.getExternalTableName());
nodeOrRel.setExternalEntry(externalEntry);
} break ;
} break;
default:
break;
}
}

}
}
} // namespace binder
} // namespace kuzu
8 changes: 4 additions & 4 deletions src/binder/bind/bind_graph_pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
#include "catalog/catalog_entry/rdf_graph_catalog_entry.h"
#include "catalog/catalog_entry/rel_group_catalog_entry.h"
#include "catalog/catalog_entry/rel_table_catalog_entry.h"
#include "common/distinct_vector.h"
#include "common/exception/binder.h"
#include "common/keyword/rdf_keyword.h"
#include "common/string_format.h"
#include "function/cast/functions/cast_from_string_functions.h"
#include "main/client_context.h"
#include "common/distinct_vector.h"

using namespace kuzu::common;
using namespace kuzu::parser;
Expand Down Expand Up @@ -286,15 +286,15 @@ std::shared_ptr<RelExpression> Binder::createNonRecursiveQueryRel(const std::str
for (auto& tableID : rdfGraphTableIDSet) {
auto entry = catalog->getTableCatalogEntry(transaction, tableID);
auto& rdfGraphEntry = entry->constCast<RDFGraphCatalogEntry>();
resourceEntries.push_back(catalog->getTableCatalogEntry(transaction, rdfGraphEntry.getResourceTableID()));
resourceEntries.push_back(
catalog->getTableCatalogEntry(transaction, rdfGraphEntry.getResourceTableID()));
}
auto pID =
expressionBinder.bindNodeOrRelPropertyExpression(*queryRel, std::string(rdf::PID));
auto rdfInfo = std::make_unique<RdfPredicateInfo>(resourceEntries, std::move(pID));
queryRel->setRdfPredicateInfo(std::move(rdfInfo));
// Mock existence of pIRI property.
auto pIRI =
createPropertyExpression(std::string(rdf::IRI), *queryRel, resourceEntries);
auto pIRI = createPropertyExpression(std::string(rdf::IRI), *queryRel, resourceEntries);
queryRel->addPropertyExpression(std::string(rdf::IRI), std::move(pIRI));
}
std::vector<StructField> fields;
Expand Down
2 changes: 1 addition & 1 deletion src/binder/bind/copy/bind_copy_from.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "binder/binder.h"
#include "binder/copy/bound_copy_from.h"
#include "catalog/catalog.h"
#include "catalog/catalog_entry/external_node_table_catalog_entry.h"
#include "catalog/catalog_entry/node_table_catalog_entry.h"
#include "catalog/catalog_entry/rdf_graph_catalog_entry.h"
#include "catalog/catalog_entry/rel_table_catalog_entry.h"
#include "catalog/catalog_entry/external_node_table_catalog_entry.h"
#include "common/enums/table_type.h"
#include "common/exception/binder.h"
#include "common/string_format.h"
Expand Down
3 changes: 2 additions & 1 deletion src/binder/bind/ddl/bound_create_table_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ void BoundExtraCreateExternalNodeTableInfo::serialize(Serializer& serializer) co
physicalInfo.serialize(serializer);
}

std::unique_ptr<BoundExtraCreateExternalNodeTableInfo> BoundExtraCreateExternalNodeTableInfo::deserialize(Deserializer& deserializer) {
std::unique_ptr<BoundExtraCreateExternalNodeTableInfo>
BoundExtraCreateExternalNodeTableInfo::deserialize(Deserializer& deserializer) {
std::string primaryKeyName;
std::string externalDBName;
std::string externalTableName;
Expand Down
10 changes: 4 additions & 6 deletions src/catalog/catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ table_id_t Catalog::createTableEntry(Transaction* transaction, const BoundCreate
} break;
case TableType::EXTERNAL_NODE: {
entry = createExternalNodeTableEntry(transaction, info);
} break ;
} break;
case TableType::REL: {
entry = createRelTableEntry(transaction, info);
} break;
Expand Down Expand Up @@ -531,14 +531,13 @@ std::unique_ptr<TableCatalogEntry> Catalog::createNodeTableEntry(Transaction*,
return nodeTableEntry;
}


std::unique_ptr<TableCatalogEntry> Catalog::createExternalNodeTableEntry(Transaction* transaction,
const BoundCreateTableInfo& info) const {
const BoundCreateTableInfo& info) const {
auto extraInfo = info.extraInfo->constPtrCast<BoundExtraCreateExternalNodeTableInfo>();
auto physicalEntry = createNodeTableEntry(transaction, extraInfo->physicalInfo);
auto entry = std::make_unique<ExternalNodeTableCatalogEntry>(tables.get(), info.tableName,
extraInfo->externalDBName, extraInfo->externalTableName,
std::move(physicalEntry), extraInfo->primaryKeyName);
extraInfo->externalDBName, extraInfo->externalTableName, std::move(physicalEntry),
extraInfo->primaryKeyName);
entry->addProperties(extraInfo->propertyDefinitions);
return entry;
}
Expand All @@ -554,7 +553,6 @@ std::unique_ptr<TableCatalogEntry> Catalog::createRelTableEntry(Transaction*,
return relTableEntry;
}


std::unique_ptr<TableCatalogEntry> Catalog::createRelTableGroupEntry(Transaction* transaction,
const BoundCreateTableInfo& info) {
auto extraInfo = info.extraInfo->ptrCast<BoundExtraCreateRelTableGroupInfo>();
Expand Down
15 changes: 9 additions & 6 deletions src/catalog/catalog_entry/external_node_table_catalog_entry.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "catalog/catalog_entry/external_node_table_catalog_entry.h"

#include "common/serializer/deserializer.h"
#include "binder/ddl/bound_create_table_info.h"
#include "common/serializer/deserializer.h"

using namespace kuzu::binder;
using namespace kuzu::common;
Expand All @@ -15,7 +15,8 @@ void ExternalNodeTableCatalogEntry::serialize(Serializer& serializer) const {
serializer.write(primaryKeyName);
}

std::unique_ptr<ExternalNodeTableCatalogEntry> ExternalNodeTableCatalogEntry::deserialize(Deserializer& deserializer) {
std::unique_ptr<ExternalNodeTableCatalogEntry> ExternalNodeTableCatalogEntry::deserialize(
Deserializer& deserializer) {
std::string primaryKeyName;
deserializer.deserializeValue(primaryKeyName);
auto entry = std::make_unique<ExternalNodeTableCatalogEntry>();
Expand All @@ -30,10 +31,12 @@ std::unique_ptr<TableCatalogEntry> ExternalNodeTableCatalogEntry::copy() const {
return result;
}

std::unique_ptr<binder::BoundExtraCreateCatalogEntryInfo> ExternalNodeTableCatalogEntry::getBoundExtraCreateInfo(Transaction* transaction) const {
std::unique_ptr<binder::BoundExtraCreateCatalogEntryInfo>
ExternalNodeTableCatalogEntry::getBoundExtraCreateInfo(Transaction* transaction) const {
return std::make_unique<BoundExtraCreateExternalNodeTableInfo>(primaryKeyName, externalDBName,
externalTableName, physicalEntry->getBoundCreateTableInfo(transaction), copyVector(getProperties()));
externalTableName, physicalEntry->getBoundCreateTableInfo(transaction),
copyVector(getProperties()));
}

}
}
} // namespace catalog
} // namespace kuzu
9 changes: 4 additions & 5 deletions src/catalog/catalog_entry/external_table_catalog_entry.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "catalog/catalog_entry/external_table_catalog_entry.h"

#include "catalog/catalog_entry/external_node_table_catalog_entry.h"
#include "common/serializer/deserializer.h"

Expand Down Expand Up @@ -34,7 +35,7 @@ std::unique_ptr<ExternalTableCatalogEntry> ExternalTableCatalogEntry::deserializ
switch (type) {
case CatalogEntryType::EXTERNAL_NODE_TABLE_ENTRY: {
entry = ExternalNodeTableCatalogEntry::deserialize(deserializer);
} break ;
} break;
default:
KU_UNREACHABLE;
}
Expand All @@ -44,7 +45,5 @@ std::unique_ptr<ExternalTableCatalogEntry> ExternalTableCatalogEntry::deserializ
return entry;
}



}
}
} // namespace catalog
} // namespace kuzu
7 changes: 4 additions & 3 deletions src/catalog/catalog_entry/table_catalog_entry.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "catalog/catalog_entry/table_catalog_entry.h"

#include "binder/ddl/bound_alter_info.h"
#include "catalog/catalog_entry/external_table_catalog_entry.h"
#include "catalog/catalog_entry/node_table_catalog_entry.h"
#include "catalog/catalog_entry/rdf_graph_catalog_entry.h"
#include "catalog/catalog_entry/rel_group_catalog_entry.h"
#include "catalog/catalog_entry/rel_table_catalog_entry.h"
#include "catalog/catalog_entry/external_table_catalog_entry.h"
#include "common/serializer/deserializer.h"

using namespace kuzu::binder;
Expand Down Expand Up @@ -77,7 +77,8 @@ common::column_id_t TableCatalogEntry::getColumnID(const std::string& propertyNa
return propertyCollection.getColumnID(propertyName);
}

void TableCatalogEntry::addProperties(const std::vector<binder::PropertyDefinition>& propertyDefinitions) {
void TableCatalogEntry::addProperties(
const std::vector<binder::PropertyDefinition>& propertyDefinitions) {
for (auto& definition : propertyDefinitions) {
propertyCollection.add(definition);
}
Expand Down Expand Up @@ -119,7 +120,7 @@ std::unique_ptr<TableCatalogEntry> TableCatalogEntry::deserialize(
} break;
case CatalogEntryType::EXTERNAL_NODE_TABLE_ENTRY: {
result = ExternalTableCatalogEntry::deserialize(deserializer, type);
} break ;
} break;
case CatalogEntryType::REL_TABLE_ENTRY: {
result = RelTableCatalogEntry::deserialize(deserializer);
} break;
Expand Down
2 changes: 1 addition & 1 deletion src/catalog/catalog_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include "binder/ddl/bound_alter_info.h"
#include "catalog/catalog_entry/dummy_catalog_entry.h"
#include "catalog/catalog_entry/table_catalog_entry.h"
#include "catalog/catalog_entry/external_node_table_catalog_entry.h"
#include "catalog/catalog_entry/table_catalog_entry.h"
#include "common/assert.h"
#include "common/exception/catalog.h"
#include "common/serializer/deserializer.h"
Expand Down
2 changes: 1 addition & 1 deletion src/include/binder/ddl/bound_create_table_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct BoundExtraCreateExternalNodeTableInfo : public BoundExtraCreateTableInfo
return std::make_unique<BoundExtraCreateExternalNodeTableInfo>(*this);
}

void serialize(common::Serializer &serializer) const override;
void serialize(common::Serializer& serializer) const override;
static std::unique_ptr<BoundExtraCreateExternalNodeTableInfo> deserialize(
common::Deserializer& deserializer);
};
Expand Down
12 changes: 3 additions & 9 deletions src/include/binder/expression/node_rel_expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,9 @@ class NodeOrRelExpression : public Expression {
void addEntries(const std::vector<catalog::TableCatalogEntry*> entries_);
catalog::TableCatalogEntry* getSingleEntry() const;

void setExternalEntry(catalog::TableCatalogEntry* entry) {
externalEntry = entry;
}
bool hasExternalEntry() const {
return externalEntry != nullptr;
}
catalog::TableCatalogEntry* getExternalEntry() const {
return externalEntry;
}
void setExternalEntry(catalog::TableCatalogEntry* entry) { externalEntry = entry; }
bool hasExternalEntry() const { return externalEntry != nullptr; }
catalog::TableCatalogEntry* getExternalEntry() const { return externalEntry; }

void addPropertyExpression(const std::string& propertyName,
std::unique_ptr<Expression> property);
Expand Down
8 changes: 4 additions & 4 deletions src/include/catalog/catalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ class KUZU_API Catalog {
const binder::BoundAlterInfo& info) const;
std::unique_ptr<TableCatalogEntry> createNodeTableEntry(transaction::Transaction* transaction,
const binder::BoundCreateTableInfo& info) const;
std::unique_ptr<TableCatalogEntry> createExternalNodeTableEntry(transaction::Transaction* transaction,
const binder::BoundCreateTableInfo& info) const;
std::unique_ptr<TableCatalogEntry> createExternalNodeTableEntry(
transaction::Transaction* transaction, const binder::BoundCreateTableInfo& info) const;
std::unique_ptr<TableCatalogEntry> createRelTableEntry(transaction::Transaction* transaction,
const binder::BoundCreateTableInfo& info) const;
std::unique_ptr<TableCatalogEntry> createRelTableGroupEntry(transaction::Transaction* transaction,
const binder::BoundCreateTableInfo& info);
std::unique_ptr<TableCatalogEntry> createRelTableGroupEntry(
transaction::Transaction* transaction, const binder::BoundCreateTableInfo& info);
std::unique_ptr<TableCatalogEntry> createRdfGraphEntry(transaction::Transaction* transaction,
const binder::BoundCreateTableInfo& info);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ namespace catalog {

class ExternalNodeTableCatalogEntry : public ExternalTableCatalogEntry {
static constexpr CatalogEntryType entryType_ = CatalogEntryType::EXTERNAL_NODE_TABLE_ENTRY;

public:
ExternalNodeTableCatalogEntry() = default;
ExternalNodeTableCatalogEntry(CatalogSet* set, std::string name, std::string externalDBName,
std::string externalTableName, std::unique_ptr<TableCatalogEntry> physicalEntry,
std::string primaryKeyName)
: ExternalTableCatalogEntry{set, entryType_, name, externalDBName, externalTableName,
std::move(physicalEntry)}, primaryKeyName{std::move(primaryKeyName)} {}
std::move(physicalEntry)},
primaryKeyName{std::move(primaryKeyName)} {}

common::TableType getTableType() const override {
return common::TableType::EXTERNAL_NODE;
}
common::TableType getTableType() const override { return common::TableType::EXTERNAL_NODE; }

void serialize(common::Serializer& serializer) const override;
static std::unique_ptr<ExternalNodeTableCatalogEntry> deserialize(common::Deserializer& deserializer);
static std::unique_ptr<ExternalNodeTableCatalogEntry> deserialize(
common::Deserializer& deserializer);

std::unique_ptr<TableCatalogEntry> copy() const override;

Expand All @@ -32,5 +33,5 @@ class ExternalNodeTableCatalogEntry : public ExternalTableCatalogEntry {
std::string primaryKeyName;
};

}
}
} // namespace catalog
} // namespace kuzu
27 changes: 12 additions & 15 deletions src/include/catalog/catalog_entry/external_table_catalog_entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,25 @@ class ExternalTableCatalogEntry : public TableCatalogEntry {
std::string externalDBName, std::string externalTableName,
std::unique_ptr<TableCatalogEntry> physicalEntry)
: TableCatalogEntry{set, entryType, std::move(name)},
externalDBName{std::move(externalDBName)}, externalTableName{std::move(externalTableName)}, physicalEntry{std::move(physicalEntry)} {}

std::string getExternalDBName() const {
return externalDBName;
}
std::string getExternalTableName() const {
return externalTableName;
}
TableCatalogEntry* getPhysicalEntry() const {
return physicalEntry.get();
externalDBName{std::move(externalDBName)},
externalTableName{std::move(externalTableName)}, physicalEntry{std::move(physicalEntry)} {
}

void copyFrom(const CatalogEntry &other) override;
std::string getExternalDBName() const { return externalDBName; }
std::string getExternalTableName() const { return externalTableName; }
TableCatalogEntry* getPhysicalEntry() const { return physicalEntry.get(); }

void copyFrom(const CatalogEntry& other) override;

void serialize(common::Serializer &serializer) const override;
static std::unique_ptr<ExternalTableCatalogEntry> deserialize(common::Deserializer& deserializer, CatalogEntryType type);
void serialize(common::Serializer& serializer) const override;
static std::unique_ptr<ExternalTableCatalogEntry> deserialize(
common::Deserializer& deserializer, CatalogEntryType type);

protected:
std::string externalDBName;
std::string externalTableName;
std::unique_ptr<TableCatalogEntry> physicalEntry;
};

}
}
} // namespace catalog
} // namespace kuzu
Loading

0 comments on commit 4e36d27

Please sign in to comment.