@Override public IN apply(byte[] bytes) { IN obj = engine.readObject(new UnsafeMemoryInput(bytes), type); if(null != next) { next.accept(obj); return null; } else { return obj; } } };
/** {@inheritDoc} */ final public float[] readFloats (int length) throws KryoException { int bytesToCopy = length << 2; float[] array = new float[length]; readBytes(array, floatArrayBaseOffset, 0, bytesToCopy); return array; }
/** Creates a new Input for reading from a byte array. * @param bufferSize The initial and maximum size of the buffer. An exception is thrown if this size is exceeded. */ public UnsafeMemoryInput (int bufferSize) { super(bufferSize); updateBufferAddress(); }
/** Reads a 2 byte short. */ public short readShort () throws KryoException { require(2); short result = unsafe().getShort(bufaddress + position); position += 2; return result; }
public int readInt (boolean optimizePositive) throws KryoException { if (!varIntsEnabled) return readInt(); else return super.readInt(optimizePositive); }
public long readLong (boolean optimizePositive) throws KryoException { if (!varIntsEnabled) return readLong(); else return super.readLong(optimizePositive); }
/** {@inheritDoc} */ final public double[] readDoubles (int length) throws KryoException { int bytesToCopy = length << 3; double[] array = new double[length]; readBytes(array, doubleArrayBaseOffset, 0, bytesToCopy); return array; }
/** Creates a new Input for reading from a byte array. * @see #setBuffer(byte[]) */ public UnsafeMemoryInput (byte[] buffer) { super(buffer); updateBufferAddress(); }
/** Reads a 4 byte int. */ public int readInt () throws KryoException { require(4); int result = unsafe().getInt(bufaddress + position); position += 4; return result; }
public int readInt (boolean optimizePositive) throws KryoException { if (!varIntsEnabled) return readInt(); else return super.readInt(optimizePositive); }
public long readLong (boolean optimizePositive) throws KryoException { if (!varIntsEnabled) return readLong(); else return super.readLong(optimizePositive); }
/** {@inheritDoc} */ final public short[] readShorts (int length) throws KryoException { int bytesToCopy = length << 1; short[] array = new short[length]; readBytes(array, shortArrayBaseOffset, 0, bytesToCopy); return array; }
/** Creates a new Input for reading from a byte array. * @see #setBuffer(byte[]) */ public UnsafeMemoryInput (byte[] buffer) { super(buffer); updateBufferAddress(); }
/** Reads an 8 byte long. */ public long readLong () throws KryoException { require(8); long result = unsafe().getLong(bufaddress + position); position += 8; return result; }
@Override public IN apply(byte[] bytes) { final Kryo kryo = engine.borrow(); try { IN obj = kryo.readObject(new UnsafeMemoryInput(bytes), type); if (null != next) { next.accept(obj); return null; } else { return obj; } } finally { engine.release(kryo); } } };
public int readInt (boolean optimizePositive) throws KryoException { if (!varIntsEnabled) return readInt(); else return super.readInt(optimizePositive); }
public long readLong (boolean optimizePositive) throws KryoException { if (!varIntsEnabled) return readLong(); else return super.readLong(optimizePositive); }
/** {@inheritDoc} */ final public char[] readChars (int length) throws KryoException { int bytesToCopy = length << 1; char[] array = new char[length]; readBytes(array, charArrayBaseOffset, 0, bytesToCopy); return array; }
/** Creates a new Input for reading from an InputStream. A buffer size of 4096 is used. */ public UnsafeMemoryInput (InputStream inputStream) { super(inputStream); updateBufferAddress(); }
/** Reads a 4 byte int. */ public int readInt () throws KryoException { require(4); int result = unsafe().getInt(bufaddress + position); position += 4; return result; }