Example #1
0
    public void write(org.apache.thrift.protocol.TProtocol oprot, TDataSink struct)
        throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.type != null) {
        oprot.writeFieldBegin(TYPE_FIELD_DESC);
        oprot.writeI32(struct.type.getValue());
        oprot.writeFieldEnd();
      }
      if (struct.stream_sink != null) {
        if (struct.isSetStream_sink()) {
          oprot.writeFieldBegin(STREAM_SINK_FIELD_DESC);
          struct.stream_sink.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      if (struct.table_sink != null) {
        if (struct.isSetTable_sink()) {
          oprot.writeFieldBegin(TABLE_SINK_FIELD_DESC);
          struct.table_sink.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }
Example #2
0
    public void read(org.apache.thrift.protocol.TProtocol iprot, TDataSink 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: // TYPE
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.type = TDataSinkType.findByValue(iprot.readI32());
              struct.setTypeIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // STREAM_SINK
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.stream_sink = new TDataStreamSink();
              struct.stream_sink.read(iprot);
              struct.setStream_sinkIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // TABLE_SINK
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.table_sink = new TTableSink();
              struct.table_sink.read(iprot);
              struct.setTable_sinkIsSet(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
      struct.validate();
    }