Skip to content

Commit 41958cc

Browse files
committed
update is_deleted logic
1 parent 81baf4a commit 41958cc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main/java/com/bytecodedl/pathfinder/FindAnyOnePath.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import java.util.Collections;
1010
import java.util.List;
11+
import java.util.Objects;
1112
import java.util.Optional;
1213
import java.util.stream.Collectors;
1314
import java.util.stream.Stream;
@@ -35,7 +36,7 @@ public Stream<PathRecord> findOnePath(@Name("start") Node start, @Name("end") No
3536
PathExpanderBuilder.empty()
3637
.add(RelationshipType.withName(relationType), Direction.OUTGOING)
3738
// filter non delete relation
38-
.addRelationshipFilter(relationship -> relationship.getProperty("is_deleted", "0").equals("0")).build())
39+
.addRelationshipFilter(relationship -> Objects.equals(relationship.getProperty("is_deleted", 0), 0)).build())
3940
.uniqueness(Uniqueness.NODE_GLOBAL)
4041
.traverse(start);
4142

@@ -46,7 +47,7 @@ public Stream<PathRecord> findOnePath(@Name("start") Node start, @Name("end") No
4647
@Description("find one path from start to end between minlength and maxlength, also show first multi dispatch")
4748
public Stream<PathRecord> biFindOnePath(@Name("start") Node start, @Name("end") Node end, @Name("maxLength") long maxLength, @Name(value = "relationshipType", defaultValue = "Call") String relationType, @Name(value = "callProperty", defaultValue = "insn") String callProperty){
4849
TraversalDescription base = tx.traversalDescription().depthFirst().uniqueness(Uniqueness.RELATIONSHIP_GLOBAL);
49-
PathExpander expander = PathExpanderBuilder.empty().add(RelationshipType.withName(relationType), Direction.OUTGOING).addRelationshipFilter(relationship -> relationship.getProperty("is_deleted", "0").equals("0")).build();
50+
PathExpander expander = PathExpanderBuilder.empty().add(RelationshipType.withName(relationType), Direction.OUTGOING).addRelationshipFilter(relationship -> Objects.equals(relationship.getProperty("is_deleted", 0), 0)).build();
5051
int maxDepth = (int) maxLength;
5152

5253
final Traverser traverser = tx.bidirectionalTraversalDescription()
@@ -94,7 +95,7 @@ public List<Relationship> getFirstMultiDispatch(Path path, String callProperty){
9495
}
9596
Object property = relationship.getProperty(callProperty);
9697
List<Relationship> relationships = startNode.getRelationships(relationship.getType()).stream().filter(
97-
relation ->relation.hasProperty(callProperty) && relation.getProperty(callProperty).equals(property)
98+
relation ->relation.hasProperty(callProperty) && relation.getProperty(callProperty).equals(property) && !Objects.equals(relation.getProperty("is_deleted", 0), 0)
9899
).collect(Collectors.toList());
99100

100101
if (relationships.size() > 1){

0 commit comments

Comments
 (0)