Search in sources :

Example 1 with BoundedIterable

use of org.neo4j.internal.helpers.collection.BoundedIterable in project neo4j by neo4j.

the class FusionIndexAccessor method newAllEntriesValueReader.

@Override
public BoundedIterable<Long> newAllEntriesValueReader(long fromIdInclusive, long toIdExclusive, CursorContext cursorContext) {
    Iterable<BoundedIterable<Long>> entries = instanceSelector.transform(indexAccessor -> indexAccessor.newAllEntriesValueReader(fromIdInclusive, toIdExclusive, cursorContext));
    return new BoundedIterable<>() {

        @Override
        public long maxCount() {
            long sum = 0;
            for (BoundedIterable entry : entries) {
                long maxCount = entry.maxCount();
                if (maxCount == UNKNOWN_MAX_COUNT) {
                    return UNKNOWN_MAX_COUNT;
                }
                sum += maxCount;
            }
            return sum;
        }

        @Override
        public void close() throws Exception {
            forAll(BoundedIterable::close, entries);
        }

        @Override
        public Iterator<Long> iterator() {
            return Iterables.concat(entries).iterator();
        }
    };
}
Also used : BoundedIterable(org.neo4j.internal.helpers.collection.BoundedIterable)

Aggregations

BoundedIterable (org.neo4j.internal.helpers.collection.BoundedIterable)1