當前位置: 首頁>>代碼示例>>Java>>正文


Java TBase.read方法代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:masonmei,項目名稱:apm-agent,代碼行數:25,代碼來源:HeaderTBaseDeserializer.java

示例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;
}
 
開發者ID:carbondata,項目名稱:carbondata,代碼行數:13,代碼來源:ThriftReader.java

示例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();
  }
}
 
開發者ID:cityzendata,項目名稱:warp10-platform,代碼行數:21,代碼來源:QuasarTokenDecoder.java

示例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;
}
 
開發者ID:masonmei,項目名稱:apm-agent,代碼行數:16,代碼來源:ChunkHeaderTBaseDeserializer.java

示例5: extractAuthToken

import org.apache.thrift.TBase; //導入方法依賴的package包/類
private TBase extractAuthToken(TProtocol protocol, TBase authToken) throws TException {
    authToken.read(protocol);
    return authToken;
}
 
開發者ID:aatarasoff,項目名稱:thrift-api-gateway-core,代碼行數:5,代碼來源:MessageTransalator.java

示例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()));
}
 
開發者ID:line,項目名稱:armeria,代碼行數:55,代碼來源:THttpClientDelegate.java


注:本文中的org.apache.thrift.TBase.read方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。