类com.esotericsoftware.kryo.io.ByteBufferInput源码实例Demo

下面列出了怎么用com.esotericsoftware.kryo.io.ByteBufferInput的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: paraflow   文件: TpchDataTransformer.java
@Override
public ParaflowRecord transform(byte[] value, int partition)
{
    Input input = new ByteBufferInput(value);
    try {
        LineOrder lineOrder = kryo.readObject(input, LineOrder.class);
        lineOrder.setFiberId(partition);
        long custKey = lineOrder.getCustomerKey();
        lineOrder.setKey(custKey);
        lineOrder.setTimestamp(lineOrder.getCreation());
        input.close();
        return lineOrder;
    }
    catch (Exception e) {
        StringWriter stringWriter = new StringWriter();
        PrintWriter printWriter = new PrintWriter(stringWriter);
        e.printStackTrace(printWriter);
        logger.error(stringWriter.toString());
        e.printStackTrace();
        return null;
    }
}
 
@Override
public SensorReading deserialize(String s, byte[] bytes) {
    try {
        return kryos.get().readObject(new ByteBufferInput(bytes), SensorReading.class);
    }
    catch(Exception e) {
        throw new IllegalArgumentException("Error reading bytes",e);
    }
}
 
源代码3 项目: Jupiter   文件: Inputs.java
public static Input getInput(InputBuf inputBuf) {
    ByteBuffer nioBuf = inputBuf.nioByteBuffer();
    ByteBufferInput input = new ByteBufferInput();
    input.setVarIntsEnabled(false); // Compatible with FastInput
    input.setBuffer(nioBuf, 0, nioBuf.capacity());
    return input;
}
 
源代码4 项目: atomix   文件: Namespace.java
/**
 * Deserializes given byte buffer to Object using Kryo instance in pool.
 *
 * @param buffer input with serialized bytes
 * @param <T>    deserialized Object type
 * @return deserialized Object
 */
public <T> T deserialize(final ByteBuffer buffer) {
  ByteBufferInput in = new ByteBufferInput(buffer);
  Kryo kryo = borrow();
  try {
    @SuppressWarnings("unchecked")
    T obj = (T) kryo.readClassAndObject(in);
    return obj;
  } finally {
    release(kryo);
  }
}
 
源代码5 项目: atomix   文件: Namespace.java
/**
 * Deserializes given InputStream to an Object using Kryo instance in pool.
 *
 * @param stream     input stream
 * @param <T>        deserialized Object type
 * @param bufferSize size of the buffer in front of the stream
 * @return deserialized Object
 */
public <T> T deserialize(final InputStream stream, final int bufferSize) {
  ByteBufferInput in = new ByteBufferInput(stream, bufferSize);
  Kryo kryo = borrow();
  try {
    @SuppressWarnings("unchecked")
    T obj = (T) kryo.readClassAndObject(in);
    return obj;
  } finally {
    release(kryo);
  }
}
 
源代码6 项目: onos   文件: KryoNamespace.java
/**
 * Deserializes given byte buffer to Object using Kryo instance in pool.
 *
 * @param buffer input with serialized bytes
 * @param <T> deserialized Object type
 * @return deserialized Object
 */
public <T> T deserialize(final ByteBuffer buffer) {
    ByteBufferInput in = new ByteBufferInput(buffer);
    Kryo kryo = borrow();
    try {
        @SuppressWarnings("unchecked")
        T obj = (T) kryo.readClassAndObject(in);
        return obj;
    } finally {
        release(kryo);
    }
}
 
源代码7 项目: onos   文件: KryoNamespace.java
/**
 * Deserializes given InputStream to an Object using Kryo instance in pool.
 *
 * @param stream input stream
 * @param <T> deserialized Object type
 * @return deserialized Object
 * @param bufferSize size of the buffer in front of the stream
 */
public <T> T deserialize(final InputStream stream, final int bufferSize) {
    ByteBufferInput in = new ByteBufferInput(stream, bufferSize);
    Kryo kryo = borrow();
    try {
        @SuppressWarnings("unchecked")
        T obj = (T) kryo.readClassAndObject(in);
        return obj;
    } finally {
        release(kryo);
    }
}
 
源代码8 项目: kryonet   文件: KryoSerialization.java
public KryoSerialization (Kryo kryo) {
	this.kryo = kryo;

	kryo.register(RegisterTCP.class);
	kryo.register(RegisterUDP.class);
	kryo.register(KeepAlive.class);
	kryo.register(DiscoverHost.class);
	kryo.register(Ping.class);

	input = new ByteBufferInput();
	output = new ByteBufferOutput();
}
 
源代码9 项目: yauaa   文件: TestKryoSerialization.java
UserAgentAnalyzerTester deserialize(byte[] bytes) {
    Kryo            kryo            = new Kryo();
    ByteBufferInput byteBufferInput = new ByteBufferInput(bytes);
    return (UserAgentAnalyzerTester) kryo.readClassAndObject(byteBufferInput);
}
 
源代码10 项目: yauaa   文件: TestMatcherList.java
MatcherList deserialize(byte[] bytes) {
    Kryo            kryo            = new Kryo();
    ByteBufferInput byteBufferInput = new ByteBufferInput(bytes);
    return (MatcherList) kryo.readClassAndObject(byteBufferInput);
}
 
源代码11 项目: gdx-ai   文件: KryoUtils.java
public static <T> T load (Class<T> type) {
	Input input = new ByteBufferInput(output.getBuffer());
	return kryo.readObjectOrNull(input, type);
}