read method

void read(
  1. TProtocol iprot
)
override

Reads the TObject from the given input protocol.

Implementation

read(TProtocol iprot) {
  TField field;
  iprot.readStructBegin();
  while (true) {
    field = iprot.readFieldBegin();
    if (field.type == TType.STOP) {
      break;
    }
    switch (field.id) {
      case CODE:
        if (field.type == TType.I32) {
          this.code = iprot.readI32();
          this.__isset_code = true;
        } else {
          TProtocolUtil.skip(iprot, field.type);
        }
        break;
      case PART_ID:
        if (field.type == TType.I32) {
          this.part_id = iprot.readI32();
          this.__isset_part_id = true;
        } else {
          TProtocolUtil.skip(iprot, field.type);
        }
        break;
      case LEADER:
        if (field.type == TType.STRUCT) {
          this.leader = new t_nebula.HostAddr();
          this.leader?.read(iprot);
        } else {
          TProtocolUtil.skip(iprot, field.type);
        }
        break;
      default:
        TProtocolUtil.skip(iprot, field.type);
        break;
    }
    iprot.readFieldEnd();
  }
  iprot.readStructEnd();

  // check for required fields of primitive type, which can't be checked in the validate method
  if (!__isset_code) {
    throw new TProtocolError(TProtocolErrorType.UNKNOWN,
        "Required field 'code' was not found in serialized data! Struct: ${toString()}");
  }

  if (!__isset_part_id) {
    throw new TProtocolError(TProtocolErrorType.UNKNOWN,
        "Required field 'part_id' was not found in serialized data! Struct: ${toString()}");
  }

  validate();
}