Search in sources :

Example 41 with LongIterator

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

the class MutableLinearProbeLongHashSetTest method frozenIterator.

@Test
void frozenIterator() {
    set.addAll(1, 2, 3, 100, 200, 300);
    final LongIterator iter1 = set.freeze().longIterator();
    set.removeAll(1, 100);
    final LongIterator iter2 = set.freeze().longIterator();
    set.removeAll(2, 200);
    final LongSet values1 = drain(iter1);
    final LongSet values2 = drain(iter2);
    assertEquals(newSetWith(1, 2, 3, 100, 200, 300), values1);
    assertEquals(newSetWith(2, 3, 200, 300), values2);
}
Also used : MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) LongSet(org.eclipse.collections.api.set.primitive.LongSet) MutableLongIterator(org.eclipse.collections.api.iterator.MutableLongIterator) LongIterator(org.eclipse.collections.api.iterator.LongIterator) Test(org.junit.jupiter.api.Test)

Example 42 with LongIterator

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

the class SchemaComplianceChecker method verifyIndexedUniquely.

private <ENTITY extends PrimitiveRecord> void verifyIndexedUniquely(ENTITY entity, Value[] propertyValues, IndexDescriptor indexRule, ValueIndexReader reader, Function<ENTITY, ConsistencyReport.PrimitiveConsistencyReport> reportSupplier) {
    long nodeId = entity.getId();
    PropertyIndexQuery[] query = seek(indexRule.schema(), propertyValues);
    LongIterator indexedNodeIds = queryIndexOrEmpty(reader, query);
    long count = 0;
    while (indexedNodeIds.hasNext()) {
        long indexedNodeId = indexedNodeIds.next();
        if (nodeId == indexedNodeId) {
            count++;
        } else {
            reportSupplier.apply(entity).uniqueIndexNotUnique(indexRule, Values.asObjects(propertyValues), indexedNodeId);
        }
    }
    reportIncorrectIndexCount(entity, propertyValues, indexRule, count, reportSupplier);
}
Also used : PropertyIndexQuery(org.neo4j.internal.kernel.api.PropertyIndexQuery) LongIterator(org.eclipse.collections.api.iterator.LongIterator)

Example 43 with LongIterator

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

the class PrimitiveLongCollectionsTest method count.

@Test
void count() {
    // GIVEN
    LongIterator items = PrimitiveLongCollections.iterator(1, 2, 3);
    // WHEN
    int count = PrimitiveLongCollections.count(items);
    // THEN
    assertEquals(3, count);
}
Also used : LongIterator(org.eclipse.collections.api.iterator.LongIterator) Test(org.junit.jupiter.api.Test)

Example 44 with LongIterator

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

the class PrimitiveLongCollectionsTest method filter.

@Test
void filter() {
    // GIVEN
    LongIterator items = PrimitiveLongCollections.iterator(1, 2, 3);
    // WHEN
    LongIterator filtered = PrimitiveLongCollections.filter(items, item -> item != 2);
    // THEN
    assertItems(filtered, 1, 3);
}
Also used : LongIterator(org.eclipse.collections.api.iterator.LongIterator) Test(org.junit.jupiter.api.Test)

Example 45 with LongIterator

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

the class IndexSamplingController method indexesToSample.

private LongList indexesToSample(IndexSamplingMode mode, IndexMap indexMap) {
    MutableLongList indexesToSample = LongLists.mutable.of();
    LongIterator allIndexes = indexMap.indexIds();
    while (allIndexes.hasNext()) {
        long indexId = allIndexes.next();
        if (shouldSampleIndex(mode, indexId)) {
            indexesToSample.add(indexId);
        }
    }
    return indexesToSample;
}
Also used : MutableLongList(org.eclipse.collections.api.list.primitive.MutableLongList) LongIterator(org.eclipse.collections.api.iterator.LongIterator)

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