Skip to content

Commit 276382c

Browse files
committed
remove usage of apache commons collections
1 parent 3822d08 commit 276382c

File tree

2 files changed

+16
-26
lines changed

2 files changed

+16
-26
lines changed

src/main/java/n10s/result/VirtualPath.java

+15-24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package n10s.result;
22

3-
import org.apache.commons.collections.CollectionUtils;
43
import org.neo4j.graphdb.*;
54
import org.neo4j.graphdb.traversal.Paths;
65

@@ -10,9 +9,6 @@
109
import java.util.concurrent.atomic.AtomicReference;
1110

1211

13-
//import static org.apache.commons.collections4.IterableUtils.reversedIterable;
14-
15-
1612
public class VirtualPath implements Path {
1713
private final Node start;
1814
private final List<Relationship> relationships;
@@ -124,36 +120,31 @@ public String toString() {
124120

125121
private void requireConnected(Relationship relationship) {
126122
final List<Node> previousNodes = getPreviousNodes();
127-
boolean isRelConnectedToPrevious = CollectionUtils.containsAny( previousNodes, Arrays.asList(relationship.getNodes()) );
123+
boolean isRelConnectedToPrevious = containsAny( previousNodes, Arrays.asList(relationship.getNodes()));
128124
if (!isRelConnectedToPrevious) {
129125
throw new IllegalArgumentException("Relationship is not part of current path.");
130126
}
131127
}
132128

129+
public static boolean containsAny(Collection<?> coll1, Collection<?> coll2) {
130+
if (coll1 == null || coll2 == null) {
131+
return false;
132+
}
133+
134+
for (Object obj : coll1) {
135+
if (coll2.contains(obj)) {
136+
return true;
137+
}
138+
}
139+
140+
return false;
141+
}
142+
133143
private List<Node> getPreviousNodes() {
134144
Relationship previousRelationship = lastRelationship();
135145
if (previousRelationship != null) {
136146
return Arrays.asList(previousRelationship.getNodes());
137147
}
138148
return List.of(endNode());
139149
}
140-
141-
public static final class Builder {
142-
private final Node start;
143-
private final List<Relationship> relationships = new ArrayList<>();
144-
145-
public Builder(Node start) {
146-
this.start = start;
147-
}
148-
149-
public Builder push(Relationship relationship) {
150-
this.relationships.add(relationship);
151-
return this;
152-
}
153-
154-
public VirtualPath build() {
155-
return new VirtualPath(start, relationships);
156-
}
157-
158-
}
159150
}

src/main/java/n10s/similarity/Similarities.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,7 @@ public Stream<SemanticSearchResult> lchSimSearch(@Name("node1") Node elem1, @Nam
194194
Long worst_case_total_depth = (Long) tx.execute(String.format(globalMaxDepthQuery, subclassOfRel), queryParams).next().get("len");
195195

196196
queryParams.put("threshold_length", ((2.0 * worst_case_total_depth)/ Math.pow(10,minSim)));
197-
//TODO: THIS IS NOT EFFICIENT: EXTRACT THE DEPTH COMPUTATION AND CACHE
198-
System.out.println(String.format(shortestPathSearchWithMaxDepth, classLabel, subclassOfRel));
197+
//TODO: MAKE THIS MORE EFFICIENT: EXTRACT THE DEPTH COMPUTATION AND CACHE
199198
return tx.execute(String.format(shortestPathSearchWithMaxDepth, classLabel, subclassOfRel), queryParams).stream().map(SemanticSearchResult::new);
200199
}
201200

0 commit comments

Comments
 (0)