use of com.baidu.hugegraph.iterator.ListIterator in project incubator-hugegraph by apache.
the class GraphTransaction method queryEdgesFromBackend.
protected Iterator<HugeEdge> queryEdgesFromBackend(Query query) {
assert query.resultType().isEdge();
QueryResults<BackendEntry> results = this.query(query);
Iterator<BackendEntry> entries = results.iterator();
Iterator<HugeEdge> edges = new FlatMapperIterator<>(entries, entry -> {
// Edges are in a vertex
HugeVertex vertex = this.parseEntry(entry);
if (vertex == null) {
return null;
}
if (query.idsSize() == 1) {
assert vertex.getEdges().size() == 1;
}
/*
* Copy to avoid ConcurrentModificationException when removing edge
* because HugeEdge.remove() will update edges in owner vertex
*/
return new ListIterator<>(ImmutableList.copyOf(vertex.getEdges()));
});
edges = this.filterExpiredResultFromFromBackend(query, edges);
if (!this.store().features().supportsQuerySortByInputIds()) {
// There is no id in BackendEntry, so sort after deserialization
edges = results.keepInputOrderIfNeeded(edges);
}
return edges;
}
Aggregations