Search in sources :

Example 81 with MutableLongSet

use of org.eclipse.collections.api.set.primitive.MutableLongSet in project neo4j by neo4j.

the class RelationshipTransactionStateTestBase method assertRelationships.

private void assertRelationships(NodeCursor node, RelationshipTraversalCursor traversal, RelationshipSelection selection, long... relationships) {
    node.relationships(traversal, selection);
    MutableLongSet set = LongHashSet.newSetWith(relationships);
    for (long relationship : relationships) {
        assertTrue(traversal.next());
        assertTrue(set.contains(traversal.relationshipReference()));
        set.remove(traversal.relationshipReference());
    }
    assertTrue(set.isEmpty());
    assertFalse(traversal.next());
}
Also used : MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet)

Example 82 with MutableLongSet

use of org.eclipse.collections.api.set.primitive.MutableLongSet in project neo4j by neo4j.

the class FreeListIdProviderTest method shouldVisitUnacquiredIds.

@Test
void shouldVisitUnacquiredIds() throws Exception {
    // GIVEN a couple of released ids
    MutableLongSet expected = new LongHashSet();
    for (int i = 0; i < 100; i++) {
        expected.add(freelist.acquireNewId(GENERATION_ONE, GENERATION_TWO, NULL));
    }
    expected.forEach(id -> {
        try {
            freelist.releaseId(GENERATION_ONE, GENERATION_TWO, id, NULL);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    });
    // and only a few acquired
    for (int i = 0; i < 10; i++) {
        long acquiredId = freelist.acquireNewId(GENERATION_TWO, GENERATION_THREE, NULL);
        assertTrue(expected.remove(acquiredId));
    }
    // WHEN/THEN
    freelist.visitFreelist(new IdProvider.IdProviderVisitor.Adaptor() {

        @Override
        public void freelistEntry(long pageId, long generation, int pos) {
            assertTrue(expected.remove(pageId));
        }
    }, NULL);
    assertTrue(expected.isEmpty());
}
Also used : LongHashSet(org.eclipse.collections.impl.set.mutable.primitive.LongHashSet) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Example 83 with MutableLongSet

use of org.eclipse.collections.api.set.primitive.MutableLongSet in project mapdb by jankotek.

the class LongLongHashMapKeySetTest method testEquals.

@Override
public void testEquals() {
    MutableLongSet set1 = this.newWith(1L, 31L, 32L);
    MutableLongSet set2 = this.newWith(32L, 31L, 1L);
    MutableLongSet set3 = this.newWith(32L, 32L, 31L, 1L);
    MutableLongSet set4 = this.newWith(32L, 32L, 31L, 1L, 1L);
    MutableLongSet set5 = this.newWith(32L, 1L);
    Verify.assertEqualsAndHashCode(set1, set2);
    Verify.assertEqualsAndHashCode(set1, set3);
    Verify.assertEqualsAndHashCode(set1, set4);
    Verify.assertEqualsAndHashCode(set2, set3);
    Verify.assertEqualsAndHashCode(set2, set4);
    Assert.assertNotEquals(set1, set5);
}
Also used : MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet)

Example 84 with MutableLongSet

use of org.eclipse.collections.api.set.primitive.MutableLongSet in project mapdb by jankotek.

the class AbstractLongSetTestCase method addAllIterable.

@Override
@Test
public void addAllIterable() {
    super.addAllIterable();
    MutableLongSet set = this.newWith(0L, 1L, 31L, AbstractLongSetTestCase.generateCollisions1().getFirst(), AbstractLongSetTestCase.generateCollisions1().get(1));
    Assert.assertFalse(set.addAll(new LongArrayList()));
    Assert.assertFalse(set.addAll(LongArrayList.newListWith(31L, AbstractLongSetTestCase.generateCollisions1().get(0), AbstractLongSetTestCase.generateCollisions1().get(1))));
    Assert.assertEquals(LongHashSet.newSetWith(0L, 1L, 31L, AbstractLongSetTestCase.generateCollisions1().getFirst(), AbstractLongSetTestCase.generateCollisions1().get(1)), set);
    Assert.assertTrue(set.addAll(LongHashSet.newSetWith(0L, 1L, 2L, 30L, AbstractLongSetTestCase.generateCollisions1().getFirst(), AbstractLongSetTestCase.generateCollisions1().get(4))));
    Assert.assertEquals(LongHashSet.newSetWith(0L, 1L, 2L, 30L, 31L, AbstractLongSetTestCase.generateCollisions1().getFirst(), AbstractLongSetTestCase.generateCollisions1().get(1), AbstractLongSetTestCase.generateCollisions1().get(4)), set);
    Assert.assertTrue(set.addAll(LongHashSet.newSetWith(5L)));
    Assert.assertEquals(LongHashSet.newSetWith(0L, 1L, 2L, 5L, 30L, 31L, AbstractLongSetTestCase.generateCollisions1().getFirst(), AbstractLongSetTestCase.generateCollisions1().get(1), AbstractLongSetTestCase.generateCollisions1().get(4)), set);
    Assert.assertTrue(set.addAll(LongHashSet.newSetWith(AbstractLongSetTestCase.generateCollisions1().get(5))));
    Assert.assertEquals(LongHashSet.newSetWith(0L, 1L, 2L, 5L, 30L, 31L, AbstractLongSetTestCase.generateCollisions1().getFirst(), AbstractLongSetTestCase.generateCollisions1().get(1), AbstractLongSetTestCase.generateCollisions1().get(4), AbstractLongSetTestCase.generateCollisions1().get(5)), set);
    LongHashSet set1 = new LongHashSet();
    Assert.assertTrue(set1.addAll(2L, 35L));
    Assert.assertEquals(LongHashSet.newSetWith(2L, 35L), set1);
}
Also used : LongHashSet(org.eclipse.collections.impl.set.mutable.primitive.LongHashSet) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) Test(org.junit.Test)

Example 85 with MutableLongSet

use of org.eclipse.collections.api.set.primitive.MutableLongSet in project mapdb by jankotek.

the class AbstractLongSetTestCase method reject.

@Override
@Test
public void reject() {
    super.reject();
    MutableLongSet set = this.newWith(0L, 1L, 31L, AbstractLongSetTestCase.generateCollisions1().getFirst(), AbstractLongSetTestCase.generateCollisions1().get(1));
    Verify.assertSize(1, set.reject(LongPredicates.greaterThan(0L)));
    Verify.assertSize(2, set.reject(LongPredicates.lessThan(32L)));
}
Also used : MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) Test(org.junit.Test)

Aggregations

MutableLongSet (org.eclipse.collections.api.set.primitive.MutableLongSet)153 LongHashSet (org.eclipse.collections.impl.set.mutable.primitive.LongHashSet)57 Test (org.junit.jupiter.api.Test)54 Test (org.junit.Test)49 IndexReadSession (org.neo4j.internal.kernel.api.IndexReadSession)17 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)17 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)14 ArrayList (java.util.ArrayList)13 IndexValueCapability (org.neo4j.internal.schema.IndexValueCapability)12 LongIterator (org.eclipse.collections.api.iterator.LongIterator)10 LongSet (org.eclipse.collections.api.set.primitive.LongSet)9 Value (org.neo4j.values.storable.Value)8 Map (java.util.Map)7 MutableLongList (org.eclipse.collections.api.list.primitive.MutableLongList)7 Transaction (org.neo4j.graphdb.Transaction)7 Write (org.neo4j.internal.kernel.api.Write)7 NavigableMap (java.util.NavigableMap)6 UnmodifiableMap (org.eclipse.collections.impl.UnmodifiableMap)6 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)6 IndexQueryConstraints (org.neo4j.internal.kernel.api.IndexQueryConstraints)6