本文整理匯總了Java中org.apache.thrift.TBase.read方法的典型用法代碼示例。如果您正苦於以下問題:Java TBase.read方法的具體用法?Java TBase.read怎麽用?Java TBase.read使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.thrift.TBase
的用法示例。
在下文中一共展示了TBase.read方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: deserialize
import org.apache.thrift.TBase; //導入方法依賴的package包/類
/**
* Deserialize the Thrift object from a byte array.
*
* @param bytes The array to read from
*/
public TBase<?, ?> deserialize(byte[] bytes) throws TException {
try {
trans.reset(bytes);
Header header = readHeader();
final int validate = validate(header);
if (validate == HeaderUtils.OK) {
TBase<?, ?> base = locator.tBaseLookup(header.getType());
base.read(protocol);
return base;
}
if (validate == HeaderUtils.PASS_L4) {
return new L4Packet(header);
}
throw new IllegalStateException("invalid validate " + validate);
} finally {
trans.clear();
protocol.reset();
}
}
示例2: read
import org.apache.thrift.TBase; //導入方法依賴的package包/類
/**
* Reads the next object from the fileName.
*/
public TBase read() throws IOException {
TBase t = creator.create();
try {
t.read(binaryIn);
} catch (TException e) {
throw new IOException(e);
}
return t;
}
示例3: deserializeThriftToken
import org.apache.thrift.TBase; //導入方法依賴的package包/類
/**
* 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
* @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();
}
}
示例4: deserialize
import org.apache.thrift.TBase; //導入方法依賴的package包/類
private TBase<?, ?> deserialize() throws TException {
final Header header = readHeader();
if (header == null) {
return null;
}
final int validate = validate(header);
if (validate == HeaderUtils.PASS_L4) {
return new L4Packet(header);
}
TBase<?, ?> base = locator.tBaseLookup(header.getType());
base.read(protocol);
return base;
}
示例5: extractAuthToken
import org.apache.thrift.TBase; //導入方法依賴的package包/類
private TBase extractAuthToken(TProtocol protocol, TBase authToken) throws TException {
authToken.read(protocol);
return authToken;
}
示例6: handle
import org.apache.thrift.TBase; //導入方法依賴的package包/類
private void handle(ClientRequestContext ctx, int seqId, DefaultRpcResponse reply,
ThriftFunction func, HttpData content) throws TException {
if (func.isOneWay()) {
handleSuccess(ctx, reply, null, null);
return;
}
if (content.isEmpty()) {
throw new TApplicationException(TApplicationException.MISSING_RESULT);
}
final TMemoryInputTransport inputTransport =
new TMemoryInputTransport(content.array(), content.offset(), content.length());
final TProtocol inputProtocol = protocolFactory.getProtocol(inputTransport);
final TMessage header = inputProtocol.readMessageBegin();
final TApplicationException appEx = readApplicationException(seqId, func, inputProtocol, header);
if (appEx != null) {
handleException(ctx, reply, new ThriftReply(header, appEx), appEx);
return;
}
TBase<?, ?> result = func.newResult();
result.read(inputProtocol);
inputProtocol.readMessageEnd();
final ThriftReply rawResponseContent = new ThriftReply(header, result);
for (TFieldIdEnum fieldIdEnum : func.exceptionFields()) {
if (ThriftFieldAccess.isSet(result, fieldIdEnum)) {
final TException cause = (TException) ThriftFieldAccess.get(result, fieldIdEnum);
handleException(ctx, reply, rawResponseContent, cause);
return;
}
}
final TFieldIdEnum successField = func.successField();
if (successField == null) { // void method
handleSuccess(ctx, reply, null, rawResponseContent);
return;
}
if (ThriftFieldAccess.isSet(result, successField)) {
final Object returnValue = ThriftFieldAccess.get(result, successField);
handleSuccess(ctx, reply, returnValue, rawResponseContent);
return;
}
handleException(
ctx, reply, rawResponseContent,
new TApplicationException(TApplicationException.MISSING_RESULT,
result.getClass().getName() + '.' + successField.getFieldName()));
}