本文整理汇总了Java中org.apache.ignite.internal.util.GridUnsafe.putIntLE方法的典型用法代码示例。如果您正苦于以下问题:Java GridUnsafe.putIntLE方法的具体用法?Java GridUnsafe.putIntLE怎么用?Java GridUnsafe.putIntLE使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.internal.util.GridUnsafe
的用法示例。
在下文中一共展示了GridUnsafe.putIntLE方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeIntArray
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void writeIntArray(int[] arr) throws IOException {
writeInt(arr.length);
int bytesToCp = arr.length << 2;
requestFreeSize(bytesToCp);
if (BIG_ENDIAN) {
long off = BYTE_ARR_OFF + this.off;
for (int val : arr) {
GridUnsafe.putIntLE(bytes, off, val);
off += 4;
}
}
else
GridUnsafe.copyMemory(arr, INT_ARR_OFF, bytes, BYTE_ARR_OFF + off, bytesToCp);
onWrite(bytesToCp);
}
示例2: writeInt
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
* @param arr Array.
* @param off Offset.
* @param val Value.
*/
public static void writeInt(byte[] arr, int off, int val) {
long pos = GridUnsafe.BYTE_ARR_OFF + off;
if (BIG_ENDIAN)
GridUnsafe.putIntLE(arr, pos, val);
else
GridUnsafe.putInt(arr, pos, val);
}
示例3: writeIntFast
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected void writeIntFast(int val) {
long addr = ptr + pos;
if (BIG_ENDIAN)
GridUnsafe.putIntLE(addr, val);
else
GridUnsafe.putInt(addr, val);
}
示例4: unsafeWriteInt
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void unsafeWriteInt(int val) {
long addr = ptr + pos;
if (BIG_ENDIAN)
GridUnsafe.putIntLE(addr, val);
else
GridUnsafe.putInt(addr, val);
shift(4);
}
示例5: writeIntFast
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected void writeIntFast(int val) {
long off = GridUnsafe.BYTE_ARR_OFF + pos;
if (BIG_ENDIAN)
GridUnsafe.putIntLE(data, off, val);
else
GridUnsafe.putInt(data, off, val);
}
示例6: unsafeWriteInt
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void unsafeWriteInt(int val) {
long off = GridUnsafe.BYTE_ARR_OFF + pos;
if (BIG_ENDIAN)
GridUnsafe.putIntLE(data, off, val);
else
GridUnsafe.putInt(data, off, val);
shift(4);
}
示例7: writeInt
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void writeInt(int v) throws IOException {
requestFreeSize(4);
long off = BYTE_ARR_OFF + this.off;
if (BIG_ENDIAN)
GridUnsafe.putIntLE(bytes, off, v);
else
GridUnsafe.putInt(bytes, off, v);
onWrite(4);
}
示例8: testOffheapBinary
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testOffheapBinary() throws Exception {
BinaryObjectBuilder builder = builder("Class");
builder.setField("i", 111);
builder.setField("f", 111.111f);
builder.setField("iArr", new int[] {1, 2, 3});
builder.setField("obj", new Key(1));
builder.setField("col", Arrays.asList(new Value(1), new Value(2)), Collection.class);
BinaryObject po = builder.build();
byte[] arr = ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).marshal(po);
long ptr = GridUnsafe.allocateMemory(arr.length + 5);
try {
long ptr0 = ptr;
GridUnsafe.putBoolean(null, ptr0++, false);
int len = arr.length;
if (BIG_ENDIAN)
GridUnsafe.putIntLE(ptr0, len);
else
GridUnsafe.putInt(ptr0, len);
GridUnsafe.copyHeapOffheap(arr, GridUnsafe.BYTE_ARR_OFF, ptr0 + 4, arr.length);
BinaryObject offheapObj = (BinaryObject)
((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).unmarshal(ptr, false);
assertEquals(BinaryObjectOffheapImpl.class, offheapObj.getClass());
assertEquals(expectedHashCode("Class"), offheapObj.type().typeId());
assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), offheapObj.hashCode());
assertEquals(111, offheapObj.<Integer>field("i").intValue());
assertEquals(111.111f, offheapObj.<Float>field("f").floatValue(), 0);
assertTrue(Arrays.equals(new int[] {1, 2, 3}, offheapObj.<int[]>field("iArr")));
assertEquals(1, offheapObj.<BinaryObject>field("obj").<Key>deserialize().i);
List<BinaryObject> list = offheapObj.field("col");
assertEquals(2, list.size());
assertEquals(1, list.get(0).<Value>deserialize().i);
assertEquals(2, list.get(1).<Value>deserialize().i);
assertEquals(po, offheapObj);
assertEquals(offheapObj, po);
}
finally {
GridUnsafe.freeMemory(ptr);
}
}