qwtsc commented on code in PR #2281:
URL:
https://github.com/apache/incubator-hugegraph/pull/2281#discussion_r1295245741
##########
hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/CountTraverser.java:
##########
@@ -78,19 +78,28 @@ public long count(Id source, List<EdgeStep> steps,
});
}
- // The last step, just query count
- EdgeStep lastStep = steps.get(stepNum - 1);
- while (edges.hasNext()) {
- Id target = ((HugeEdge) edges.next()).id().otherVertexId();
- if (this.dedup(target)) {
- continue;
+ try {
+ // The last step, just query count
+ EdgeStep lastStep = steps.get(stepNum - 1);
+ while (edges.hasNext()) {
+ Id target = ((HugeEdge) edges.next()).id().otherVertexId();
+ if (this.dedup(target)) {
+ continue;
+ }
+ // Count last layer vertices(without dedup size)
+ long edgesCount = this.edgesCount(target, lastStep);
+ this.count.add(edgesCount);
}
- // Count last layer vertices(without dedup size)
- long edgesCount = this.edgesCount(target, lastStep);
- this.count.add(edgesCount);
- }
- return this.count.longValue();
+ return this.count.longValue();
+ } finally {
+ if (edges instanceof FlatMapperIterator) {
Review Comment:
```java
if (iterator instanceof AutoCloseable) {
try {
((AutoCloseable)iterator).close();
} catch (Exception var2) {
throw new RuntimeException(var2);
}
}
```
closeIterator will throw runtime exception when error occurs, do u think
this exception can be ignored? I'm willing to modify the PR if u think it is ok
to use it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]