All Downloads are FREE. Search and download functionalities are using the official Maven repository.

wavefront.report.Histogram Maven / Gradle / Ivy

The newest version!
/**
 * Autogenerated by Avro
 *
 * DO NOT EDIT DIRECTLY
 */
package wavefront.report;

import org.apache.avro.generic.GenericArray;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.util.Utf8;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;

@org.apache.avro.specific.AvroGenerated
public class Histogram extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
  private static final long serialVersionUID = 5450823579846202556L;
  public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Histogram\",\"namespace\":\"wavefront.report\",\"fields\":[{\"name\":\"duration\",\"type\":\"int\"},{\"name\":\"type\",\"type\":{\"type\":\"enum\",\"name\":\"HistogramType\",\"symbols\":[\"TDIGEST\",\"DOUBLE_TRUNCATE\"]}},{\"name\":\"bins\",\"type\":{\"type\":\"array\",\"items\":\"double\"}},{\"name\":\"counts\",\"type\":{\"type\":\"array\",\"items\":\"int\"}}]}");
  public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }

  private static SpecificData MODEL$ = new SpecificData();

  private static final BinaryMessageEncoder ENCODER =
      new BinaryMessageEncoder(MODEL$, SCHEMA$);

  private static final BinaryMessageDecoder DECODER =
      new BinaryMessageDecoder(MODEL$, SCHEMA$);

  /**
   * Return the BinaryMessageEncoder instance used by this class.
   * @return the message encoder used by this class
   */
  public static BinaryMessageEncoder getEncoder() {
    return ENCODER;
  }

  /**
   * Return the BinaryMessageDecoder instance used by this class.
   * @return the message decoder used by this class
   */
  public static BinaryMessageDecoder getDecoder() {
    return DECODER;
  }

  /**
   * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
   * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
   * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore
   */
  public static BinaryMessageDecoder createDecoder(SchemaStore resolver) {
    return new BinaryMessageDecoder(MODEL$, SCHEMA$, resolver);
  }

  /**
   * Serializes this Histogram to a ByteBuffer.
   * @return a buffer holding the serialized data for this instance
   * @throws java.io.IOException if this instance could not be serialized
   */
  public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
    return ENCODER.encode(this);
  }

  /**
   * Deserializes a Histogram from a ByteBuffer.
   * @param b a byte buffer holding serialized data for an instance of this class
   * @return a Histogram instance decoded from the given buffer
   * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class
   */
  public static Histogram fromByteBuffer(
      java.nio.ByteBuffer b) throws java.io.IOException {
    return DECODER.decode(b);
  }

  @Deprecated public int duration;
  @Deprecated public wavefront.report.HistogramType type;
  @Deprecated public java.util.List bins;
  @Deprecated public java.util.List counts;

  /**
   * Default constructor.  Note that this does not initialize fields
   * to their default values from the schema.  If that is desired then
   * one should use newBuilder().
   */
  public Histogram() {}

  /**
   * All-args constructor.
   * @param duration The new value for duration
   * @param type The new value for type
   * @param bins The new value for bins
   * @param counts The new value for counts
   */
  public Histogram(java.lang.Integer duration, wavefront.report.HistogramType type, java.util.List bins, java.util.List counts) {
    this.duration = duration;
    this.type = type;
    this.bins = bins;
    this.counts = counts;
  }

  public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; }
  public org.apache.avro.Schema getSchema() { return SCHEMA$; }
  // Used by DatumWriter.  Applications should not call.
  public java.lang.Object get(int field$) {
    switch (field$) {
    case 0: return duration;
    case 1: return type;
    case 2: return bins;
    case 3: return counts;
    default: throw new org.apache.avro.AvroRuntimeException("Bad index");
    }
  }

  // Used by DatumReader.  Applications should not call.
  @SuppressWarnings(value="unchecked")
  public void put(int field$, java.lang.Object value$) {
    switch (field$) {
    case 0: duration = (java.lang.Integer)value$; break;
    case 1: type = (wavefront.report.HistogramType)value$; break;
    case 2: bins = (java.util.List)value$; break;
    case 3: counts = (java.util.List)value$; break;
    default: throw new org.apache.avro.AvroRuntimeException("Bad index");
    }
  }

  /**
   * Gets the value of the 'duration' field.
   * @return The value of the 'duration' field.
   */
  public int getDuration() {
    return duration;
  }


  /**
   * Sets the value of the 'duration' field.
   * @param value the value to set.
   */
      public void setDuration(int value) {
    this.duration = value;
  }
  
  /**
   * Gets the value of the 'type' field.
   * @return The value of the 'type' field.
   */
  public wavefront.report.HistogramType getType() {
    return type;
  }


  /**
   * Sets the value of the 'type' field.
   * @param value the value to set.
   */
      public void setType(wavefront.report.HistogramType value) {
    this.type = value;
  }
  
  /**
   * Gets the value of the 'bins' field.
   * @return The value of the 'bins' field.
   */
  public java.util.List getBins() {
    return bins;
  }


  /**
   * Sets the value of the 'bins' field.
   * @param value the value to set.
   */
      public void setBins(java.util.List value) {
    this.bins = value;
  }
  
  /**
   * Gets the value of the 'counts' field.
   * @return The value of the 'counts' field.
   */
  public java.util.List getCounts() {
    return counts;
  }


  /**
   * Sets the value of the 'counts' field.
   * @param value the value to set.
   */
      public void setCounts(java.util.List value) {
    this.counts = value;
  }
  
  /**
   * Creates a new Histogram RecordBuilder.
   * @return A new Histogram RecordBuilder
   */
  public static wavefront.report.Histogram.Builder newBuilder() {
    return new wavefront.report.Histogram.Builder();
  }

  /**
   * Creates a new Histogram RecordBuilder by copying an existing Builder.
   * @param other The existing builder to copy.
   * @return A new Histogram RecordBuilder
   */
  public static wavefront.report.Histogram.Builder newBuilder(wavefront.report.Histogram.Builder other) {
    if (other == null) {
      return new wavefront.report.Histogram.Builder();
    } else {
      return new wavefront.report.Histogram.Builder(other);
    }
  }

  /**
   * Creates a new Histogram RecordBuilder by copying an existing Histogram instance.
   * @param other The existing instance to copy.
   * @return A new Histogram RecordBuilder
   */
  public static wavefront.report.Histogram.Builder newBuilder(wavefront.report.Histogram other) {
    if (other == null) {
      return new wavefront.report.Histogram.Builder();
    } else {
      return new wavefront.report.Histogram.Builder(other);
    }
  }

  /**
   * RecordBuilder for Histogram instances.
   */
  @org.apache.avro.specific.AvroGenerated
  public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase
    implements org.apache.avro.data.RecordBuilder {

    private int duration;
    private wavefront.report.HistogramType type;
    private java.util.List bins;
    private java.util.List counts;

    /** Creates a new Builder */
    private Builder() {
      super(SCHEMA$);
    }

    /**
     * Creates a Builder by copying an existing Builder.
     * @param other The existing Builder to copy.
     */
    private Builder(wavefront.report.Histogram.Builder other) {
      super(other);
      if (isValidValue(fields()[0], other.duration)) {
        this.duration = data().deepCopy(fields()[0].schema(), other.duration);
        fieldSetFlags()[0] = other.fieldSetFlags()[0];
      }
      if (isValidValue(fields()[1], other.type)) {
        this.type = data().deepCopy(fields()[1].schema(), other.type);
        fieldSetFlags()[1] = other.fieldSetFlags()[1];
      }
      if (isValidValue(fields()[2], other.bins)) {
        this.bins = data().deepCopy(fields()[2].schema(), other.bins);
        fieldSetFlags()[2] = other.fieldSetFlags()[2];
      }
      if (isValidValue(fields()[3], other.counts)) {
        this.counts = data().deepCopy(fields()[3].schema(), other.counts);
        fieldSetFlags()[3] = other.fieldSetFlags()[3];
      }
    }

    /**
     * Creates a Builder by copying an existing Histogram instance
     * @param other The existing instance to copy.
     */
    private Builder(wavefront.report.Histogram other) {
      super(SCHEMA$);
      if (isValidValue(fields()[0], other.duration)) {
        this.duration = data().deepCopy(fields()[0].schema(), other.duration);
        fieldSetFlags()[0] = true;
      }
      if (isValidValue(fields()[1], other.type)) {
        this.type = data().deepCopy(fields()[1].schema(), other.type);
        fieldSetFlags()[1] = true;
      }
      if (isValidValue(fields()[2], other.bins)) {
        this.bins = data().deepCopy(fields()[2].schema(), other.bins);
        fieldSetFlags()[2] = true;
      }
      if (isValidValue(fields()[3], other.counts)) {
        this.counts = data().deepCopy(fields()[3].schema(), other.counts);
        fieldSetFlags()[3] = true;
      }
    }

    /**
      * Gets the value of the 'duration' field.
      * @return The value.
      */
    public int getDuration() {
      return duration;
    }
    
    /**
      * Sets the value of the 'duration' field.
      * @param value The value of 'duration'.
      * @return This builder.
      */
    public wavefront.report.Histogram.Builder setDuration(int value) {
      validate(fields()[0], value);
      this.duration = value;
      fieldSetFlags()[0] = true;
      return this;
    }
    
    
    /**
      * Checks whether the 'duration' field has been set.
      * @return True if the 'duration' field has been set, false otherwise.
      */
    public boolean hasDuration() {
      return fieldSetFlags()[0];
    }


    /**
      * Clears the value of the 'duration' field.
      * @return This builder.
      */
    public wavefront.report.Histogram.Builder clearDuration() {
      fieldSetFlags()[0] = false;
      return this;
    }

    /**
      * Gets the value of the 'type' field.
      * @return The value.
      */
    public wavefront.report.HistogramType getType() {
      return type;
    }
    
    /**
      * Sets the value of the 'type' field.
      * @param value The value of 'type'.
      * @return This builder.
      */
    public wavefront.report.Histogram.Builder setType(wavefront.report.HistogramType value) {
      validate(fields()[1], value);
      this.type = value;
      fieldSetFlags()[1] = true;
      return this;
    }
    
    
    /**
      * Checks whether the 'type' field has been set.
      * @return True if the 'type' field has been set, false otherwise.
      */
    public boolean hasType() {
      return fieldSetFlags()[1];
    }


    /**
      * Clears the value of the 'type' field.
      * @return This builder.
      */
    public wavefront.report.Histogram.Builder clearType() {
      type = null;
      fieldSetFlags()[1] = false;
      return this;
    }

    /**
      * Gets the value of the 'bins' field.
      * @return The value.
      */
    public java.util.List getBins() {
      return bins;
    }
    
    /**
      * Sets the value of the 'bins' field.
      * @param value The value of 'bins'.
      * @return This builder.
      */
    public wavefront.report.Histogram.Builder setBins(java.util.List value) {
      validate(fields()[2], value);
      this.bins = value;
      fieldSetFlags()[2] = true;
      return this;
    }
    
    
    /**
      * Checks whether the 'bins' field has been set.
      * @return True if the 'bins' field has been set, false otherwise.
      */
    public boolean hasBins() {
      return fieldSetFlags()[2];
    }


    /**
      * Clears the value of the 'bins' field.
      * @return This builder.
      */
    public wavefront.report.Histogram.Builder clearBins() {
      bins = null;
      fieldSetFlags()[2] = false;
      return this;
    }

    /**
      * Gets the value of the 'counts' field.
      * @return The value.
      */
    public java.util.List getCounts() {
      return counts;
    }
    
    /**
      * Sets the value of the 'counts' field.
      * @param value The value of 'counts'.
      * @return This builder.
      */
    public wavefront.report.Histogram.Builder setCounts(java.util.List value) {
      validate(fields()[3], value);
      this.counts = value;
      fieldSetFlags()[3] = true;
      return this;
    }
    
    
    /**
      * Checks whether the 'counts' field has been set.
      * @return True if the 'counts' field has been set, false otherwise.
      */
    public boolean hasCounts() {
      return fieldSetFlags()[3];
    }


    /**
      * Clears the value of the 'counts' field.
      * @return This builder.
      */
    public wavefront.report.Histogram.Builder clearCounts() {
      counts = null;
      fieldSetFlags()[3] = false;
      return this;
    }

    @Override
    @SuppressWarnings("unchecked")
    public Histogram build() {
      try {
        Histogram record = new Histogram();
        record.duration = fieldSetFlags()[0] ? this.duration : (java.lang.Integer) defaultValue(fields()[0]);
        record.type = fieldSetFlags()[1] ? this.type : (wavefront.report.HistogramType) defaultValue(fields()[1]);
        record.bins = fieldSetFlags()[2] ? this.bins : (java.util.List) defaultValue(fields()[2]);
        record.counts = fieldSetFlags()[3] ? this.counts : (java.util.List) defaultValue(fields()[3]);
        return record;
      } catch (org.apache.avro.AvroMissingFieldException e) {
        throw e;
      } catch (java.lang.Exception e) {
        throw new org.apache.avro.AvroRuntimeException(e);
      }
    }
  }

  @SuppressWarnings("unchecked")
  private static final org.apache.avro.io.DatumWriter
    WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$);

  @Override public void writeExternal(java.io.ObjectOutput out)
    throws java.io.IOException {
    WRITER$.write(this, SpecificData.getEncoder(out));
  }

  @SuppressWarnings("unchecked")
  private static final org.apache.avro.io.DatumReader
    READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$);

  @Override public void readExternal(java.io.ObjectInput in)
    throws java.io.IOException {
    READER$.read(this, SpecificData.getDecoder(in));
  }

  @Override protected boolean hasCustomCoders() { return true; }

  @Override public void customEncode(org.apache.avro.io.Encoder out)
    throws java.io.IOException
  {
    out.writeInt(this.duration);

    out.writeEnum(this.type.ordinal());

    long size0 = this.bins.size();
    out.writeArrayStart();
    out.setItemCount(size0);
    long actualSize0 = 0;
    for (java.lang.Double e0: this.bins) {
      actualSize0++;
      out.startItem();
      out.writeDouble(e0);
    }
    out.writeArrayEnd();
    if (actualSize0 != size0)
      throw new java.util.ConcurrentModificationException("Array-size written was " + size0 + ", but element count was " + actualSize0 + ".");

    long size1 = this.counts.size();
    out.writeArrayStart();
    out.setItemCount(size1);
    long actualSize1 = 0;
    for (java.lang.Integer e1: this.counts) {
      actualSize1++;
      out.startItem();
      out.writeInt(e1);
    }
    out.writeArrayEnd();
    if (actualSize1 != size1)
      throw new java.util.ConcurrentModificationException("Array-size written was " + size1 + ", but element count was " + actualSize1 + ".");

  }

  @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in)
    throws java.io.IOException
  {
    org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff();
    if (fieldOrder == null) {
      this.duration = in.readInt();

      this.type = wavefront.report.HistogramType.values()[in.readEnum()];

      long size0 = in.readArrayStart();
      java.util.List a0 = this.bins;
      if (a0 == null) {
        a0 = new SpecificData.Array((int)size0, SCHEMA$.getField("bins").schema());
        this.bins = a0;
      } else a0.clear();
      SpecificData.Array ga0 = (a0 instanceof SpecificData.Array ? (SpecificData.Array)a0 : null);
      for ( ; 0 < size0; size0 = in.arrayNext()) {
        for ( ; size0 != 0; size0--) {
          java.lang.Double e0 = (ga0 != null ? ga0.peek() : null);
          e0 = in.readDouble();
          a0.add(e0);
        }
      }

      long size1 = in.readArrayStart();
      java.util.List a1 = this.counts;
      if (a1 == null) {
        a1 = new SpecificData.Array((int)size1, SCHEMA$.getField("counts").schema());
        this.counts = a1;
      } else a1.clear();
      SpecificData.Array ga1 = (a1 instanceof SpecificData.Array ? (SpecificData.Array)a1 : null);
      for ( ; 0 < size1; size1 = in.arrayNext()) {
        for ( ; size1 != 0; size1--) {
          java.lang.Integer e1 = (ga1 != null ? ga1.peek() : null);
          e1 = in.readInt();
          a1.add(e1);
        }
      }

    } else {
      for (int i = 0; i < 4; i++) {
        switch (fieldOrder[i].pos()) {
        case 0:
          this.duration = in.readInt();
          break;

        case 1:
          this.type = wavefront.report.HistogramType.values()[in.readEnum()];
          break;

        case 2:
          long size0 = in.readArrayStart();
          java.util.List a0 = this.bins;
          if (a0 == null) {
            a0 = new SpecificData.Array((int)size0, SCHEMA$.getField("bins").schema());
            this.bins = a0;
          } else a0.clear();
          SpecificData.Array ga0 = (a0 instanceof SpecificData.Array ? (SpecificData.Array)a0 : null);
          for ( ; 0 < size0; size0 = in.arrayNext()) {
            for ( ; size0 != 0; size0--) {
              java.lang.Double e0 = (ga0 != null ? ga0.peek() : null);
              e0 = in.readDouble();
              a0.add(e0);
            }
          }
          break;

        case 3:
          long size1 = in.readArrayStart();
          java.util.List a1 = this.counts;
          if (a1 == null) {
            a1 = new SpecificData.Array((int)size1, SCHEMA$.getField("counts").schema());
            this.counts = a1;
          } else a1.clear();
          SpecificData.Array ga1 = (a1 instanceof SpecificData.Array ? (SpecificData.Array)a1 : null);
          for ( ; 0 < size1; size1 = in.arrayNext()) {
            for ( ; size1 != 0; size1--) {
              java.lang.Integer e1 = (ga1 != null ? ga1.peek() : null);
              e1 = in.readInt();
              a1.add(e1);
            }
          }
          break;

        default:
          throw new java.io.IOException("Corrupt ResolvingDecoder.");
        }
      }
    }
  }
}














© 2015 - 2024 Weber Informatics LLC | Privacy Policy