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


Java GridUnsafe类代码示例

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


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

示例1: create

import org.apache.ignite.internal.util.GridUnsafe; //导入依赖的package包/类
/**
 * Creates settings for specific table.
 *
 * @param cacheName Ignite cache name.
 * @param tableName Cassandra table name.
 * @return settings for target Cassandra table.
 */
private KeyValuePersistenceSettings create(String cacheName, String tableName) {
    PublicKeyValuePersistenceSettings keyValue = cacheSettings.get(cacheName);
    if (keyValue == null) {
        keyValue = new PublicKeyValuePersistenceSettings(null, null, defaultKeySettings, defaultValueSettings);
        cacheSettings.put(cacheName, keyValue);
    }
    try {
        Object instance = GridUnsafe.allocateInstance(KeyValuePersistenceSettings.class);
        set(instance, elvis(keyValue.getTTL(), generalSettings.getTTL()), "ttl");
        set(instance, generalSettings.getKeyspace(), "keyspace");
        set(instance, tableName, "tbl");
        set(instance, elvis(keyValue.getTableOptions(), generalSettings.getTableOptions()), "tblOptions");
        set(instance, generalSettings.getKeyspaceOptions(), "keyspaceOptions");
        set(instance, elvis(keyValue.getKeyPersistenceSettings(), defaultKeySettings), "keyPersistenceSettings");
        set(instance, elvis(keyValue.getValuePersistenceSettings(), defaultValueSettings), "valPersistenceSettings");
        return (KeyValuePersistenceSettings)instance;
    }
    catch (InstantiationException | NoSuchFieldException | IllegalAccessException e) {
        throw new IllegalStateException("Cannot create Settings");
    }
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:29,代码来源:KeyValuePersistenceSettingsRegistry.java

示例2: writeCharArray

import org.apache.ignite.internal.util.GridUnsafe; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void writeCharArray(char[] arr) throws IOException {
    writeInt(arr.length);

    int bytesToCp = arr.length << 1;

    requestFreeSize(bytesToCp);

    if (BIG_ENDIAN) {
        long off = BYTE_ARR_OFF + this.off;

        for (char val : arr) {
            GridUnsafe.putCharLE(bytes, off, val);

            off += 2;
        }
    }
    else
        GridUnsafe.copyMemory(arr, CHAR_ARR_OFF, bytes, BYTE_ARR_OFF + off, bytesToCp);

    onWrite(bytesToCp);
}
 
开发者ID:apache,项目名称:ignite,代码行数:23,代码来源:GridUnsafeDataOutput.java

示例3: writeDoubleArray

import org.apache.ignite.internal.util.GridUnsafe; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void writeDoubleArray(double[] val) {
    int cnt = val.length << 3;

    ensureCapacity(pos + cnt);

    if (BIG_ENDIAN) {
        for (double item : val) {
            writeLongFast(Double.doubleToLongBits(item));

            shift(8);
        }
    }
    else
        copyAndShift(val, GridUnsafe.DOUBLE_ARR_OFF, cnt);
}
 
开发者ID:apache,项目名称:ignite,代码行数:17,代码来源:BinaryAbstractOutputStream.java

示例4: writeFloatArray

import org.apache.ignite.internal.util.GridUnsafe; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void writeFloatArray(float[] val) {
    int cnt = val.length << 2;

    ensureCapacity(pos + cnt);

    if (BIG_ENDIAN) {
        for (float item : val) {
            writeIntFast(Float.floatToIntBits(item));

            shift(4);
        }
    }
    else
        copyAndShift(val, GridUnsafe.FLOAT_ARR_OFF, cnt);
}
 
开发者ID:apache,项目名称:ignite,代码行数:17,代码来源:BinaryAbstractOutputStream.java

示例5: toString

import org.apache.ignite.internal.util.GridUnsafe; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public String toString() {
    ByteBuffer buf = ByteBuffer.allocateDirect(pageData.length);
    buf.order(ByteOrder.nativeOrder());
    buf.put(pageData);

    long addr = GridUnsafe.bufferAddress(buf);

    try {
        return "PageSnapshot [fullPageId = " + fullPageId() + ", page = [\n"
            + PageIO.printPage(addr, pageData.length)
            + "],\nsuper = ["
            + super.toString() + "]]";
    }
    catch (IgniteCheckedException ignored) {
        return "Error during call'toString' of PageSnapshot [fullPageId=" + fullPageId() +
            ", pageData = " + Arrays.toString(pageData) + ", super=" + super.toString() + "]";
    }
    finally {
        GridUnsafe.cleanDirectBuffer(buf);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:23,代码来源:PageSnapshot.java

示例6: writeCharArray

import org.apache.ignite.internal.util.GridUnsafe; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void writeCharArray(char[] val) {
    int cnt = val.length << 1;

    ensureCapacity(pos + cnt);

    if (BIG_ENDIAN) {
        for (char item : val) {
            writeCharFast(item);

            shift(2);
        }
    }
    else
        copyAndShift(val, GridUnsafe.CHAR_ARR_OFF, cnt);
}
 
开发者ID:apache,项目名称:ignite,代码行数:17,代码来源:BinaryAbstractOutputStream.java

示例7: readDoubleArray

import org.apache.ignite.internal.util.GridUnsafe; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public double[] readDoubleArray(int cnt) {
    int len = cnt << 3;

    ensureEnoughData(len);

    double[] res = new double[cnt];

    if (BIG_ENDIAN) {
        for (int i = 0; i < res.length; i++) {
            long x = readLongFast();

            shift(8);

            res[i] = Double.longBitsToDouble(x);
        }
    }
    else
        copyAndShift(res, GridUnsafe.DOUBLE_ARR_OFF, len);

    return res;
}
 
开发者ID:apache,项目名称:ignite,代码行数:23,代码来源:BinaryAbstractInputStream.java

示例8: printPage

import org.apache.ignite.internal.util.GridUnsafe; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected void printPage(long addr, int pageSize, GridStringBuilder sb) throws IgniteCheckedException {
    sb.a("TrackingPage [\n\tlastSnapshotTag=").a(getLastSnapshotTag(addr))
        .a(",\n\tleftHalf={")
        .a("\n\t\tsize=").a(GridUnsafe.getShort(addr + SIZE_FIELD_OFFSET))
        .a("\n\t\tdata={");

    for (int i = 0; i < (countOfPageToTrack(pageSize) >> 3); i += 2)
        sb.appendHex(GridUnsafe.getShort(addr + BITMAP_OFFSET + i));

    sb.a("}\n\t},\n\trightHalf={")
        .a("\n\t\tsize=").a(GridUnsafe.getShort(addr + BITMAP_OFFSET + (countOfPageToTrack(pageSize) >> 3)))
        .a("\n\t\tdata={");

    for (int i = 0; i < (countOfPageToTrack(pageSize) >> 3); i += 2)
        sb.appendHex(GridUnsafe.getShort(addr + BITMAP_OFFSET + (countOfPageToTrack(pageSize) >> 3)
             + SIZE_FIELD_SIZE + i));

    sb.a("}\n\t}\n]");
}
 
开发者ID:apache,项目名称:ignite,代码行数:21,代码来源:TrackingPageIO.java

示例9: readHashSet

import org.apache.ignite.internal.util.GridUnsafe; //导入依赖的package包/类
/**
 * Reads {@link HashSet}.
 *
 * @param mapFieldOff Map field offset.
 * @return Set.
 * @throws ClassNotFoundException If class not found.
 * @throws IOException In case of error.
 */
@SuppressWarnings("unchecked")
HashSet<?> readHashSet(long mapFieldOff) throws ClassNotFoundException, IOException {
    try {
        HashSet<Object> set = (HashSet<Object>)GridUnsafe.allocateInstance(HashSet.class);

        handles.assign(set);

        setObject(set, mapFieldOff, readHashMap(true));

        return set;
    }
    catch (InstantiationException e) {
        throw new IOException(e);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:24,代码来源:OptimizedObjectInputStream.java

示例10: readLinkedHashSet

import org.apache.ignite.internal.util.GridUnsafe; //导入依赖的package包/类
/**
 * Reads {@link LinkedHashSet}.
 *
 * @param mapFieldOff Map field offset.
 * @return Set.
 * @throws ClassNotFoundException If class not found.
 * @throws IOException In case of error.
 */
@SuppressWarnings("unchecked")
LinkedHashSet<?> readLinkedHashSet(long mapFieldOff) throws ClassNotFoundException, IOException {
    try {
        LinkedHashSet<Object> set = (LinkedHashSet<Object>)GridUnsafe.allocateInstance(LinkedHashSet.class);

        handles.assign(set);

        setObject(set, mapFieldOff, readLinkedHashMap(true));

        return set;
    }
    catch (InstantiationException e) {
        throw new IOException(e);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:24,代码来源:OptimizedObjectInputStream.java

示例11: writeChar

import org.apache.ignite.internal.util.GridUnsafe; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void writeChar(char val) {
    lastFinished = buf.remaining() >= 2;

    if (lastFinished) {
        int pos = buf.position();

        long off = baseOff + pos;

        if (BIG_ENDIAN)
            GridUnsafe.putCharLE(heapArr, off, val);
        else
            GridUnsafe.putChar(heapArr, off, val);

        buf.position(pos + 2);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:18,代码来源:DirectByteBufferStreamImplV2.java

示例12: clearAt

import org.apache.ignite.internal.util.GridUnsafe; //导入依赖的package包/类
/**
 * @param idx Index to clear value at.
 * @param pred Test predicate.
 * @param absent Value to return if the cell is empty.
 * @return Value at the given index.
 */
public long clearAt(int idx, GridPredicate3<Integer, Long, Integer> pred, long absent) {
    long base = entryBase(idx);

    int grpId = GridUnsafe.getInt(base);
    int tag = GridUnsafe.getInt(base + 4);
    long pageId = GridUnsafe.getLong(base + 8);

    if ((pageId == REMOVED_PAGE_ID && grpId == REMOVED_CACHE_GRP_ID)
        || (pageId == EMPTY_PAGE_ID && grpId == EMPTY_CACHE_GRP_ID))
        return absent;

    if (pred.apply(grpId, pageId, tag)) {
        long res = valueAt(idx);

        setKeyAt(idx, REMOVED_CACHE_GRP_ID, REMOVED_PAGE_ID);
        setValueAt(idx, 0);

        return res;
    }
    else
        return absent;
}
 
开发者ID:apache,项目名称:ignite,代码行数:29,代码来源:FullPageIdTable.java

示例13: readCharArray

import org.apache.ignite.internal.util.GridUnsafe; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public char[] readCharArray() throws IOException {
    int arrSize = readInt();

    int bytesToCp = arrSize << 1;

    fromStream(bytesToCp);

    char[] arr = new char[arrSize];

    long off = BYTE_ARR_OFF + offset(bytesToCp);

    if (BIG_ENDIAN) {
        for (int i = 0; i < arr.length; i++) {
            arr[i] = GridUnsafe.getCharLE(buf, off);

            off += 2;
        }
    }
    else
        GridUnsafe.copyMemory(buf, off, arr, CHAR_ARR_OFF, bytesToCp);

    return arr;
}
 
开发者ID:apache,项目名称:ignite,代码行数:25,代码来源:GridUnsafeDataInput.java

示例14: writeLongArray

import org.apache.ignite.internal.util.GridUnsafe; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void writeLongArray(long[] val) {
    int cnt = val.length << 3;

    ensureCapacity(pos + cnt);

    if (BIG_ENDIAN) {
        for (long item : val) {
            writeLongFast(item);

            shift(8);
        }
    }
    else
        copyAndShift(val, GridUnsafe.LONG_ARR_OFF, cnt);
}
 
开发者ID:apache,项目名称:ignite,代码行数:17,代码来源:BinaryAbstractOutputStream.java

示例15: readLong

import org.apache.ignite.internal.util.GridUnsafe; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public long readLong() {
    lastFinished = false;

    long val = 0;

    while (buf.hasRemaining()) {
        int pos = buf.position();

        byte b = GridUnsafe.getByte(heapArr, baseOff + pos);

        buf.position(pos + 1);

        prim |= ((long)b & 0x7F) << (7 * primShift);

        if ((b & 0x80) == 0) {
            lastFinished = true;

            val = prim;

            if (val == Long.MIN_VALUE)
                val = Long.MAX_VALUE;
            else
                val--;

            prim = 0;
            primShift = 0;

            break;
        }
        else
            primShift++;
    }

    return val;
}
 
开发者ID:apache,项目名称:ignite,代码行数:37,代码来源:DirectByteBufferStreamImplV2.java


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