Search in sources :

Example 11 with HashSlotCursor16byteKey

use of com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey in project hazelcast by hazelcast.

the class HashSlotArray16byteKeyImplTest method testCursor_valueAddress.

@Test
public void testCursor_valueAddress() {
    final long valueAddress = insert(randomKey(), randomKey());
    HashSlotCursor16byteKey cursor = hsa.cursor();
    cursor.advance();
    assertEquals(valueAddress, cursor.valueAddress());
}
Also used : HashSlotCursor16byteKey(com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 12 with HashSlotCursor16byteKey

use of com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey in project hazelcast by hazelcast.

the class HashSlotArray16byteKeyImplTest method testCursor_withManyValues.

@Test
public void testCursor_withManyValues() {
    final long factor = 123456;
    final int k = 1000;
    for (int i = 1; i <= k; i++) {
        long key1 = (long) i;
        long key2 = key1 * factor;
        insert(key1, key2);
    }
    boolean[] verifiedKeys = new boolean[k];
    HashSlotCursor16byteKey cursor = hsa.cursor();
    while (cursor.advance()) {
        long key1 = cursor.key1();
        long key2 = cursor.key2();
        long valueAddress = cursor.valueAddress();
        assertEquals(key1 * factor, key2);
        verifyValue(key1, key2, valueAddress);
        verifiedKeys[((int) key1) - 1] = true;
    }
    for (int i = 0; i < k; i++) {
        assertTrue("Failed to encounter key " + i, verifiedKeys[i]);
    }
}
Also used : HashSlotCursor16byteKey(com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 13 with HashSlotCursor16byteKey

use of com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey in project hazelcast by hazelcast.

the class HashSlotArray16byteKeyImplTest method testCursor_key2_whenDisposed.

@Test(expected = AssertionError.class)
public void testCursor_key2_whenDisposed() {
    HashSlotCursor16byteKey cursor = hsa.cursor();
    hsa.dispose();
    cursor.key2();
}
Also used : HashSlotCursor16byteKey(com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 14 with HashSlotCursor16byteKey

use of com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey in project hazelcast by hazelcast.

the class HashSlotArray16byteKeyNoValueTest method testCursor_key2_whenDisposed.

@Test(expected = AssertionError.class)
@RequireAssertEnabled
public void testCursor_key2_whenDisposed() {
    HashSlotCursor16byteKey cursor = hsa.cursor();
    hsa.dispose();
    cursor.key2();
}
Also used : HashSlotCursor16byteKey(com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey) RequireAssertEnabled(com.hazelcast.test.RequireAssertEnabled) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 15 with HashSlotCursor16byteKey

use of com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey in project hazelcast by hazelcast.

the class HashSlotArray16byteKeyNoValueTest method testCursor_key1_withoutAdvance.

@Test(expected = AssertionError.class)
@RequireAssertEnabled
public void testCursor_key1_withoutAdvance() {
    HashSlotCursor16byteKey cursor = hsa.cursor();
    cursor.key1();
}
Also used : HashSlotCursor16byteKey(com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey) RequireAssertEnabled(com.hazelcast.test.RequireAssertEnabled) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

HashSlotCursor16byteKey (com.hazelcast.internal.util.hashslot.HashSlotCursor16byteKey)28 QuickTest (com.hazelcast.test.annotation.QuickTest)28 Test (org.junit.Test)28 RequireAssertEnabled (com.hazelcast.test.RequireAssertEnabled)11