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 12, 2024
1 parent 814de09 commit f116668
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 51 deletions.
42 changes: 24 additions & 18 deletions src/binder/bind/bind_graph_pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,9 @@ std::shared_ptr<RelExpression> Binder::bindQueryRel(const RelPattern& relPattern
}

std::shared_ptr<RelExpression> Binder::createNonRecursiveQueryRel(const std::string& parsedName,
const std::vector<catalog::TableCatalogEntry*>& entries, std::shared_ptr<NodeExpression> srcNode,
std::shared_ptr<NodeExpression> dstNode, RelDirectionType directionType) {
const std::vector<catalog::TableCatalogEntry*>& entries,
std::shared_ptr<NodeExpression> srcNode, std::shared_ptr<NodeExpression> dstNode,
RelDirectionType directionType) {
auto relTableEntries = getRelTableEntries(entries);
auto queryRel = make_shared<RelExpression>(LogicalType(LogicalTypeID::REL),
getUniqueExpressionName(parsedName), parsedName, relTableEntries, std::move(srcNode),
Expand Down Expand Up @@ -277,11 +278,9 @@ std::shared_ptr<RelExpression> Binder::createNonRecursiveQueryRel(const std::str
if (!rdfGraphTableIDSet.empty()) {
if (!nonRdfRelTableIDSet.empty()) {
auto relTableName =
catalog->getTableCatalogEntry(transaction, *nonRdfRelTableIDSet.begin())
->getName();
catalog->getTableCatalogEntry(transaction, *nonRdfRelTableIDSet.begin())->getName();
auto rdfGraphName =
catalog->getTableCatalogEntry(transaction, *rdfGraphTableIDSet.begin())
->getName();
catalog->getTableCatalogEntry(transaction, *rdfGraphTableIDSet.begin())->getName();
throw BinderException(stringFormat(
"Relationship pattern {} contains both PropertyGraph relationship "
"label {} and RDFGraph label {}. Mixing relationships tables from an RDFGraph and "
Expand All @@ -300,8 +299,7 @@ std::shared_ptr<RelExpression> Binder::createNonRecursiveQueryRel(const std::str
queryRel->setRdfPredicateInfo(std::move(rdfInfo));
std::vector<TableCatalogEntry*> resourceTableSchemas;
for (auto tableID : resourceTableIDs) {
resourceTableSchemas.push_back(
catalog->getTableCatalogEntry(transaction, tableID));
resourceTableSchemas.push_back(catalog->getTableCatalogEntry(transaction, tableID));
}
// Mock existence of pIRI property.
auto pIRI =
Expand Down Expand Up @@ -338,8 +336,9 @@ static void bindRecursiveRelProjectionList(const expression_vector& projectionLi
}

std::shared_ptr<RelExpression> Binder::createRecursiveQueryRel(const parser::RelPattern& relPattern,
const std::vector<catalog::TableCatalogEntry*>& entries, std::shared_ptr<NodeExpression> srcNode,
std::shared_ptr<NodeExpression> dstNode, RelDirectionType directionType) {
const std::vector<catalog::TableCatalogEntry*>& entries,
std::shared_ptr<NodeExpression> srcNode, std::shared_ptr<NodeExpression> dstNode,
RelDirectionType directionType) {
auto catalog = clientContext->getCatalog();
auto transaction = clientContext->getTx();
auto relTableEntries = getRelTableEntries(entries);
Expand Down Expand Up @@ -630,7 +629,9 @@ std::vector<TableCatalogEntry*> Binder::bindTableEntries(const std::vector<std::
for (auto entry : entrySet) {
entries.push_back(entry);
}
std::sort(entries.begin(), entries.end(), [](TableCatalogEntry* a, TableCatalogEntry* b){ return a->getTableID() < b->getTableID(); });
std::sort(entries.begin(), entries.end(), [](TableCatalogEntry* a, TableCatalogEntry* b) {
return a->getTableID() < b->getTableID();
});
return entries;
}

Expand All @@ -647,26 +648,29 @@ common::table_id_t Binder::bindTableID(const std::string& tableName) const {
return bindTableEntry(tableName)->getTableID();
}

std::vector<TableCatalogEntry*> Binder::getNodeTableEntries(const std::vector<TableCatalogEntry*>& entries) const {
std::vector<TableCatalogEntry*> Binder::getNodeTableEntries(
const std::vector<TableCatalogEntry*>& entries) const {
return getTableEntries(entries, TableType::NODE);
}

std::vector<TableCatalogEntry*> Binder::getRelTableEntries(const std::vector<TableCatalogEntry*>& entries) const {
std::vector<TableCatalogEntry*> Binder::getRelTableEntries(
const std::vector<TableCatalogEntry*>& entries) const {
return getTableEntries(entries, TableType::REL);
}

std::vector<TableCatalogEntry*> Binder::getTableEntries(const std::vector<TableCatalogEntry*>& entries, TableType tableType) const {
std::vector<TableCatalogEntry*> Binder::getTableEntries(
const std::vector<TableCatalogEntry*>& entries, TableType tableType) const {
std::vector<TableCatalogEntry*> result;
table_id_set_t set;
for (auto& entry : entries) {
std::vector<TableCatalogEntry*> expandedEntries;
switch (tableType) {
case TableType::NODE: {
expandedEntries = getNodeTableEntries(entry);
} break ;
} break;
case TableType::REL: {
expandedEntries = getRelTableEntries(entry);
} break ;
} break;
default:
break;
}
Expand Down Expand Up @@ -698,8 +702,10 @@ std::vector<TableCatalogEntry*> Binder::getRelTableEntries(TableCatalogEntry* en
switch (entry->getTableType()) {
case TableType::RDF: {
auto& rdfEntry = entry->constCast<RDFGraphCatalogEntry>();
auto rtEntry = catalog->getTableCatalogEntry(transaction, rdfEntry.getResourceTripleTableID());
auto ltEntry = catalog->getTableCatalogEntry(transaction, rdfEntry.getLiteralTripleTableID());
auto rtEntry =
catalog->getTableCatalogEntry(transaction, rdfEntry.getResourceTripleTableID());
auto ltEntry =
catalog->getTableCatalogEntry(transaction, rdfEntry.getLiteralTripleTableID());
return {rtEntry, ltEntry};
}
case TableType::REL_GROUP: {
Expand Down
4 changes: 2 additions & 2 deletions src/binder/bind/bind_updating_clause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ void Binder::bindInsertRel(std::shared_ptr<RelExpression> rel,
} else {
auto insertInfo = BoundInsertInfo(TableType::REL, rel);
insertInfo.columnExprs = rel->getPropertyExprs();
insertInfo.columnDataExprs = bindInsertColumnDataExprs(rel->getPropertyDataExprRef(),
entry->getPropertiesRef());
insertInfo.columnDataExprs =
bindInsertColumnDataExprs(rel->getPropertyDataExprRef(), entry->getPropertiesRef());
infos.push_back(std::move(insertInfo));
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/binder/bind_expression/bind_function_expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ std::shared_ptr<Expression> ExpressionBinder::bindLabelFunction(const Expression
return createLiteralExpression("");
}
if (!node.isMultiLabeled()) {
auto labelName = catalog->getTableName(context->getTx(), node.getSingleEntry()->getTableID());
auto labelName =
catalog->getTableName(context->getTx(), node.getSingleEntry()->getTableID());
return createLiteralExpression(Value(LogicalType::STRING(), labelName));
}
auto nodeTableIDs = catalog->getNodeTableIDs(context->getTx());
Expand All @@ -276,7 +277,8 @@ std::shared_ptr<Expression> ExpressionBinder::bindLabelFunction(const Expression
return createLiteralExpression("");
}
if (!rel.isMultiLabeled()) {
auto labelName = catalog->getTableName(context->getTx(), rel.getSingleEntry()->getTableID());
auto labelName =
catalog->getTableName(context->getTx(), rel.getSingleEntry()->getTableID());
return createLiteralExpression(Value(LogicalType::STRING(), labelName));
}
auto relTableIDs = catalog->getRelTableIDs(context->getTx());
Expand Down
2 changes: 1 addition & 1 deletion src/binder/expression/node_rel_expression.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "binder/expression/node_rel_expression.h"

#include "common/exception/runtime.h"
#include "catalog/catalog_entry/table_catalog_entry.h"
#include "common/exception/runtime.h"

using namespace kuzu::catalog;
using namespace kuzu::common;
Expand Down
3 changes: 2 additions & 1 deletion src/catalog/catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ TableCatalogEntry* Catalog::getTableCatalogEntry(Transaction* transaction,
return result;
}

TableCatalogEntry* Catalog::getTableCatalogEntry(Transaction* transaction, const std::string& tableName) const {
TableCatalogEntry* Catalog::getTableCatalogEntry(Transaction* transaction,
const std::string& tableName) const {
auto entry = tables->getEntry(transaction, tableName);
// LCOV_EXCL_START
if (entry == nullptr) {
Expand Down
3 changes: 2 additions & 1 deletion src/function/gds/gds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ void GDSAlgorithm::init(GDSCallSharedState* sharedState_, ClientContext* context
}

std::shared_ptr<Expression> GDSAlgorithm::bindNodeOutput(Binder* binder, GraphEntry& graphEntry) {
auto node = binder->createQueryNode(NODE_COLUMN_NAME, binder->getTableEntries(graphEntry.nodeTableIDs));
auto node =
binder->createQueryNode(NODE_COLUMN_NAME, binder->getTableEntries(graphEntry.nodeTableIDs));
binder->addToScope(NODE_COLUMN_NAME, node);
return node;
}
Expand Down
32 changes: 20 additions & 12 deletions src/include/binder/binder.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,13 @@ class Binder {
const std::shared_ptr<NodeExpression>& leftNode,
const std::shared_ptr<NodeExpression>& rightNode, QueryGraph& queryGraph);
std::shared_ptr<RelExpression> createNonRecursiveQueryRel(const std::string& parsedName,
const std::vector<catalog::TableCatalogEntry*>& entries, std::shared_ptr<NodeExpression> srcNode,
std::shared_ptr<NodeExpression> dstNode, RelDirectionType directionType);
const std::vector<catalog::TableCatalogEntry*>& entries,
std::shared_ptr<NodeExpression> srcNode, std::shared_ptr<NodeExpression> dstNode,
RelDirectionType directionType);
std::shared_ptr<RelExpression> createRecursiveQueryRel(const parser::RelPattern& relPattern,
const std::vector<catalog::TableCatalogEntry*>& entries, std::shared_ptr<NodeExpression> srcNode,
std::shared_ptr<NodeExpression> dstNode, RelDirectionType directionType);
const std::vector<catalog::TableCatalogEntry*>& entries,
std::shared_ptr<NodeExpression> srcNode, std::shared_ptr<NodeExpression> dstNode,
RelDirectionType directionType);
std::pair<uint64_t, uint64_t> bindVariableLengthRelBound(const parser::RelPattern& relPattern);
void bindQueryRelProperties(RelExpression& rel);

Expand All @@ -268,17 +270,23 @@ class Binder {
void bindQueryNodeProperties(NodeExpression& node);

/*** bind table entries ***/
std::vector<catalog::TableCatalogEntry*> bindTableEntries(const std::vector<std::string>& tableNames,
bool nodePattern) const;
std::vector<catalog::TableCatalogEntry*> bindTableEntries(
const std::vector<std::string>& tableNames, bool nodePattern) const;
catalog::TableCatalogEntry* bindTableEntry(const std::string& tableName) const;
common::table_id_t bindTableID(const std::string& tableName) const;
std::vector<catalog::TableCatalogEntry*> getNodeTableEntries(const std::vector<catalog::TableCatalogEntry*>& entries) const;
std::vector<catalog::TableCatalogEntry*> getRelTableEntries(const std::vector<catalog::TableCatalogEntry*>& entries) const;
std::vector<catalog::TableCatalogEntry*> getTableEntries(const std::vector<catalog::TableCatalogEntry*>& entries, common::TableType tableType) const;
std::vector<catalog::TableCatalogEntry*> getNodeTableEntries(catalog::TableCatalogEntry* entry) const;
std::vector<catalog::TableCatalogEntry*> getRelTableEntries(catalog::TableCatalogEntry* entry) const;
std::vector<catalog::TableCatalogEntry*> getNodeTableEntries(
const std::vector<catalog::TableCatalogEntry*>& entries) const;
std::vector<catalog::TableCatalogEntry*> getRelTableEntries(
const std::vector<catalog::TableCatalogEntry*>& entries) const;
std::vector<catalog::TableCatalogEntry*> getTableEntries(
const std::vector<catalog::TableCatalogEntry*>& entries, common::TableType tableType) const;
std::vector<catalog::TableCatalogEntry*> getNodeTableEntries(
catalog::TableCatalogEntry* entry) const;
std::vector<catalog::TableCatalogEntry*> getRelTableEntries(
catalog::TableCatalogEntry* entry) const;
// TODO(Xiyang): remove id based table binding logic.
std::vector<catalog::TableCatalogEntry*> getTableEntries(const common::table_id_vector_t& tableIDs);
std::vector<catalog::TableCatalogEntry*> getTableEntries(
const common::table_id_vector_t& tableIDs);

/*** validations ***/
// E.g. ... RETURN a, b AS a
Expand Down
6 changes: 4 additions & 2 deletions src/include/binder/binder_scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class BinderScope {
expression_vector getExpressions() const { return expressions; }
void addExpression(const std::string& varName, std::shared_ptr<Expression> expression);

void memorizeTableEntries(const std::string& name, std::vector<catalog::TableCatalogEntry*> entries) {
void memorizeTableEntries(const std::string& name,
std::vector<catalog::TableCatalogEntry*> entries) {
memorizedNodeNameToEntries.insert({name, entries});
}
bool hasMemorizedTableIDs(const std::string& name) const {
Expand Down Expand Up @@ -56,7 +57,8 @@ class BinderScope {
// A node might be popped out of scope. But we may need to retain its table ID information.
// E.g. MATCH (a:person) WITH collect(a) AS list_a UNWIND list_a AS new_a MATCH (new_a)-[]->()
// It will be more performant if we can retain the information that new_a has label person.
std::unordered_map<std::string, std::vector<catalog::TableCatalogEntry*>> memorizedNodeNameToEntries;
std::unordered_map<std::string, std::vector<catalog::TableCatalogEntry*>>
memorizedNodeNameToEntries;
// A node pattern may not always be bound as a node expression, e.g. in the above query,
// (new_a) is bound as a variable rather than node expression.
std::unordered_map<std::string, std::shared_ptr<NodeExpression>> nodeReplacement;
Expand Down
4 changes: 1 addition & 3 deletions src/include/binder/expression/node_rel_expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ class NodeOrRelExpression : public Expression {
common::idx_t getNumEntries() const { return entries.size(); }
common::table_id_vector_t getTableIDsX() const;
common::table_id_set_t getTableIDsSet() const;
const std::vector<catalog::TableCatalogEntry*>& getEntries() const {
return entries;
}
const std::vector<catalog::TableCatalogEntry*>& getEntries() const { return entries; }
void setEntries(std::vector<catalog::TableCatalogEntry*> entries_) {
entries = std::move(entries_);
}
Expand Down
3 changes: 2 additions & 1 deletion src/include/catalog/catalog_entry/table_catalog_entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ struct TableCatalogEntryEquality {
}
};

using table_catalog_entry_set_t = std::unordered_set<TableCatalogEntry*, TableCatalogEntryHasher, TableCatalogEntryEquality>;
using table_catalog_entry_set_t =
std::unordered_set<TableCatalogEntry*, TableCatalogEntryHasher, TableCatalogEntryEquality>;

} // namespace catalog
} // namespace kuzu
3 changes: 2 additions & 1 deletion src/include/processor/plan_mapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ class PlanMapper {
const planner::Schema& schema) const;
std::unique_ptr<RelDeleteExecutor> getRelDeleteExecutor(const binder::BoundDeleteInfo& info,
const planner::Schema& schema) const;
NodeTableDeleteInfo getNodeTableDeleteInfo(const catalog::TableCatalogEntry& entry, DataPos pkPos) const;
NodeTableDeleteInfo getNodeTableDeleteInfo(const catalog::TableCatalogEntry& entry,
DataPos pkPos) const;
NodeTableSetInfo getNodeTableSetInfo(const catalog::TableCatalogEntry& entry,
const binder::Expression& expr) const;
RelTableSetInfo getRelTableSetInfo(const catalog::TableCatalogEntry& entry,
Expand Down
2 changes: 1 addition & 1 deletion src/optimizer/acc_hash_join_optimizer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "optimizer/acc_hash_join_optimizer.h"

#include "catalog/catalog_entry/table_catalog_entry.h"
#include "function/gds/gds.h"
#include "optimizer/logical_operator_collector.h"
#include "planner/operator/extend/logical_recursive_extend.h"
Expand All @@ -9,7 +10,6 @@
#include "planner/operator/logical_intersect.h"
#include "planner/operator/scan/logical_scan_node_table.h"
#include "planner/operator/sip/logical_semi_masker.h"
#include "catalog/catalog_entry/table_catalog_entry.h"

using namespace kuzu::common;
using namespace kuzu::binder;
Expand Down
3 changes: 2 additions & 1 deletion src/processor/map/map_delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ using namespace kuzu::storage;
namespace kuzu {
namespace processor {

NodeTableDeleteInfo PlanMapper::getNodeTableDeleteInfo(const TableCatalogEntry& entry, DataPos pkPos) const {
NodeTableDeleteInfo PlanMapper::getNodeTableDeleteInfo(const TableCatalogEntry& entry,
DataPos pkPos) const {
auto storageManager = clientContext->getStorageManager();
auto catalog = clientContext->getCatalog();
auto transaction = clientContext->getTx();
Expand Down
3 changes: 2 additions & 1 deletion src/processor/map/map_insert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ NodeInsertExecutor PlanMapper::getNodeInsertExecutor(const LogicalInsertInfo* bo
auto columnsPos = populateReturnColumnsPos(*boundInfo, outSchema);
auto info = NodeInsertInfo(nodeIDPos, columnsPos, boundInfo->conflictAction);
auto storageManager = clientContext->getStorageManager();
auto table = storageManager->getTable(node.getSingleEntry()->getTableID())->ptrCast<NodeTable>();
auto table =
storageManager->getTable(node.getSingleEntry()->getTableID())->ptrCast<NodeTable>();
evaluator_vector_t evaluators;
auto exprMapper = ExpressionMapper(&inSchema);
for (auto& expr : boundInfo->columnDataExprs) {
Expand Down
4 changes: 2 additions & 2 deletions src/processor/map/map_recursive_extend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ using namespace kuzu::planner;
namespace kuzu {
namespace processor {

static std::shared_ptr<RecursiveJoinSharedState> createSharedState(
const NodeExpression& nbrNode, const main::ClientContext& context) {
static std::shared_ptr<RecursiveJoinSharedState> createSharedState(const NodeExpression& nbrNode,
const main::ClientContext& context) {
std::vector<std::unique_ptr<common::NodeOffsetLevelSemiMask>> semiMasks;
for (auto entry : nbrNode.getEntries()) {
auto tableID = entry->getTableID();
Expand Down
6 changes: 4 additions & 2 deletions src/processor/map/map_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ static column_id_t getColumnID(const catalog::TableCatalogEntry& entry,
return columnID;
}

NodeTableSetInfo PlanMapper::getNodeTableSetInfo(const TableCatalogEntry& entry, const Expression& expr) const {
NodeTableSetInfo PlanMapper::getNodeTableSetInfo(const TableCatalogEntry& entry,
const Expression& expr) const {
auto storageManager = clientContext->getStorageManager();
auto table = storageManager->getTable(entry.getTableID())->ptrCast<NodeTable>();
auto columnID = getColumnID(entry, expr.constCast<PropertyExpression>());
return NodeTableSetInfo(table, columnID);
}

RelTableSetInfo PlanMapper::getRelTableSetInfo(const TableCatalogEntry& entry, const Expression& expr) const {
RelTableSetInfo PlanMapper::getRelTableSetInfo(const TableCatalogEntry& entry,
const Expression& expr) const {
auto storageManager = clientContext->getStorageManager();
auto table = storageManager->getTable(entry.getTableID())->ptrCast<RelTable>();
auto columnID = getColumnID(entry, expr.constCast<PropertyExpression>());
Expand Down

0 comments on commit f116668

Please sign in to comment.