当前位置: 首页>>代码示例>>Java>>正文


Java TType.STOP属性代码示例

本文整理汇总了Java中org.apache.thrift.protocol.TType.STOP属性的典型用法代码示例。如果您正苦于以下问题:Java TType.STOP属性的具体用法?Java TType.STOP怎么用?Java TType.STOP使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.thrift.protocol.TType的用法示例。


在下文中一共展示了TType.STOP属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read

/**
 * 读取操作
 */
@Override
public void read(TProtocol iprot) throws TException {
	if (!"org.apache.thrift.scheme.StandardScheme".equals(iprot.getScheme().getName()))
		throw new TApplicationException("Service scheme must be 'org.apache.thrift.scheme.StandardScheme' !");
	TField schemeField;
	iprot.readStructBegin();
	while (Boolean.TRUE) {
		schemeField = iprot.readFieldBegin();
		if (schemeField.type == TType.STOP)
			break;
		if (schemeField.type == TType.STRING)
			str = iprot.readString();
		else
			throw new TApplicationException("field type must be 'String' !");
		iprot.readFieldEnd();
	}
	iprot.readStructEnd();
}
 
开发者ID:venwyhk,项目名称:ikasoa,代码行数:21,代码来源:AbstractThriftBase.java

示例2: writeFieldBegin

@Override
public void writeFieldBegin(TField field) throws TException {
  if (field.type == TType.STOP) {
    return;
  }
  try {
    currentType = thriftFieldIdToParquetField[field.id];
    if (currentType == null) {
      throw new ParquetEncodingException("field " + field.id + " was not found in " + thriftType + " and " + schema.getType());
    }
    final int index = currentType.getIndex();
    recordConsumer.startField(currentType.getName(), index);
    currentProtocol = children[index];
  } catch (ArrayIndexOutOfBoundsException e) {
    throw new ParquetEncodingException("field " + field.id + " was not found in " + thriftType + " and " + schema.getType());
  }
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:17,代码来源:ParquetWriteProtocol.java

示例3: locateField

private TField locateField(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException {
  trans_.reset(bytes);

  TFieldIdEnum[] fieldIdPath= new TFieldIdEnum[fieldIdPathRest.length + 1];
  fieldIdPath[0] = fieldIdPathFirst;
  for (int i = 0; i < fieldIdPathRest.length; i++){
    fieldIdPath[i + 1] = fieldIdPathRest[i];
  }

  // index into field ID path being currently searched for
  int curPathIndex = 0;

  // this will be the located field, or null if it is not located
  TField field = null;

  protocol_.readStructBegin();

  while (curPathIndex < fieldIdPath.length) {
    field = protocol_.readFieldBegin();
    // we can stop searching if we either see a stop or we go past the field
    // id we're looking for (since fields should now be serialized in asc
    // order).
    if (field.type == TType.STOP || field.id > fieldIdPath[curPathIndex].getThriftFieldId()) {
      return null;
    }

    if (field.id != fieldIdPath[curPathIndex].getThriftFieldId()) {
      // Not the field we're looking for. Skip field.
      TProtocolUtil.skip(protocol_, field.type);
      protocol_.readFieldEnd();
    } else {
      // This field is the next step in the path. Step into field.
      curPathIndex++;
      if (curPathIndex < fieldIdPath.length) {
        protocol_.readStructBegin();
      }
    }
  }
  return field;
}
 
开发者ID:adityayadav76,项目名称:internet_of_things_simulator,代码行数:40,代码来源:TDeserializer.java

示例4: read

public static TApplicationException read(TProtocol iprot) throws TException {
  TField field;
  iprot.readStructBegin();

  String message = null;
  int type = UNKNOWN;

  while (true) {
    field = iprot.readFieldBegin();
    if (field.type == TType.STOP) {
      break;
    }
    switch (field.id) {
    case 1:
      if (field.type == TType.STRING) {
        message = iprot.readString();
      } else {
        TProtocolUtil.skip(iprot, field.type);
      }
      break;
    case 2:
      if (field.type == TType.I32) {
        type = iprot.readI32();
      } else {
        TProtocolUtil.skip(iprot, field.type);
      }
      break;
    default:
      TProtocolUtil.skip(iprot, field.type);
      break;
    }
    iprot.readFieldEnd();
  }
  iprot.readStructEnd();

  return new TApplicationException(type, message);
}
 
开发者ID:adityayadav76,项目名称:internet_of_things_simulator,代码行数:37,代码来源:TApplicationException.java

示例5: read

/**
 * Reads a {@link TApplicationException} from the specified {@link TProtocol}.
 *
 * <p>Note: This has been copied from {@link TApplicationException#read(TProtocol)} due to API differences
 * between libthrift 0.9.x and 0.10.x.
 */
public static TApplicationException read(TProtocol iprot) throws TException {
    TField field;
    iprot.readStructBegin();

    String message = null;
    int type = TApplicationException.UNKNOWN;

    while (true) {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) {
            break;
        }
        switch (field.id) {
            case 1:
                if (field.type == TType.STRING) {
                    message = iprot.readString();
                } else {
                    TProtocolUtil.skip(iprot, field.type);
                }
                break;
            case 2:
                if (field.type == TType.I32) {
                    type = iprot.readI32();
                } else {
                    TProtocolUtil.skip(iprot, field.type);
                }
                break;
            default:
                TProtocolUtil.skip(iprot, field.type);
                break;
        }
        iprot.readFieldEnd();
    }
    iprot.readStructEnd();

    return new TApplicationException(type, message);
}
 
开发者ID:line,项目名称:armeria,代码行数:43,代码来源:TApplicationExceptions.java

示例6: main

public static void main(String[] args) throws TException {
    TTransport trans = new TSimpleFileTransport("data", true, false);
    TProtocol proto = new TBinaryProtocol(trans);		

    Trade trade_read = new Trade();
    TField field = new TField();

    TStruct struct_obj = proto.readStructBegin();		
    while(true) {						
        field = proto.readFieldBegin();			
        if (field.id == TType.STOP) {				
            break;
        }
        switch(field.id) {					
        case 1:
            trade_read.symbol = proto.readString();	
            break;
        case 2:
            trade_read.price = proto.readDouble();
            break;
        case 3:
            trade_read.size = proto.readI32();
            break;
        default:
            TProtocolUtil.skip(proto,field.type);	
            break;
        }
        proto.readFieldEnd();				
    }
    proto.readStructEnd();				

    System.out.println("Trade: " + trade_read.symbol + " " +
                       trade_read.size + " @ " + trade_read.price);
}
 
开发者ID:RandyAbernethy,项目名称:ThriftBook,代码行数:34,代码来源:BinFileRead.java

示例7: readStructContent

/**
 * reads the content of a struct (fields) from the underlying protocol and passes the events to c
 * @param c the field consumer
 * @throws TException
 */
public void readStructContent(FieldConsumer c) throws TException {
  TField field;
  while (true) {
    field = protocol.readFieldBegin();
    if (field.type == TType.STOP) {
      break;
    }
    c.consumeField(protocol, this, field.id, field.type);
  }
}
 
开发者ID:apache,项目名称:parquet-format,代码行数:15,代码来源:EventBasedThriftReader.java

示例8: read

public void read(TProtocol iprot, Log_result struct) throws TException {
  org.apache.thrift.protocol.TField schemeField;
  iprot.readStructBegin();
  while (true)
  {
    schemeField = iprot.readFieldBegin();
    if (schemeField.type == TType.STOP) { 
      break;
    }
    switch (schemeField.id) {
      case 0: // SUCCESS
        if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
          struct.success = ResultCode.findByValue(iprot.readI32());
          struct.setSuccessIsSet(true);
        } else { 
          TProtocolUtil.skip(iprot, schemeField.type);
        }
        break;
      default:
        TProtocolUtil.skip(iprot, schemeField.type);
    }
    iprot.readFieldEnd();
  }
  iprot.readStructEnd();

  // check for required fields of primitive type, which can't be checked in the validate method
  struct.validate();
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:28,代码来源:scribe.java

示例9: readOneStruct

private void readOneStruct(TProtocol in, TProtocol out) throws TException {
  final TStruct struct = in.readStructBegin();
  out.writeStructBegin(struct);
  TField field;
  while ((field = in.readFieldBegin()).type != TType.STOP) {
    out.writeFieldBegin(field);
    readOneValue(in, out, field.type);
    in.readFieldEnd();
    out.writeFieldEnd();
  }
  out.writeFieldStop();
  in.readStructEnd();
  out.writeStructEnd();
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:14,代码来源:ProtocolReadToWrite.java

示例10: readOneValue

void readOneValue(TProtocol in, TProtocol out, byte type)
    throws TException {
  switch (type) {
  case TType.LIST:
    readOneList(in, out);
    break;
  case TType.MAP:
    readOneMap(in, out);
    break;
  case TType.SET:
    readOneSet(in, out);
    break;
  case TType.STRUCT:
    readOneStruct(in, out);
    break;
  case TType.STOP:
    break;
  case TType.BOOL:
    out.writeBool(in.readBool());
    break;
  case TType.BYTE:
    out.writeByte(in.readByte());
    break;
  case TType.DOUBLE:
    out.writeDouble(in.readDouble());
    break;
  case TType.I16:
    out.writeI16(in.readI16());
    break;
  case TType.ENUM: // same as i32 => actually never seen in the protocol layer as enums are written as a i32 field
  case TType.I32:
    out.writeI32(in.readI32());
    break;
  case TType.I64:
    out.writeI64(in.readI64());
    break;
  case TType.STRING:
    out.writeBinary(in.readBinary());
    break;
  case TType.VOID:
    break;
  default:
    throw new TException("Unknown type: " + type);
  }
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:45,代码来源:ProtocolReadToWrite.java

示例11: readOneValue

/**
 * @return true when all value is consumed, false when some values is ignored due to the field is not defined in expectedType
 * @throws TException
 */
private boolean readOneValue(TProtocol in, byte type, List<Action> buffer, ThriftType expectedType) throws TException {
  if (expectedType != null && expectedType.getType().getSerializedThriftType() != type) {
    throw new DecodingSchemaMismatchException("the data type does not match the expected thrift structure: expected " + expectedType + " got " + typeName(type));
  }
  boolean hasFieldsIgnored = false;
  switch (type) {
  case TType.LIST:
    hasFieldsIgnored = readOneList(in, buffer, (ListType)expectedType);
    break;
  case TType.MAP:
    hasFieldsIgnored = readOneMap(in, buffer, (MapType)expectedType);
    break;
  case TType.SET:
    hasFieldsIgnored = readOneSet(in, buffer, (SetType)expectedType);
    break;
  case TType.STRUCT:
    hasFieldsIgnored = readOneStruct(in, buffer, (StructType)expectedType);
    break;
  case TType.STOP:
    break;
  case TType.BOOL:
    final boolean bool = in.readBool();
    writeBoolAction(buffer, bool);
    break;
  case TType.BYTE:
    final byte b = in.readByte();
    writeByteAction(buffer, b);
    break;
  case TType.DOUBLE:
    final double d = in.readDouble();
    writeDoubleAction(buffer, d);
    break;
  case TType.I16:
    final short s = in.readI16();
    writeShortAction(buffer, s);
    break;
  case TType.ENUM: // same as i32 => actually never seen in the protocol layer as enums are written as a i32 field
  case TType.I32:
    final int i = in.readI32();
    checkEnum(expectedType,i);
    writeIntAction(buffer, i);
    break;
  case TType.I64:
    final long l = in.readI64();
    writeLongAction(buffer, l);
    break;
  case TType.STRING:
    final ByteBuffer bin = in.readBinary();
    writeStringAction(buffer, bin);
    break;
  case TType.VOID:
    break;
  default:
    throw new TException("Unknown type: " + type);
  }
  return hasFieldsIgnored;
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:61,代码来源:BufferedProtocolReadToWrite.java


注:本文中的org.apache.thrift.protocol.TType.STOP属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。