Skip to content

Commit

Permalink
fix(core): close flat mapper iterator after usage (#2281)
Browse files Browse the repository at this point in the history
close [Bug] FlatMapperIterator should be closed after usage #2280
  • Loading branch information
qwtsc authored Aug 29, 2023
1 parent 8a515f2 commit aaf67cf
Showing 1 changed file with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.hugegraph.iterator.FlatMapperIterator;
import org.apache.hugegraph.structure.HugeEdge;
import org.apache.hugegraph.util.E;
import org.apache.tinkerpop.gremlin.structure.util.CloseableIterator;

public class CountTraverser extends HugeTraverser {

Expand Down Expand Up @@ -78,19 +79,23 @@ 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 {
CloseableIterator.closeIterator(edges);
}
}

private Iterator<Edge> edgesOfVertexWithCount(Id source, EdgeStep step) {
Expand Down

0 comments on commit aaf67cf

Please sign in to comment.