Java 类com.esotericsoftware.kryo.io.FastInput 实例源码

项目:jsflight    文件:Http2JMeter.java   
/**
 * Just to test IdGeneration Recording
 * @param file
 * @return
 * @throws Exception
 */
public List<IdRecordInfo> getIdRecords(String file) throws Exception
{
    List<IdRecordInfo> infos = new ArrayList<>();
    FastInput input = new FastInput(new FileInputStream(file));
    Kryo kryo = new Kryo();
    kryo.register(HashMap.class, new MapSerializer());

    while (input.available() > 0)
    {
        InternalEventRecorder.InternalEventRecord record = kryo.readObject(input,
                InternalEventRecorder.InternalEventRecord.class);
        String tag = new String(record.tag).trim();
        if (tag.equalsIgnoreCase(IdRecordInfo.ID_RECORD_TAG))
        {
            infos.add((IdRecordInfo)record.data);
        }
    }

    return infos;
}
项目:rpc    文件:KryoSerialization.java   
@Override
public <T> T deserialize(byte[] data, Class<T> clz) throws IOException, ClassNotFoundException {
    Kryo kryo = kryoThreadMap.get();
    kryo.register(clz);
    KryoObjectInput input = new KryoObjectInput(kryo, new FastInput(new ByteArrayInputStream(data)));
    return (T) input.readObject();
}
项目:RxBroadcast    文件:KryoSerializer.java   
public final Object deserialize(final byte[] bytes) {
    final Kryo kryo = threadLocalKryo.get();
    return kryo.readClassAndObject(new FastInput(bytes));
}
项目:jsflight    文件:Http2JMeter.java   
public List<RestoredRequest> getRequests(String file, int limit) throws IOException
{
    List<RestoredRequest> requests = new ArrayList<>();
    FastInput input = new FastInput(new FileInputStream(file));

    Kryo kryo = new Kryo();
    kryo.register(HashMap.class, new MapSerializer());
    while (input.available() > 0)
    {
        InternalEventRecorder.InternalEventRecord record = kryo.readObject(input,
                InternalEventRecorder.InternalEventRecord.class);

        String tag = new String(record.tag).trim();

        if (tag.equalsIgnoreCase(HttpRecorderHelper.HTTP_RECORDER_TAG))
        {
            HttpRecordInformation information = (HttpRecordInformation)record.data;
            RestoredRequest request = new RestoredRequest();

            if (information.params != null && information.params.length > 0)
            {
                FastInput paramsInput = new FastInput(new ByteArrayInputStream(information.params));

                request.parameters = kryo.readObject(paramsInput, HashMap.class);
                request.headers = kryo.readObject(paramsInput, HashMap.class);
                request.contentLength = kryo.readObjectOrNull(paramsInput, Integer.class);
                request.contentType = kryo.readObjectOrNull(paramsInput, String.class);
                request.uri = kryo.readObjectOrNull(paramsInput, String.class);
                request.method = kryo.readObjectOrNull(paramsInput, String.class);
                request.contextPath = kryo.readObjectOrNull(paramsInput, String.class);
                request.cookies = kryo.readObject(paramsInput, HashMap.class);
            }
            if (information.payload != null && information.payload.length > 0)
            {
                request.payload = new String(information.payload);
            }

            request.additional = information.additional;
            request.timestampNs = record.timestampNs;

            if (limit > 0 && requests.size() >= limit)
            {
                break;
            }
            requests.add(request);
        }
    }
    return requests;
}