use of org.eclipse.collections.api.iterator.LongIterator 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);
}
use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.
the class RelationshipModifications method idsAsBatch.
static RelationshipBatch idsAsBatch(LongSet ids, IdDataDecorator idDataDecorator) {
return new RelationshipBatch() {
@Override
public int size() {
return ids.size();
}
@Override
public boolean isEmpty() {
return ids.isEmpty();
}
@Override
public boolean contains(long id) {
return ids.contains(id);
}
@Override
public long first() {
return ids.longIterator().next();
}
@Override
public <E extends Exception> void forEach(RelationshipVisitor<E> relationship) throws E {
LongIterator iterator = ids.longIterator();
while (iterator.hasNext()) {
long id = iterator.next();
idDataDecorator.accept(id, relationship);
}
}
};
}
use of org.eclipse.collections.api.iterator.LongIterator in project mapdb by jankotek.
the class AbstractLongLongMapTestCase method longIterator.
@Test
public void longIterator() {
MutableLongSet expected = LongHashSet.newSetWith(0L, 31L, 32L);
MutableLongSet actual = LongHashSet.newSetWith();
LongIterator iterator = this.map.longIterator();
Assert.assertTrue(iterator.hasNext());
actual.add(iterator.next());
Assert.assertTrue(iterator.hasNext());
actual.add(iterator.next());
Assert.assertTrue(iterator.hasNext());
actual.add(iterator.next());
Assert.assertFalse(iterator.hasNext());
Assert.assertEquals(expected, actual);
Verify.assertThrows(NoSuchElementException.class, iterator::next);
Verify.assertThrows(NoSuchElementException.class, () -> this.getEmptyMap().longIterator().next());
}
use of org.eclipse.collections.api.iterator.LongIterator in project mapdb by jankotek.
the class AbstractMutableLongCollectionTestCase method longIterator_throws_non_empty_collection.
@Override
@Test(expected = NoSuchElementException.class)
public void longIterator_throws_non_empty_collection() {
super.longIterator_throws_non_empty_collection();
MutableLongCollection collection = this.newWith();
collection.add(1L);
collection.add(2L);
collection.add(3L);
LongIterator iterator = collection.longIterator();
while (iterator.hasNext()) {
iterator.next();
}
iterator.next();
}
use of org.eclipse.collections.api.iterator.LongIterator in project mapdb by jankotek.
the class AbstractLazyLongIterableTestCase method longIterator_throws.
@Test(expected = NoSuchElementException.class)
public void longIterator_throws() {
LongIterator iterator = this.classUnderTest().longIterator();
while (iterator.hasNext()) {
iterator.next();
}
iterator.next();
}
Aggregations