当前位置: 首页>>代码示例>>Java>>正文


Java GridUnsafe.copyHeapOffheap方法代码示例

本文整理汇总了Java中org.apache.ignite.internal.util.GridUnsafe.copyHeapOffheap方法的典型用法代码示例。如果您正苦于以下问题:Java GridUnsafe.copyHeapOffheap方法的具体用法?Java GridUnsafe.copyHeapOffheap怎么用?Java GridUnsafe.copyHeapOffheap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ignite.internal.util.GridUnsafe的用法示例。


在下文中一共展示了GridUnsafe.copyHeapOffheap方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyAndShift

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
 * Copy source object to the stream shifting position afterwards.
 *
 * @param src Source.
 * @param off Offset.
 * @param len Length.
 */
private void copyAndShift(Object src, long off, int len) {
    ensureCapacity(pos + len);

    GridUnsafe.copyHeapOffheap(src, off, data + pos, len);

    shift(len);
}
 
开发者ID:apache,项目名称:ignite,代码行数:15,代码来源:PlatformOutputStreamImpl.java

示例2: write

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void write(byte[] b, int off, int len) {
    GridUnsafe.copyHeapOffheap(b, GridUnsafe.BYTE_ARR_OFF + off, move(len), len);
}
 
开发者ID:apache,项目名称:ignite,代码行数:5,代码来源:HadoopDataOutStream.java

示例3: copyTo

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** */
@Override public void copyTo(long ptr) {
    GridUnsafe.copyHeapOffheap(buf, GridUnsafe.BYTE_ARR_OFF + off, ptr, size);
}
 
开发者ID:apache,项目名称:ignite,代码行数:5,代码来源:HadoopShuffleJob.java

示例4: copyAndShift

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected void copyAndShift(Object src, long offset, int len) {
    GridUnsafe.copyHeapOffheap(src, offset, ptr + pos, len);

    shift(len);
}
 
开发者ID:apache,项目名称:ignite,代码行数:7,代码来源:BinaryOffheapOutputStream.java

示例5: 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);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:60,代码来源:BinaryObjectBuilderDefaultMappersSelfTest.java

示例6: copyOffheap

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
 * @param obj Object.
 * @return Offheap address.
 */
private long copyOffheap(BinaryObjectImpl obj) {
    byte[] arr = obj.array();

    long ptr = GridUnsafe.allocateMemory(arr.length);

    GridUnsafe.copyHeapOffheap(arr, GridUnsafe.BYTE_ARR_OFF, ptr, arr.length);

    return ptr;
}
 
开发者ID:apache,项目名称:ignite,代码行数:14,代码来源:BinaryMarshallerSelfTest.java

示例7: toBinary

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected BinaryObjectExImpl toBinary(BinaryMarshaller marsh, Object obj) throws Exception {
    byte[] arr = marsh.marshal(obj);

    long ptr = GridUnsafe.allocateMemory(arr.length);

    ptrs.add(ptr);

    GridUnsafe.copyHeapOffheap(arr, GridUnsafe.BYTE_ARR_OFF, ptr, arr.length);

    return new BinaryObjectOffheapImpl(ctx, ptr, 0, arr.length);
}
 
开发者ID:apache,项目名称:ignite,代码行数:13,代码来源:BinaryFooterOffsetsOffheapSelfTest.java

示例8: toBinary

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected BinaryObjectExImpl toBinary(BinaryMarshaller marsh, Object obj) throws Exception {
    byte[] arr = marsh.marshal(obj);

    long ptr = GridUnsafe.allocateMemory(arr.length);

    ptrs.add(ptr);

    GridUnsafe.copyHeapOffheap(arr, GridUnsafe.BYTE_ARR_OFF, ptr, arr.length);

    return new BinaryObjectOffheapImpl(binaryContext(marsh), ptr, 0, arr.length);
}
 
开发者ID:apache,项目名称:ignite,代码行数:13,代码来源:BinaryFieldsOffheapSelfTest.java

示例9: writeBytes

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
 * Writes byte array into memory location.
 *
 * @param ptr Pointer.
 * @param arr Array.
 */
public void writeBytes(long ptr, byte[] arr) {
    GridUnsafe.copyHeapOffheap(arr, GridUnsafe.BYTE_ARR_OFF, ptr, arr.length);
}
 
开发者ID:apache,项目名称:ignite,代码行数:10,代码来源:GridUnsafeMemory.java


注:本文中的org.apache.ignite.internal.util.GridUnsafe.copyHeapOffheap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。