From 9b54987780b67136c1f5e56396d895884acf0872 Mon Sep 17 00:00:00 2001 From: CI Bot Date: Tue, 14 Jan 2025 13:52:11 +0000 Subject: [PATCH] Run clang-format --- src/binder/bind/bind_graph_pattern.cpp | 15 ++--- src/function/gds/all_shortest_paths.cpp | 12 ++-- src/function/gds/gds_utils.cpp | 9 ++- src/function/gds/rec_joins.cpp | 5 +- src/function/gds/single_shortest_paths.cpp | 20 +++---- src/function/gds/weighted_shortest_paths.cpp | 57 ++++++++++--------- src/include/function/gds/gds_utils.h | 2 +- .../transform/transform_graph_pattern.cpp | 12 ++-- src/planner/plan/append_extend.cpp | 3 +- 9 files changed, 72 insertions(+), 63 deletions(-) diff --git a/src/binder/bind/bind_graph_pattern.cpp b/src/binder/bind/bind_graph_pattern.cpp index 8274950a8d8..40c8c868cf4 100644 --- a/src/binder/bind/bind_graph_pattern.cpp +++ b/src/binder/bind/bind_graph_pattern.cpp @@ -404,18 +404,19 @@ std::shared_ptr Binder::createRecursiveQueryRel(const parser::Rel recursiveInfo->nodeProjectionList = std::move(nodeProjectionList); recursiveInfo->relProjectionList = std::move(relProjectionList); - recursiveInfo->pathNodeIDsExpr = createInvisibleVariable("pathNodeIDs", - LogicalType::LIST(LogicalType::INTERNAL_ID())); - recursiveInfo->pathEdgeIDsExpr = createInvisibleVariable("pathEdgeIDs", - LogicalType::LIST(LogicalType::INTERNAL_ID())); - recursiveInfo->pathEdgeDirectionsExpr = createInvisibleVariable("pathEdgeDirections", - LogicalType::LIST(LogicalType::BOOL())); + recursiveInfo->pathNodeIDsExpr = + createInvisibleVariable("pathNodeIDs", LogicalType::LIST(LogicalType::INTERNAL_ID())); + recursiveInfo->pathEdgeIDsExpr = + createInvisibleVariable("pathEdgeIDs", LogicalType::LIST(LogicalType::INTERNAL_ID())); + recursiveInfo->pathEdgeDirectionsExpr = + createInvisibleVariable("pathEdgeDirections", LogicalType::LIST(LogicalType::BOOL())); if (relPattern.getRelType() == QueryRelType::WEIGHTED_SHORTEST) { auto propertyExpr = expressionBinder.bindNodeOrRelPropertyExpression(*rel, recursivePatternInfo->weightPropertyName); recursiveInfo->weightPropertyExpr = propertyExpr; - recursiveInfo->weightOutputExpr = createVariable(parsedName + "_weight", propertyExpr->getDataType()); + recursiveInfo->weightOutputExpr = + createVariable(parsedName + "_weight", propertyExpr->getDataType()); } queryRel->setRecursiveInfo(std::move(recursiveInfo)); diff --git a/src/function/gds/all_shortest_paths.cpp b/src/function/gds/all_shortest_paths.cpp index 79b3dbe9f58..80007e6c38d 100644 --- a/src/function/gds/all_shortest_paths.cpp +++ b/src/function/gds/all_shortest_paths.cpp @@ -73,7 +73,8 @@ struct AllSPDestinationOutputs : public RJOutputs { public: AllSPDestinationOutputs(nodeID_t sourceNodeID, std::shared_ptr pathLengths, std::shared_ptr multiplicities) - : RJOutputs{sourceNodeID}, pathLengths{std::move(pathLengths)}, multiplicities{std::move(multiplicities)} {} + : RJOutputs{sourceNodeID}, pathLengths{std::move(pathLengths)}, + multiplicities{std::move(multiplicities)} {} void initRJFromSource(nodeID_t source) override { multiplicities->pinTargetTable(source.tableID); @@ -123,8 +124,9 @@ class AllSPDestinationsOutputWriter : public RJOutputWriter { private: bool skipInternal(nodeID_t dstNodeID) const override { auto outputs = rjOutputs->ptrCast(); - return dstNodeID == outputs->sourceNodeID || outputs->pathLengths->getMaskValueFromCurFrontier( - dstNodeID.offset) == PathLengths::UNVISITED; + return dstNodeID == outputs->sourceNodeID || + outputs->pathLengths->getMaskValueFromCurFrontier(dstNodeID.offset) == + PathLengths::UNVISITED; } private: @@ -245,8 +247,8 @@ class AllSPDestinationsAlgorithm final : public SPAlgorithm { auto outputWriter = std::make_unique(clientContext, output.get(), sharedState->getOutputNodeMaskMap()); auto frontierPair = std::make_unique(frontier); - auto edgeCompute = std::make_unique(frontierPair.get(), - multiplicities); + auto edgeCompute = + std::make_unique(frontierPair.get(), multiplicities); return RJCompState(std::move(frontierPair), std::move(edgeCompute), sharedState->getOutputNodeMaskMap(), std::move(output), std::move(outputWriter)); } diff --git a/src/function/gds/gds_utils.cpp b/src/function/gds/gds_utils.cpp index a807545ed0d..dad4cb19789 100644 --- a/src/function/gds/gds_utils.cpp +++ b/src/function/gds/gds_utils.cpp @@ -1,13 +1,13 @@ #include "function/gds/gds_utils.h" +#include "binder/expression/property_expression.h" #include "catalog/catalog.h" +#include "catalog/catalog_entry/table_catalog_entry.h" #include "common/task_system/task_scheduler.h" #include "function/gds/gds_task.h" #include "graph/graph.h" #include "graph/graph_entry.h" #include "main/settings.h" -#include "binder/expression/property_expression.h" -#include "catalog/catalog_entry/table_catalog_entry.h" using namespace kuzu::common; using namespace kuzu::function; @@ -33,8 +33,7 @@ void GDSComputeState::beginFrontierComputeBetweenTables(common::table_id_t currT void GDSUtils::scheduleFrontierTask(catalog::TableCatalogEntry* fromEntry, catalog::TableCatalogEntry* toEntry, catalog::TableCatalogEntry* relEntry, graph::Graph* graph, ExtendDirection extendDirection, GDSComputeState& gdsComputeState, - processor::ExecutionContext* context, uint64_t numThreads, - const std::string& propertyToScan) { + processor::ExecutionContext* context, uint64_t numThreads, const std::string& propertyToScan) { auto clientContext = context->clientContext; auto transaction = clientContext->getTransaction(); auto info = FrontierTaskInfo(fromEntry, toEntry, relEntry, graph, extendDirection, @@ -96,7 +95,7 @@ void GDSUtils::runFrontiersUntilConvergence(processor::ExecutionContext* context compState.beginFrontierComputeBetweenTables(toEntry->getTableID(), fromEntry->getTableID()); scheduleFrontierTask(toEntry, fromEntry, relEntry, graph, ExtendDirection::BWD, - compState, context, numThreads, propertyToScan); + compState, context, numThreads, propertyToScan); } break; default: KU_UNREACHABLE; diff --git a/src/function/gds/rec_joins.cpp b/src/function/gds/rec_joins.cpp index c22369776e2..41ba9bbb527 100644 --- a/src/function/gds/rec_joins.cpp +++ b/src/function/gds/rec_joins.cpp @@ -2,6 +2,7 @@ #include "binder/binder.h" #include "binder/expression/expression_util.h" +#include "binder/expression/property_expression.h" #include "common/exception/interrupt.h" #include "common/exception/runtime.h" #include "common/task_system/progress_bar.h" @@ -12,7 +13,6 @@ #include "storage/buffer_manager/memory_manager.h" #include "storage/local_storage/local_node_table.h" #include "storage/local_storage/local_storage.h" -#include "binder/expression/property_expression.h" using namespace kuzu::binder; using namespace kuzu::common; @@ -212,7 +212,8 @@ void RJAlgorithm::exec(processor::ExecutionContext* context) { rjCompState.initSource(sourceNodeID); auto rjBindData = bindData->ptrCast(); GDSUtils::runFrontiersUntilConvergence(context, rjCompState, graph, - rjBindData->extendDirection, rjBindData->upperBound, rjBindData->weightPropertyName); + rjBindData->extendDirection, rjBindData->upperBound, + rjBindData->weightPropertyName); auto vertexCompute = std::make_unique(clientContext->getMemoryManager(), sharedState.get(), rjCompState.outputWriter->copy()); diff --git a/src/function/gds/single_shortest_paths.cpp b/src/function/gds/single_shortest_paths.cpp index bcdd78477a4..ed4721c29c0 100644 --- a/src/function/gds/single_shortest_paths.cpp +++ b/src/function/gds/single_shortest_paths.cpp @@ -40,8 +40,7 @@ class SingleSPDestinationsOutputWriter : public RJOutputWriter { lengthVector = createVector(LogicalType::UINT16(), context->getMemoryManager()); } - void write(FactorizedTable& fTable, nodeID_t dstNodeID, - GDSOutputCounter* counter) override { + void write(FactorizedTable& fTable, nodeID_t dstNodeID, GDSOutputCounter* counter) override { auto outputs = rjOutputs->ptrCast(); auto length = outputs->pathLengths->getMaskValueFromCurFrontier(dstNodeID.offset); dstNodeIDVector->setValue(0, dstNodeID); @@ -53,14 +52,16 @@ class SingleSPDestinationsOutputWriter : public RJOutputWriter { } std::unique_ptr copy() override { - return std::make_unique(context, rjOutputs, outputNodeMask); + return std::make_unique(context, rjOutputs, + outputNodeMask); } private: bool skipInternal(nodeID_t dstNodeID) const override { auto outputs = rjOutputs->ptrCast(); - return dstNodeID == outputs->sourceNodeID || outputs->pathLengths->getMaskValueFromCurFrontier( - dstNodeID.offset) == PathLengths::UNVISITED; + return dstNodeID == outputs->sourceNodeID || + outputs->pathLengths->getMaskValueFromCurFrontier(dstNodeID.offset) == + PathLengths::UNVISITED; } private: @@ -72,8 +73,7 @@ class SingleSPDestinationsEdgeCompute : public SPEdgeCompute { explicit SingleSPDestinationsEdgeCompute(SinglePathLengthsFrontierPair* frontierPair) : SPEdgeCompute{frontierPair} {}; - std::vector edgeCompute(nodeID_t, NbrScanState::Chunk& resultChunk, - bool) override { + std::vector edgeCompute(nodeID_t, NbrScanState::Chunk& resultChunk, bool) override { std::vector activeNodes; resultChunk.forEach([&](auto nbrNode, auto) { if (frontierPair->getPathLengths()->getMaskValueFromNextFrontier(nbrNode.offset) == @@ -135,7 +135,7 @@ class SingleSPDestinationsAlgorithm : public SPAlgorithm { : SPAlgorithm{other} {} expression_vector getResultColumns(Binder*) const override { - auto columns = getBaseResultColumns(); + auto columns = getBaseResultColumns(); columns.push_back(bindData->ptrCast()->lengthExpr); return columns; } @@ -149,8 +149,8 @@ class SingleSPDestinationsAlgorithm : public SPAlgorithm { auto clientContext = context->clientContext; auto frontier = getPathLengthsFrontier(context, PathLengths::UNVISITED); auto output = std::make_unique(sourceNodeID, frontier); - auto outputWriter = std::make_unique(clientContext, output.get(), - sharedState->getOutputNodeMaskMap()); + auto outputWriter = std::make_unique(clientContext, + output.get(), sharedState->getOutputNodeMaskMap()); auto frontierPair = std::make_unique(output->pathLengths); auto edgeCompute = std::make_unique(frontierPair.get()); return RJCompState(std::move(frontierPair), std::move(edgeCompute), diff --git a/src/function/gds/weighted_shortest_paths.cpp b/src/function/gds/weighted_shortest_paths.cpp index 134385af9c9..455a50fff16 100644 --- a/src/function/gds/weighted_shortest_paths.cpp +++ b/src/function/gds/weighted_shortest_paths.cpp @@ -1,9 +1,9 @@ -#include "function/gds_function.h" +#include "binder/binder.h" #include "function/gds/gds_function_collection.h" #include "function/gds/rec_joins.h" +#include "function/gds_function.h" #include "main/client_context.h" #include "processor/execution_context.h" -#include "binder/binder.h" using namespace kuzu::common; using namespace kuzu::storage; @@ -21,9 +21,7 @@ class Weights { void pinTable(table_id_t tableID) { weights = weightsMap.getData(tableID); } - T getWeight(offset_t offset) { - return weights[offset].load(std::memory_order_relaxed); - } + T getWeight(offset_t offset) { return weights[offset].load(std::memory_order_relaxed); } void setWeight(offset_t offset, T val) { weights[offset].store(val, std::memory_order_relaxed); @@ -59,9 +57,11 @@ class Weights { template class DestinationsEdgeCompute : public EdgeCompute { public: - explicit DestinationsEdgeCompute(std::shared_ptr> weights) : weights{std::move(weights)} {} + explicit DestinationsEdgeCompute(std::shared_ptr> weights) + : weights{std::move(weights)} {} - std::vector edgeCompute(nodeID_t boundNodeID, graph::NbrScanState::Chunk &chunk, bool) override { + std::vector edgeCompute(nodeID_t boundNodeID, graph::NbrScanState::Chunk& chunk, + bool) override { std::vector result; chunk.forEach([&](auto nbrNodeID, auto /* edgeID */, auto weight) { if (weights->update(boundNodeID.offset, nbrNodeID.offset, weight)) { @@ -86,9 +86,7 @@ struct DestinationOutputs : public RJOutputs { DestinationOutputs(nodeID_t sourceNodeID, std::shared_ptr> weights) : RJOutputs{sourceNodeID}, weights{std::move(weights)} {} - void initRJFromSource(common::nodeID_t a) override { - weights->setWeight(a.offset, 0); - } + void initRJFromSource(common::nodeID_t a) override { weights->setWeight(a.offset, 0); } void beginFrontierComputeBetweenTables(table_id_t, table_id_t nextFrontierTableID) override { weights->pinTable(nextFrontierTableID); @@ -105,12 +103,12 @@ class DestinationsOutputWriter : public RJOutputWriter { DestinationsOutputWriter(main::ClientContext* context, RJOutputs* rjOutputs, processor::NodeOffsetMaskMap* outputNodeMask, std::shared_ptr> weights, const LogicalType& weightType) - : RJOutputWriter{context, rjOutputs, outputNodeMask}, - weights{std::move(weights)} { + : RJOutputWriter{context, rjOutputs, outputNodeMask}, weights{std::move(weights)} { weightVector = createVector(weightType, context->getMemoryManager()); } - void write(processor::FactorizedTable &fTable, nodeID_t dstNodeID, processor::GDSOutputCounter *counter) override { + void write(processor::FactorizedTable& fTable, nodeID_t dstNodeID, + processor::GDSOutputCounter* counter) override { dstNodeIDVector->setValue(0, dstNodeID); auto weight = weights->getWeight(dstNodeID.offset); weightVector->setValue(0, weight); @@ -121,7 +119,8 @@ class DestinationsOutputWriter : public RJOutputWriter { } std::unique_ptr copy() override { - return std::make_unique>(context, rjOutputs, outputNodeMask, weights, weightVector->dataType); + return std::make_unique>(context, rjOutputs, outputNodeMask, + weights, weightVector->dataType); } private: @@ -141,7 +140,7 @@ class WeightedSPDestinationsAlgorithm : public SPAlgorithm { WeightedSPDestinationsAlgorithm(const WeightedSPDestinationsAlgorithm& other) : SPAlgorithm{other} {} - binder::expression_vector getResultColumns(binder::Binder *) const override { + binder::expression_vector getResultColumns(binder::Binder*) const override { auto columns = getBaseResultColumns(); columns.push_back(bindData->ptrCast()->weightOutputExpr); return columns; @@ -192,28 +191,30 @@ class WeightedSPDestinationsAlgorithm : public SPAlgorithm { default: break; } - throw RuntimeException(stringFormat("{} weight type is not supported for weighted shortest path.", dataType.toString())); + throw RuntimeException(stringFormat( + "{} weight type is not supported for weighted shortest path.", dataType.toString())); } - RJCompState getRJCompState(processor::ExecutionContext *context, nodeID_t sourceNodeID) override { + RJCompState getRJCompState(processor::ExecutionContext* context, + nodeID_t sourceNodeID) override { auto clientContext = context->clientContext; auto numNodes = sharedState->graph->getNumNodesMap(clientContext->getTransaction()); auto curFrontier = getPathLengthsFrontier(context, PathLengths::UNVISITED); auto nextFrontier = getPathLengthsFrontier(context, PathLengths::UNVISITED); - auto frontierPair = std::make_unique(curFrontier, nextFrontier); + auto frontierPair = + std::make_unique(curFrontier, nextFrontier); auto rjBindData = bindData->ptrCast(); std::unique_ptr edgeCompute; std::unique_ptr outputs; std::unique_ptr outputWriter; auto& dataType = rjBindData->weightOutputExpr->getDataType(); - visit(dataType, - [&](T) { - auto weight = std::make_shared>(numNodes, clientContext->getMemoryManager()); - edgeCompute = std::make_unique>(weight); - outputs = std::make_unique>(sourceNodeID, weight); - outputWriter = std::make_unique>(clientContext, - outputs.get(), sharedState->getOutputNodeMaskMap(), weight, dataType); - }); + visit(dataType, [&](T) { + auto weight = std::make_shared>(numNodes, clientContext->getMemoryManager()); + edgeCompute = std::make_unique>(weight); + outputs = std::make_unique>(sourceNodeID, weight); + outputWriter = std::make_unique>(clientContext, + outputs.get(), sharedState->getOutputNodeMaskMap(), weight, dataType); + }); return RJCompState(std::move(frontierPair), std::move(edgeCompute), sharedState->getOutputNodeMaskMap(), std::move(outputs), std::move(outputWriter)); } @@ -231,5 +232,5 @@ GDSFunction WeightedSPDestinationsFunction::getFunction() { return GDSFunction(name, std::move(params), std::move(algo)); } -} -} +} // namespace function +} // namespace kuzu diff --git a/src/include/function/gds/gds_utils.h b/src/include/function/gds/gds_utils.h index bb6612f51f2..4c28bd213fb 100644 --- a/src/include/function/gds/gds_utils.h +++ b/src/include/function/gds/gds_utils.h @@ -2,10 +2,10 @@ #include +#include "binder/expression/expression.h" #include "catalog/catalog_entry/table_catalog_entry.h" #include "common/enums/extend_direction.h" #include "common/types/types.h" -#include "binder/expression/expression.h" namespace kuzu { namespace processor { diff --git a/src/parser/transform/transform_graph_pattern.cpp b/src/parser/transform/transform_graph_pattern.cpp index a71eb5d1b85..79f2245b5d7 100644 --- a/src/parser/transform/transform_graph_pattern.cpp +++ b/src/parser/transform/transform_graph_pattern.cpp @@ -105,7 +105,8 @@ RelPattern Transformer::transformRelationshipPattern( relType = QueryRelType::ALL_SHORTEST; } else if (recursiveType->WSHORTEST()) { relType = QueryRelType::WEIGHTED_SHORTEST; - recursiveInfo.weightPropertyName = transformPropertyKeyName(*recursiveType->oC_PropertyKeyName()); + recursiveInfo.weightPropertyName = + transformPropertyKeyName(*recursiveType->oC_PropertyKeyName()); } else if (recursiveDetail->kU_RecursiveType()->SHORTEST()) { relType = QueryRelType::SHORTEST; } else if (recursiveDetail->kU_RecursiveType()->TRAIL()) { @@ -147,13 +148,16 @@ RelPattern Transformer::transformRelationshipPattern( if (!comprehension->kU_RecursiveProjectionItems().empty()) { recursiveInfo.hasProjection = true; KU_ASSERT(comprehension->kU_RecursiveProjectionItems().size() == 2); - auto relProjectionList = comprehension->kU_RecursiveProjectionItems(0)->oC_ProjectionItems(); + auto relProjectionList = + comprehension->kU_RecursiveProjectionItems(0)->oC_ProjectionItems(); if (relProjectionList) { recursiveInfo.relProjectionList = transformProjectionItems(*relProjectionList); } - auto nodeProjectionList = comprehension->kU_RecursiveProjectionItems(1)->oC_ProjectionItems(); + auto nodeProjectionList = + comprehension->kU_RecursiveProjectionItems(1)->oC_ProjectionItems(); if (nodeProjectionList) { - recursiveInfo.nodeProjectionList = transformProjectionItems(*nodeProjectionList); + recursiveInfo.nodeProjectionList = + transformProjectionItems(*nodeProjectionList); } } } diff --git a/src/planner/plan/append_extend.cpp b/src/planner/plan/append_extend.cpp index 14e0086706a..c56d4291c4e 100644 --- a/src/planner/plan/append_extend.cpp +++ b/src/planner/plan/append_extend.cpp @@ -152,7 +152,8 @@ void Planner::appendRecursiveExtendAsGDS(const std::shared_ptr& bindData->pathNodeIDsExpr = recursiveInfo->pathNodeIDsExpr; bindData->pathEdgeIDsExpr = recursiveInfo->pathEdgeIDsExpr; if (recursiveInfo->weightPropertyExpr != nullptr) { - bindData->weightPropertyName = recursiveInfo->weightPropertyExpr->ptrCast()->getPropertyName(); + bindData->weightPropertyName = + recursiveInfo->weightPropertyExpr->ptrCast()->getPropertyName(); bindData->weightOutputExpr = recursiveInfo->weightOutputExpr; } gdsFunction.gds->setBindData(std::move(bindData));