示例#1
0
 @Override
 public void read(org.apache.thrift.protocol.TProtocol prot, THdfsFileDesc struct)
     throws org.apache.thrift.TException {
   TTupleProtocol iprot = (TTupleProtocol) prot;
   struct.file_name = iprot.readString();
   struct.setFile_nameIsSet(true);
   struct.length = iprot.readI64();
   struct.setLengthIsSet(true);
   struct.compression = THdfsCompression.findByValue(iprot.readI32());
   struct.setCompressionIsSet(true);
   struct.last_modification_time = iprot.readI64();
   struct.setLast_modification_timeIsSet(true);
   {
     org.apache.thrift.protocol.TList _list39 =
         new org.apache.thrift.protocol.TList(
             org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
     struct.file_blocks = new ArrayList<THdfsFileBlock>(_list39.size);
     for (int _i40 = 0; _i40 < _list39.size; ++_i40) {
       THdfsFileBlock _elem41; // required
       _elem41 = new THdfsFileBlock();
       _elem41.read(iprot);
       struct.file_blocks.add(_elem41);
     }
   }
   struct.setFile_blocksIsSet(true);
 }
示例#2
0
    public void read(org.apache.thrift.protocol.TProtocol iprot, THdfsFileDesc struct)
        throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TField schemeField;
      iprot.readStructBegin();
      while (true) {
        schemeField = iprot.readFieldBegin();
        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
          break;
        }
        switch (schemeField.id) {
          case 1: // FILE_NAME
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.file_name = iprot.readString();
              struct.setFile_nameIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // LENGTH
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.length = iprot.readI64();
              struct.setLengthIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // COMPRESSION
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.compression = THdfsCompression.findByValue(iprot.readI32());
              struct.setCompressionIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // LAST_MODIFICATION_TIME
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.last_modification_time = iprot.readI64();
              struct.setLast_modification_timeIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 5: // FILE_BLOCKS
            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
              {
                org.apache.thrift.protocol.TList _list34 = iprot.readListBegin();
                struct.file_blocks = new ArrayList<THdfsFileBlock>(_list34.size);
                for (int _i35 = 0; _i35 < _list34.size; ++_i35) {
                  THdfsFileBlock _elem36; // required
                  _elem36 = new THdfsFileBlock();
                  _elem36.read(iprot);
                  struct.file_blocks.add(_elem36);
                }
                iprot.readListEnd();
              }
              struct.setFile_blocksIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          default:
            org.apache.thrift.protocol.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
      if (!struct.isSetLength()) {
        throw new org.apache.thrift.protocol.TProtocolException(
            "Required field 'length' was not found in serialized data! Struct: " + toString());
      }
      if (!struct.isSetLast_modification_time()) {
        throw new org.apache.thrift.protocol.TProtocolException(
            "Required field 'last_modification_time' was not found in serialized data! Struct: "
                + toString());
      }
      struct.validate();
    }