/** * @param initSize Initial size. * @param order Byte order. */ public ByteBufferExpander(int initSize, ByteOrder order) { ByteBuffer buffer = GridUnsafe.allocateBuffer(initSize); buffer.order(order); buf = buffer; }
/** */ @Test public void testBuffers() { ByteBuffer b1 = GridUnsafe.allocateBuffer(10); ByteBuffer b2 = GridUnsafe.allocateBuffer(20); assertEquals(GridUnsafe.NATIVE_BYTE_ORDER, b2.order()); assertTrue(b2.isDirect()); assertEquals(20, b2.capacity()); assertEquals(20, b2.limit()); assertEquals(0, b2.position()); assertEquals(GridUnsafe.NATIVE_BYTE_ORDER, b1.order()); assertTrue(b1.isDirect()); assertEquals(10, b1.capacity()); assertEquals(10, b1.limit()); assertEquals(0, b1.position()); b1.putLong(1L); b1.putShort((short)7); b2.putLong(2L); GridUnsafe.freeBuffer(b1); b2.putLong(3L); b2.putInt(9); for (int i = 0; i <= 16; i++) b2.putInt(i, 100500); GridUnsafe.freeBuffer(b2); }
buf = GridUnsafe.allocateBuffer(expHead.chainSize());
/** * @param initSize Initial size. * @param order Byte order. */ public ByteBufferExpander(int initSize, ByteOrder order) { ByteBuffer buffer = GridUnsafe.allocateBuffer(initSize); buffer.order(order); buf = buffer; }
buf = GridUnsafe.allocateBuffer(expHead.chainSize());