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


Java U.arrayCopy方法代码示例

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


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

示例1: flatten

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Copies cached data if specified position matches cached region.
 *
 * @param dst Destination buffer.
 * @param pos Read position in file.
 * @param dstOff Offset in destination buffer from which start writing.
 * @param len Maximum number of bytes to copy.
 * @return Number of bytes copied.
 * @throws IgniteCheckedException If read future failed.
 */
public int flatten(byte[] dst, long pos, int dstOff, int len) throws IgniteCheckedException {
    // If read start position is within cached boundaries.
    if (contains(pos)) {
        byte[] data = readFut.get();

        int srcPos = (int)(pos - this.pos);
        int cpLen = Math.min(len, data.length - srcPos);

        U.arrayCopy(data, srcPos, dst, dstOff, cpLen);

        return cpLen;
    }

    return 0;
}
 
开发者ID:apache,项目名称:ignite,代码行数:26,代码来源:HadoopIgfsInputStream.java

示例2: updateMetaData

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Updates meta data.
 *
 * @throws SQLException In case of error.
 */
private void updateMetaData() throws SQLException {
    if (conn.isClosed())
        throw new SQLException("Connection is closed.");

    try {
        byte[] packet = conn.client().compute().execute(TASK_NAME, conn.cacheName());

        byte status = packet[0];
        byte[] data = new byte[packet.length - 1];

        U.arrayCopy(packet, 1, data, 0, data.length);

        if (status == 1)
            throw JdbcUtils.unmarshalError(data);
        else {
            List<Object> res = JdbcUtils.unmarshal(data);

            meta = (Map<String, Map<String, Map<String, String>>>)res.get(0);
            indexes = (Collection<List<Object>>)res.get(1);
        }
    }
    catch (GridClientException e) {
        throw new SQLException("Failed to get meta data from Ignite.", e);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:31,代码来源:JdbcDatabaseMetadata.java

示例3: process

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public Void process(MutableEntry<IgfsBlockKey, byte[]> entry, Object... args) {
    byte[] e = entry.getValue();

    final int size = data.length;

    if (e == null || e.length == 0)
        e = new byte[start + size]; // Don't allocate more, then required.
    else if (e.length < start + size) {
        // Expand stored data array, if it less, then required.
        byte[] tmp = new byte[start + size]; // Don't allocate more than required.

        U.arrayCopy(e, 0, tmp, 0, e.length);

        e = tmp;
    }

    // Copy data into entry.
    U.arrayCopy(data, 0, e, start, size);

    entry.setValue(e);

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

示例4: write

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Writes <code>len</code> bytes from the specified byte array
 * starting at offset <code>off</code> to this byte array output stream.
 *
 * @param b   the data.
 * @param off the start offset in the data.
 * @param len the number of bytes to write.
 */
@Override public void write(byte b[], int off, int len) {
    if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0))
        throw new IndexOutOfBoundsException();
    else if (len == 0)
        return;

    int newCnt = cnt + len;

    if (newCnt > buf.length)
        buf = Arrays.copyOf(buf, Math.max(buf.length << 1, newCnt));

    U.arrayCopy(b, off, buf, cnt, len);

    cnt = newCnt;
}
 
开发者ID:apache,项目名称:ignite,代码行数:24,代码来源:GridByteArrayOutputStream.java

示例5: read

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Reads up to {@code len} bytes of data into an array of bytes from this input stream.
 * If {@code pos} equals {@code count}, then {@code -1} is returned to indicate
 * end of file. Otherwise, the  number {@code k} of bytes read is equal to the smaller of
 * {@code len} and {@code count-pos}. If {@code k} is positive, then bytes
 * {@code buf[pos]} through {@code buf[pos+k-1]} are copied into {@code b[off]} through
 * {@code b[off+k-1]} in the manner performed by {@code System.arraycopy}. The value
 * {@code k} is added into {@code pos} and {@code k} is returned.
 * <p>
 * This {@code read} method cannot block.
 *
 * @param b The buffer into which the data is read.
 * @param off The start offset in the destination array {@code b}
 * @param len The maximum number of bytes read.
 * @return The total number of bytes read into the buffer, or
 *      {@code -1} if there is no more data because the end of
 *      the stream has been reached.
 * @throws NullPointerException If {@code b} is {@code null}.
 * @throws IndexOutOfBoundsException If {@code off} is negative,
 *      {@code len} is negative, or {@code len} is greater than {@code b.length - off}
 */
@Override public int read(byte b[], int off, int len) {
    if (b == null)
        throw new NullPointerException();
    else if (off < 0 || len < 0 || len > b.length - off)
        throw new IndexOutOfBoundsException();

    if (pos >= cnt)
        return -1;

    if (pos + len > cnt)
        len = cnt - pos;

    if (len <= 0)
        return 0;

    U.arrayCopy(buf, pos, b, off, len);

    pos += len;

    return len;
}
 
开发者ID:apache,项目名称:ignite,代码行数:43,代码来源:GridByteArrayInputStream.java

示例6: toBytes

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @return Serialized checkpoint data.
 */
public byte[] toBytes() {
    byte[] keyBytes = key.getBytes();

    byte[] bytes = new byte[4 + state.length + 8 + 4 + keyBytes.length];

    U.intToBytes(state.length, bytes, 0);
    U.arrayCopy(state, 0, bytes, 4, state.length);
    U.longToBytes(expTime, bytes, 4 + state.length);
    U.intToBytes(keyBytes.length, bytes, 4 + state.length + 8);
    U.arrayCopy(keyBytes, 0, bytes, 4 + state.length + 8 + 4, keyBytes.length);

    return bytes;
}
 
开发者ID:apache,项目名称:ignite,代码行数:17,代码来源:S3CheckpointData.java

示例7: reduce

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public byte[] reduce(List<ComputeJobResult> results) throws IgniteException {
    try {
        byte status;
        byte[] bytes;

        ComputeJobResult res = F.first(results);

        if (res.getException() == null) {
            status = 0;

            bytes = U.marshal(MARSHALLER, res.getData());
        }
        else {
            status = 1;

            bytes = U.marshal(MARSHALLER, new SQLException(res.getException().getMessage()));
        }

        byte[] packet = new byte[bytes.length + 1];

        packet[0] = status;

        U.arrayCopy(bytes, 0, packet, 1, bytes.length);

        return packet;
    }
    catch (IgniteCheckedException e) {
        throw U.convertException(e);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:32,代码来源:GridCacheQueryJdbcTask.java

示例8: array

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Gets copy of internal array.
 *
 * @return Copy of internal array.
 */
public byte[] array() {
    byte[] res = new byte[size];

    U.arrayCopy(data, 0, res, 0, size);

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

示例9: add

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @param bytes Byte to add.
 * @param off Offset at which to add.
 * @param len Number of bytes to add.
 */
public void add(byte[] bytes, int off, int len) {
    requestFreeSize(len);

    U.arrayCopy(bytes, off, data, size, len);

    size += len;
}
 
开发者ID:apache,项目名称:ignite,代码行数:13,代码来源:GridByteArrayList.java

示例10: getBytes

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public byte[] getBytes(long pos, int len) throws SQLException {
    ensureNotClosed();

    if (pos < 1 || arr.length - pos < 0 || len < 0)
        throw new SQLException("Invalid argument. Position can't be less than 1 or " +
            "greater than size of underlying byte array. Requested length also can't be negative " + "" +
            "[pos=" + pos + ", len=" + len +']');

    int idx = (int)(pos - 1);

    int size = len > arr.length - idx ? arr.length - idx : len;

    byte[] res = new byte[size];

    U.arrayCopy(arr, idx, res, 0, size);

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

示例11: setBytes

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public int setBytes(long pos, byte[] bytes, int off, int len) throws SQLException {
    ensureNotClosed();

    if (pos < 1)
        throw new SQLException("Invalid argument. Position can't be less than 1 [pos=" + pos + ']');

    int idx = (int)(pos - 1);

    if (pos - 1 > arr.length || off < 0 || off >= bytes.length || off + len > bytes.length)
        throw new ArrayIndexOutOfBoundsException();

    byte[] dst = arr;

    if (idx + len > arr.length) {
        dst = new byte[arr.length + (len - (arr.length - idx))];

        U.arrayCopy(arr, 0, dst, 0, idx);

        arr = dst;
    }

    U.arrayCopy(bytes, off, dst, idx, len);

    return len;
}
 
开发者ID:apache,项目名称:ignite,代码行数:27,代码来源:JdbcBlob.java

示例12: putBytes

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Sets bytes from specified buffer to a given value.
 *
 * @param buf Buffer.
 * @param off Offset.
 * @param len Length.
 */
public void putBytes(byte[] buf, int off, int len) {
    if (arr == null)
        arr = new byte[PACKET_SIZE];

    U.arrayCopy(buf, 0, arr, off, len);
}
 
开发者ID:apache,项目名称:ignite,代码行数:14,代码来源:GridClientHandshakeRequest.java

示例13: valueBytes

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public byte[] valueBytes(CacheObjectValueContext ctx) throws IgniteCheckedException {
    if (detached())
        return array();

    int len = length();

    byte[] arr0 = new byte[len];

    U.arrayCopy(arr, start, arr0, 0, len);

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

示例14: detach

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @return Detached binary object.
 */
public BinaryObject detach() {
    if (!detachAllowed || detached())
        return this;

    int len = length();

    byte[] arr0 = new byte[len];

    U.arrayCopy(arr, start, arr0, 0, len);

    return new BinaryObjectImpl(ctx, arr0, 0);
}
 
开发者ID:apache,项目名称:ignite,代码行数:16,代码来源:BinaryObjectImpl.java


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