Search in sources :

Example 1 with RangeLongIterator

use of org.neo4j.collection.RangeLongIterator in project neo4j by neo4j.

the class BaseCursorScan method reserveBatch.

@Override
public boolean reserveBatch(C cursor, int sizeHint) {
    requirePositive(sizeHint);
    LongIterator addedItems = ImmutableEmptyLongIterator.INSTANCE;
    if (hasChanges && !addedItemsConsumed) {
        // the idea here is to give each batch an exclusive range of the underlying
        // memory so that each thread can read in parallel without contention.
        int addedStart = addedChunk.getAndAdd(sizeHint);
        if (addedStart < addedItemsArray.length) {
            int batchSize = min(sizeHint, addedItemsArray.length - addedStart);
            sizeHint -= batchSize;
            addedItems = new RangeLongIterator(addedItemsArray, addedStart, batchSize);
        } else {
            addedItemsConsumed = true;
        }
    }
    return scanStore(cursor, sizeHint, addedItems);
}
Also used : RangeLongIterator(org.neo4j.collection.RangeLongIterator) LongIterator(org.eclipse.collections.api.iterator.LongIterator) ImmutableEmptyLongIterator(org.eclipse.collections.impl.iterator.ImmutableEmptyLongIterator) RangeLongIterator(org.neo4j.collection.RangeLongIterator)

Aggregations

LongIterator (org.eclipse.collections.api.iterator.LongIterator)1 ImmutableEmptyLongIterator (org.eclipse.collections.impl.iterator.ImmutableEmptyLongIterator)1 RangeLongIterator (org.neo4j.collection.RangeLongIterator)1