Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.arcadedb.query.opencypher.ast.NodePattern;
import com.arcadedb.query.opencypher.ast.PathPattern;
import com.arcadedb.query.opencypher.ast.RelationshipPattern;
import com.arcadedb.query.opencypher.ast.Direction;
import com.arcadedb.query.opencypher.parser.CypherASTBuilder;
import com.arcadedb.query.sql.executor.*;

Expand Down Expand Up @@ -205,8 +206,16 @@ private void createPath(final PathPattern pathPattern, final ResultInternal resu
// Create relationships between vertices
for (int i = 0; i < pathPattern.getRelationshipCount(); i++) {
final RelationshipPattern relPattern = pathPattern.getRelationship(i);
final Vertex fromVertex = vertices.get(i);
final Vertex toVertex = vertices.get(i + 1);
final Vertex fromVertex;
final Vertex toVertex;

if (relPattern.getDirection() == Direction.IN) {
fromVertex = vertices.get(i + 1);
toVertex = vertices.get(i);
} else {
fromVertex = vertices.get(i);
toVertex = vertices.get(i + 1);
}
Comment on lines +209 to +218
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This logic for determining fromVertex and toVertex is duplicated in MergeStep.java (lines 282-291). To adhere to the DRY (Don't Repeat Yourself) principle and improve maintainability, please consider extracting this logic into a common helper method that can be used by both CreateStep and MergeStep.


final Edge edge = createEdge(fromVertex, toVertex, relPattern, result);
if (relPattern.getVariable() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.arcadedb.query.opencypher.ast.NodePattern;
import com.arcadedb.query.opencypher.ast.PathPattern;
import com.arcadedb.query.opencypher.ast.RelationshipPattern;
import com.arcadedb.query.opencypher.ast.Direction;
import com.arcadedb.query.opencypher.ast.SetClause;
import com.arcadedb.query.opencypher.executor.CypherFunctionFactory;
import com.arcadedb.query.opencypher.executor.ExpressionEvaluator;
Expand Down Expand Up @@ -278,8 +279,16 @@ private boolean mergePath(final PathPattern pathPattern, final ResultInternal re
// Merge relationships between vertices
for (int i = 0; i < pathPattern.getRelationshipCount(); i++) {
final RelationshipPattern relPattern = pathPattern.getRelationship(i);
final Vertex fromVertex = vertices.get(i);
final Vertex toVertex = vertices.get(i + 1);
final Vertex fromVertex;
final Vertex toVertex;

if (relPattern.getDirection() == Direction.IN) {
fromVertex = vertices.get(i + 1);
toVertex = vertices.get(i);
} else {
fromVertex = vertices.get(i);
toVertex = vertices.get(i + 1);
}

// Try to find existing relationship
Edge edge = findEdge(fromVertex, toVertex, relPattern, result);
Expand Down
Loading