/** * Gets byte field value. * * @param obj Object. * @param off Field offset. * @return Byte value. */ static byte getByte(Object obj, long off) { return GridUnsafe.getByteField(obj, off); }
/** * @param arr Array. * @param off Offset. * @param len Length. * @param typeSize Primitive type size in bytes. */ private void writeArrayLE(Object arr, long off, int len, int typeSize) { int pos = buf.position(); for (int i = 0; i < len; i++) { for (int j = 0; j < typeSize; j++) { byte b = GridUnsafe.getByteField(arr, off + arrOff + (typeSize - j - 1)); GridUnsafe.putByte(heapArr, baseOff + pos++, b); } buf.position(pos); arrOff += typeSize; } }
/** {@inheritDoc} */ @Override protected void write0(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException { writer.writeFieldIdNoSchemaUpdate(id); byte val = GridUnsafe.getByteField(obj, offset); writer.writeByteFieldPrimitive(val); }
/** * Change byte order for the provided array. * * @param arr Source array. * @param baseOff Base offset for the provided array. * @param typeSize Type size. * @param <T> Array type. */ private <T> void revertByteOrder(T arr, long baseOff, int typeSize) { int len = Array.getLength(arr); byte[] tmp = new byte[typeSize]; for (int i = 0; i < len; i++) { for (int j = 0; j < typeSize; j++) tmp[j] = GridUnsafe.getByteField(arr, baseOff + i * typeSize + j); for (int j = 0; j < typeSize; j++) GridUnsafe.putByteField(arr, baseOff + i * typeSize + j, tmp[typeSize - j - 1]); } }
/** * Gets byte field value. * * @param obj Object. * @param off Field offset. * @return Byte value. */ static byte getByte(Object obj, long off) { return GridUnsafe.getByteField(obj, off); }
/** * @param arr Array. * @param off Offset. * @param len Length. * @param typeSize Primitive type size in bytes. */ private void writeArrayLE(Object arr, long off, int len, int typeSize) { int pos = buf.position(); for (int i = 0; i < len; i++) { for (int j = 0; j < typeSize; j++) { byte b = GridUnsafe.getByteField(arr, off + arrOff + (typeSize - j - 1)); GridUnsafe.putByte(heapArr, baseOff + pos++, b); } buf.position(pos); arrOff += typeSize; } }
/** {@inheritDoc} */ @Override protected void write0(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException { writer.writeFieldIdNoSchemaUpdate(id); byte val = GridUnsafe.getByteField(obj, offset); writer.writeByteFieldPrimitive(val); }