当前位置: 首页>>代码示例>>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;未经允许,请勿转载。