Example usage for org.apache.thrift.transport TMemoryInputTransport consumeBuffer

List of usage examples for org.apache.thrift.transport TMemoryInputTransport consumeBuffer

Introduction

In this page you can find the example usage for org.apache.thrift.transport TMemoryInputTransport consumeBuffer.

Prototype

public void consumeBuffer(int len) 

Source Link

Usage

From source file:io.warp10.quasar.encoder.QuasarTokenDecoder.java

License:Apache License

/**
 * Deserialize the given byte array into any type of Thrift tokens
 * This method avoid an explicit cast on the deserialized token
 * @param base The Thrift instance/*  w w w  .ja  va2  s .  com*/
 * @param bytes the serialized thrift token
 */
private void deserializeThriftToken(TBase<?, ?> base, byte[] bytes) throws TException {
    // Thrift deserialization
    TMemoryInputTransport trans_ = new TMemoryInputTransport();
    TProtocol protocol_ = new TCompactProtocol.Factory().getProtocol(trans_);
    try {
        trans_.reset(bytes);
        // TRASH THE 8 fist bytes (SIP HASH)
        trans_.consumeBuffer(8);
        base.read(protocol_);
    } finally {
        trans_.clear();
        protocol_.reset();
    }
}