/** * @param ptr Pointer. * @param arr Array. * @return The same array as passed in one. */ public byte[] readBytes(long ptr, byte[] arr) { GridUnsafe.copyOffheapHeap(ptr, arr, GridUnsafe.BYTE_ARR_OFF, arr.length); return arr; }
/** * @param ptr Pointer. * @param arr Array. * @param off Offset. * @param len Length. * @return The same array as passed in one. */ public byte[] readBytes(long ptr, byte[] arr, int off, int len) { GridUnsafe.copyOffheapHeap(ptr, arr, GridUnsafe.BYTE_ARR_OFF + off, len); return arr; }
/** * @param ptr Pointer. * @param off Offset. * @return Value. */ public static byte[] readByteArray(long ptr, int off, int len) { byte[] arr0 = new byte[len]; GridUnsafe.copyOffheapHeap(ptr + off, arr0, GridUnsafe.BYTE_ARR_OFF, len); return arr0; }
/** {@inheritDoc} */ @Override public byte[] arrayCopy() { if (dataCopy == null) { dataCopy = new byte[len]; GridUnsafe.copyOffheapHeap(data, dataCopy, GridUnsafe.BYTE_ARR_OFF, dataCopy.length); } return dataCopy; }
/** {@inheritDoc} */ @Override public byte[] arrayCopy() { byte[] res = new byte[len]; GridUnsafe.copyOffheapHeap(ptr, res, GridUnsafe.BYTE_ARR_OFF, res.length); return res; }
/** {@inheritDoc} */ @Override public byte[] arrayCopy() { byte[] res = new byte[pos]; GridUnsafe.copyOffheapHeap(ptr, res, GridUnsafe.BYTE_ARR_OFF, pos); return res; }
/** {@inheritDoc} */ @Override protected void copyAndShift(Object target, long off, int len) { GridUnsafe.copyOffheapHeap(ptr + pos, target, off, len); shift(len); }
/** * @param marker Marker. * @param ptr Pointer. * @param size Size. */ private void add(byte marker, long ptr, int size) { buf[off++] = marker; GridUnsafe.putInt(buf, GridUnsafe.BYTE_ARR_OFF + off, size); off += 4; GridUnsafe.copyOffheapHeap(ptr, buf, GridUnsafe.BYTE_ARR_OFF + off, size); off += size; }
/** * @param ptr Pointer. * @param off Offset. * @return Value. */ public static char[] readCharArray(long ptr, int off, int len) { char[] arr0 = new char[len]; GridUnsafe.copyOffheapHeap(ptr + off, arr0, GridUnsafe.CHAR_ARR_OFF, len << 1); if (BIG_ENDIAN) { for (int i = 0; i < len; i++) arr0[i] = Character.reverseBytes(arr0[i]); } return arr0; }
/** * Copy required amount of data and shift position. * * @param target Target to copy data to. * @param off Offset. * @param cnt Count. */ private void copyAndShift(Object target, long off, int cnt) { ensureEnoughData(cnt); GridUnsafe.copyOffheapHeap(data + pos, target, off, cnt); shift(cnt); }
private void read(long ptr, int size, Writable w) { assert size == 4 : size; GridUnsafe.copyOffheapHeap(ptr, buf, GridUnsafe.BYTE_ARR_OFF, size); dataInput.bytes(buf, size); try { w.readFields(dataInput); } catch (IOException e) { throw new RuntimeException(e); } } });
private void read(long ptr, int size, Writable w) { assert size == 4 : size; GridUnsafe.copyOffheapHeap(ptr, buf, GridUnsafe.BYTE_ARR_OFF, size); dataInput.bytes(buf, size); try { w.readFields(dataInput); } catch (IOException e) { throw new RuntimeException(e); } } });
/** {@inheritDoc} */ @Override public byte[] arrayCopy() { byte[] res = new byte[len]; GridUnsafe.copyOffheapHeap(ptr, res, GridUnsafe.BYTE_ARR_OFF, res.length); return res; }
/** * @param ptr Pointer. * @param arr Array. * @param off Offset. * @param len Length. * @return The same array as passed in one. */ public byte[] readBytes(long ptr, byte[] arr, int off, int len) { GridUnsafe.copyOffheapHeap(ptr, arr, GridUnsafe.BYTE_ARR_OFF + off, len); return arr; }
/** * @param ptr Pointer. * @param off Offset. * @return Value. */ public static byte[] readByteArray(long ptr, int off, int len) { byte[] arr0 = new byte[len]; GridUnsafe.copyOffheapHeap(ptr + off, arr0, GridUnsafe.BYTE_ARR_OFF, len); return arr0; }
/** {@inheritDoc} */ @Override public byte[] arrayCopy() { if (dataCopy == null) { dataCopy = new byte[len]; GridUnsafe.copyOffheapHeap(data, dataCopy, GridUnsafe.BYTE_ARR_OFF, dataCopy.length); } return dataCopy; }
/** {@inheritDoc} */ @Override public byte[] arrayCopy() { byte[] res = new byte[pos]; GridUnsafe.copyOffheapHeap(ptr, res, GridUnsafe.BYTE_ARR_OFF, pos); return res; }
/** {@inheritDoc} */ @Override protected void copyAndShift(Object target, long off, int len) { GridUnsafe.copyOffheapHeap(ptr + pos, target, off, len); shift(len); }
/** * @param marker Marker. * @param ptr Pointer. * @param size Size. */ private void add(byte marker, long ptr, int size) { buf[off++] = marker; GridUnsafe.putInt(buf, GridUnsafe.BYTE_ARR_OFF + off, size); off += 4; GridUnsafe.copyOffheapHeap(ptr, buf, GridUnsafe.BYTE_ARR_OFF + off, size); off += size; }
/** * Copy required amount of data and shift position. * * @param target Target to copy data to. * @param off Offset. * @param cnt Count. */ private void copyAndShift(Object target, long off, int cnt) { ensureEnoughData(cnt); GridUnsafe.copyOffheapHeap(data + pos, target, off, cnt); shift(cnt); }