Search in sources :

Example 36 with GridLongList

use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.

the class GridLongListSelfTest method testTruncate.

/**
 */
@Test
public void testTruncate() {
    GridLongList list = asList(1, 2, 3, 4, 5, 6, 7, 8);
    list.truncate(4, true);
    assertEquals(asList(1, 2, 3, 4), list);
    list.truncate(2, false);
    assertEquals(asList(3, 4), list);
    list = new GridLongList();
    list.truncate(0, false);
    list.truncate(0, true);
    assertEquals(new GridLongList(), list);
}
Also used : GridLongList(org.apache.ignite.internal.util.GridLongList) Test(org.junit.Test)

Example 37 with GridLongList

use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.

the class GridLongListSelfTest method testArray.

/**
 */
@Test
public void testArray() {
    GridLongList list = new GridLongList();
    long[] array = list.array();
    assertNotNull(array);
    assertEquals(0, array.length);
    list.add(1L);
    array = list.array();
    assertNotNull(array);
    assertEquals(1, array.length);
    assertEquals(1L, array[0]);
}
Also used : GridLongList(org.apache.ignite.internal.util.GridLongList) Test(org.junit.Test)

Example 38 with GridLongList

use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.

the class GridLongListSelfTest method testCopyWithout.

/**
 * @throws Exception If failed.
 */
@SuppressWarnings("ZeroLengthArrayAllocation")
@Test
public void testCopyWithout() throws Exception {
    assertCopy(new GridLongList(new long[] {}), new GridLongList(new long[] {}));
    assertCopy(new GridLongList(new long[] {}), new GridLongList(new long[] { 1 }));
    assertCopy(new GridLongList(new long[] { 1 }), new GridLongList(new long[] {}));
    assertCopy(new GridLongList(new long[] { 1, 2, 3 }), new GridLongList(new long[] { 4, 5, 6 }));
    assertCopy(new GridLongList(new long[] { 1, 2, 3 }), new GridLongList(new long[] { 1, 2, 3 }));
    assertCopy(new GridLongList(new long[] { 1, 2, 3, 4, 5, 1 }), new GridLongList(new long[] { 1, 1 }));
    assertCopy(new GridLongList(new long[] { 1, 1, 1, 2, 3, 4, 5, 1, 1, 1 }), new GridLongList(new long[] { 1, 1 }));
    assertCopy(new GridLongList(new long[] { 1, 2, 3 }), new GridLongList(new long[] { 1, 1, 2, 2, 3, 3 }));
}
Also used : GridLongList(org.apache.ignite.internal.util.GridLongList) Test(org.junit.Test)

Example 39 with GridLongList

use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.

the class GridLongListSelfTest method testSerializationInsufficientBuffer.

/**
 */
@Test
public void testSerializationInsufficientBuffer() {
    MessageWriter writer = new DirectMessageWriter(GridIoManager.DIRECT_PROTO_VER);
    ByteBuffer buf = ByteBuffer.allocate(10);
    GridLongList ll = new GridLongList(new long[] { 1L, 2L, 3L });
    Assert.assertFalse(ll.writeTo(buf, writer));
    Assert.assertEquals(10, buf.position());
}
Also used : DirectMessageWriter(org.apache.ignite.internal.direct.DirectMessageWriter) GridLongList(org.apache.ignite.internal.util.GridLongList) DirectMessageWriter(org.apache.ignite.internal.direct.DirectMessageWriter) MessageWriter(org.apache.ignite.plugin.extensions.communication.MessageWriter) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

GridLongList (org.apache.ignite.internal.util.GridLongList)39 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)6 ByteBuffer (java.nio.ByteBuffer)5 DirectMessageWriter (org.apache.ignite.internal.direct.DirectMessageWriter)5 MessageWriter (org.apache.ignite.plugin.extensions.communication.MessageWriter)5 Map (java.util.Map)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 ClusterNode (org.apache.ignite.cluster.ClusterNode)4 IgniteException (org.apache.ignite.IgniteException)3 PagesListAddPageRecord (org.apache.ignite.internal.pagemem.wal.record.delta.PagesListAddPageRecord)3 PagesListInitNewPageRecord (org.apache.ignite.internal.pagemem.wal.record.delta.PagesListInitNewPageRecord)3 PagesListSetNextRecord (org.apache.ignite.internal.pagemem.wal.record.delta.PagesListSetNextRecord)3 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 TreeMap (java.util.TreeMap)2 UUID (java.util.UUID)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 PagesListMetaIO (org.apache.ignite.internal.processors.cache.persistence.freelist.io.PagesListMetaIO)2