Example #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);
 }
Example #2
0
 @Override
 public void write(org.apache.thrift.protocol.TProtocol prot, THdfsFileDesc struct)
     throws org.apache.thrift.TException {
   TTupleProtocol oprot = (TTupleProtocol) prot;
   oprot.writeString(struct.file_name);
   oprot.writeI64(struct.length);
   oprot.writeI32(struct.compression.getValue());
   oprot.writeI64(struct.last_modification_time);
   {
     oprot.writeI32(struct.file_blocks.size());
     for (THdfsFileBlock _iter38 : struct.file_blocks) {
       _iter38.write(oprot);
     }
   }
 }
Example #3
0
    public void write(org.apache.thrift.protocol.TProtocol oprot, THdfsFileDesc struct)
        throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.file_name != null) {
        oprot.writeFieldBegin(FILE_NAME_FIELD_DESC);
        oprot.writeString(struct.file_name);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(LENGTH_FIELD_DESC);
      oprot.writeI64(struct.length);
      oprot.writeFieldEnd();
      if (struct.compression != null) {
        oprot.writeFieldBegin(COMPRESSION_FIELD_DESC);
        oprot.writeI32(struct.compression.getValue());
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(LAST_MODIFICATION_TIME_FIELD_DESC);
      oprot.writeI64(struct.last_modification_time);
      oprot.writeFieldEnd();
      if (struct.file_blocks != null) {
        oprot.writeFieldBegin(FILE_BLOCKS_FIELD_DESC);
        {
          oprot.writeListBegin(
              new org.apache.thrift.protocol.TList(
                  org.apache.thrift.protocol.TType.STRUCT, struct.file_blocks.size()));
          for (THdfsFileBlock _iter37 : struct.file_blocks) {
            _iter37.write(oprot);
          }
          oprot.writeListEnd();
        }
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }
Example #4
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();
    }