Search in sources :

Example 36 with LongIterator

use of org.eclipse.collections.api.iterator.LongIterator in project mapdb by jankotek.

the class LongLongHashMapValuesTest method longIterator.

@Override
@Test
public void longIterator() {
    MutableLongCollection bag = this.newWith(0L, 1L, 2L, 3L);
    LongArrayList list = LongArrayList.newListWith(0L, 1L, 2L, 3L);
    LongIterator iterator = bag.longIterator();
    for (int i = 0; i < 4; i++) {
        Assert.assertTrue(iterator.hasNext());
        Assert.assertTrue(list.remove(iterator.next()));
    }
    Verify.assertEmpty(list);
    Assert.assertFalse(iterator.hasNext());
    Verify.assertThrows(NoSuchElementException.class, iterator::next);
}
Also used : LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) MutableLongCollection(org.eclipse.collections.api.collection.primitive.MutableLongCollection) LongIterator(org.eclipse.collections.api.iterator.LongIterator)

Example 37 with LongIterator

use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.

the class RecordIdIteratorTest method assertIds.

private static void assertIds(RecordIdIterator ids, long[]... expectedIds) {
    for (long[] expectedArray : expectedIds) {
        LongIterator iterator = ids.nextBatch();
        assertNotNull(iterator);
        for (long expectedId : expectedArray) {
            assertEquals(expectedId, iterator.next());
        }
        assertFalse(iterator.hasNext());
    }
    assertNull(ids.nextBatch());
}
Also used : LongIterator(org.eclipse.collections.api.iterator.LongIterator)

Example 38 with LongIterator

use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.

the class DocValuesCollectorTest method shouldSilentlyMergeSegmentsWhenReturnDocValuesInOrder.

@Test
void shouldSilentlyMergeSegmentsWhenReturnDocValuesInOrder() throws Exception {
    // given
    DocValuesCollector collector = new DocValuesCollector(true);
    IndexReaderStub readerStub = indexReaderWithMaxDocs(42);
    // when
    collector.doSetNextReader(readerStub.getContext());
    collector.setScorer(constantScorer(1.0f));
    collector.collect(1);
    collector.doSetNextReader(readerStub.getContext());
    collector.setScorer(constantScorer(2.0f));
    collector.collect(2);
    // then
    LongIterator valuesIterator = collector.getValuesSortedByRelevance("id");
    assertEquals(2, valuesIterator.next());
    assertEquals(1, valuesIterator.next());
    assertFalse(valuesIterator.hasNext());
}
Also used : IndexReaderStub(org.neo4j.kernel.api.impl.index.IndexReaderStub) LongIterator(org.eclipse.collections.api.iterator.LongIterator) Test(org.junit.jupiter.api.Test)

Example 39 with LongIterator

use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.

the class IndexingCompositeQueryAcceptanceTest method shouldNotIncludeEntitiesDeletedInSameTxInIndexSeek.

@ParameterizedTest(name = "shouldNotIncludeEntitiesDeletedInSameTxInIndexSeek using {0} with {1} index for {2}")
@MethodSource("data")
public void shouldNotIncludeEntitiesDeletedInSameTxInIndexSeek(DataSet dataSet, IndexingMode withIndex, EntityControl entityControl) {
    createIndex(withIndex, dataSet.keys, entityControl);
    // GIVEN
    createEntities(db, entityControl, TOKEN_NAME, dataSet.keys, dataSet.nonMatching[0]);
    LongSet toDelete = createEntities(db, entityControl, TOKEN_NAME, dataSet.keys, dataSet.values, dataSet.nonMatching[1], dataSet.nonMatching[2]);
    MutableLongSet expected = createEntities(db, entityControl, TOKEN_NAME, dataSet.keys, dataSet.values);
    // WHEN
    LongSet found;
    try (Transaction tx = db.beginTx()) {
        LongIterator deleting = toDelete.longIterator();
        while (deleting.hasNext()) {
            long id = deleting.next();
            entityControl.deleteEntity(tx, id);
            expected.remove(id);
        }
        found = dataSet.indexSeek.findEntities(tx, dataSet.keys, dataSet.values, entityControl);
    }
    // THEN
    assertThat(found).isEqualTo(expected);
}
Also used : MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) LongSet(org.eclipse.collections.api.set.primitive.LongSet) LongIterator(org.eclipse.collections.api.iterator.LongIterator) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 40 with LongIterator

use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.

the class MutableLinearProbeLongHashSetTest method frozenIteratorFailsWhenParentSetIsClosed.

@Test
void frozenIteratorFailsWhenParentSetIsClosed() {
    set.addAll(1, 2, 3, 100, 200, 300);
    final LongIterator iter = set.freeze().longIterator();
    set.close();
    assertThrows(ConcurrentModificationException.class, iter::hasNext);
    assertThrows(ConcurrentModificationException.class, iter::next);
}
Also used : MutableLongIterator(org.eclipse.collections.api.iterator.MutableLongIterator) LongIterator(org.eclipse.collections.api.iterator.LongIterator) Test(org.junit.jupiter.api.Test)

Aggregations

LongIterator (org.eclipse.collections.api.iterator.LongIterator)45 Test (org.junit.Test)16 Test (org.junit.jupiter.api.Test)15 MutableLongSet (org.eclipse.collections.api.set.primitive.MutableLongSet)9 MutableLongIterator (org.eclipse.collections.api.iterator.MutableLongIterator)5 MutableLongCollection (org.eclipse.collections.api.collection.primitive.MutableLongCollection)4 LongSet (org.eclipse.collections.api.set.primitive.LongSet)3 IndexReaderStub (org.neo4j.kernel.api.impl.index.IndexReaderStub)3 LazyLongIterable (org.eclipse.collections.api.LazyLongIterable)2 LongIterable (org.eclipse.collections.api.LongIterable)2 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 RelationshipChangesForNode.createRelationshipChangesForNode (org.neo4j.kernel.impl.api.state.RelationshipChangesForNode.createRelationshipChangesForNode)2 IOException (java.io.IOException)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 MutableLongList (org.eclipse.collections.api.list.primitive.MutableLongList)1 ImmutableEmptyLongIterator (org.eclipse.collections.impl.iterator.ImmutableEmptyLongIterator)1 AbstractPrimitiveLongBaseIterator (org.neo4j.collection.PrimitiveLongCollections.AbstractPrimitiveLongBaseIterator)1 RangeLongIterator (org.neo4j.collection.RangeLongIterator)1