/** * Read from a stream. */ public PercentilesAggregationBuilder(StreamInput in) throws IOException { super(in, ValuesSourceType.NUMERIC, ValueType.NUMERIC); percents = in.readDoubleArray(); keyed = in.readBoolean(); numberOfSignificantValueDigits = in.readVInt(); compression = in.readDouble(); method = PercentilesMethod.readFromStream(in); }
@Override protected int innerHashCode() { switch (method) { case HDR: return Objects.hash(Arrays.hashCode(percents), keyed, numberOfSignificantValueDigits, method); case TDIGEST: return Objects.hash(Arrays.hashCode(percents), keyed, compression, method); default: throw new IllegalStateException("Illegal method [" + method.toString() + "]"); } }
@Override protected void innerWriteTo(StreamOutput out) throws IOException { out.writeDoubleArray(values); out.writeBoolean(keyed); out.writeVInt(numberOfSignificantValueDigits); out.writeDouble(compression); method.writeTo(out); }
if (method != null) { throw new SearchParseException(context, "Found multiple methods in [" + aggregationName + "]: [" + currentFieldName + "]. only one of [" + PercentilesMethod.TDIGEST.getName() + "] and [" + PercentilesMethod.HDR.getName() + "] may be used.", parser.getTokenLocation()); method = PercentilesMethod.resolveFromName(currentFieldName); if (method == null) { throw new SearchParseException(context, "Unexpected token " + token + " in [" + aggregationName + "].",
/** * Returns the {@link PercentilesMethod} for this method name. returns * <code>null</code> if no {@link PercentilesMethod} exists for the name. */ public static PercentilesMethod resolveFromName(String name) { for (PercentilesMethod method : values()) { if (method.name.equalsIgnoreCase(name)) { return method; } } return null; } }
@Override protected void internalXContent(XContentBuilder builder, Params params) throws IOException { super.internalXContent(builder, params); doInternalXContent(builder, params); if (method != null) { builder.startObject(method.getName()); if (compression != null) { builder.field(AbstractPercentilesParser.COMPRESSION_FIELD.getPreferredName(), compression); } if (numberOfSignificantValueDigits != null) { builder.field(AbstractPercentilesParser.NUMBER_SIGNIFICANT_DIGITS_FIELD.getPreferredName(), numberOfSignificantValueDigits); } builder.endObject(); } }
@Override protected boolean innerEquals(Object obj) { PercentilesAggregationBuilder other = (PercentilesAggregationBuilder) obj; if (!Objects.equals(method, other.method)) { return false; } boolean equalSettings = false; switch (method) { case HDR: equalSettings = Objects.equals(numberOfSignificantValueDigits, other.numberOfSignificantValueDigits); break; case TDIGEST: equalSettings = Objects.equals(compression, other.compression); break; default: throw new IllegalStateException("Illegal method [" + method.toString() + "]"); } return equalSettings && Objects.deepEquals(percents, other.percents) && Objects.equals(keyed, other.keyed) && Objects.equals(method, other.method); }
/** * Read from a stream. */ public PercentileRanksAggregationBuilder(StreamInput in) throws IOException { super(in, ValuesSourceType.NUMERIC, ValueType.NUMERIC); values = in.readDoubleArray(); keyed = in.readBoolean(); numberOfSignificantValueDigits = in.readVInt(); compression = in.readDouble(); method = PercentilesMethod.readFromStream(in); }
@Override protected void innerWriteTo(StreamOutput out) throws IOException { out.writeDoubleArray(percents); out.writeBoolean(keyed); out.writeVInt(numberOfSignificantValueDigits); out.writeDouble(compression); method.writeTo(out); }
@Override protected XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException { builder.array(VALUES_FIELD.getPreferredName(), values); builder.field(PercentilesAggregationBuilder.KEYED_FIELD.getPreferredName(), keyed); builder.startObject(method.toString()); if (method == PercentilesMethod.TDIGEST) { builder.field(PercentilesAggregationBuilder.COMPRESSION_FIELD.getPreferredName(), compression); } else { builder.field(PercentilesAggregationBuilder.NUMBER_SIGNIFICANT_DIGITS_FIELD.getPreferredName(), numberOfSignificantValueDigits); } builder.endObject(); return builder; }
/** * Read from a stream. */ public PercentileRanksAggregationBuilder(StreamInput in) throws IOException { super(in, ValuesSourceType.NUMERIC, ValueType.NUMERIC); values = in.readDoubleArray(); keyed = in.readBoolean(); numberOfSignificantValueDigits = in.readVInt(); compression = in.readDouble(); method = PercentilesMethod.readFromStream(in); }
@Override protected void innerWriteTo(StreamOutput out) throws IOException { out.writeDoubleArray(values); out.writeBoolean(keyed); out.writeVInt(numberOfSignificantValueDigits); out.writeDouble(compression); method.writeTo(out); }
@Override protected XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException { builder.array(PERCENTS_FIELD.getPreferredName(), percents); builder.field(KEYED_FIELD.getPreferredName(), keyed); builder.startObject(method.toString()); if (method == PercentilesMethod.TDIGEST) { builder.field(COMPRESSION_FIELD.getPreferredName(), compression); } else { builder.field(NUMBER_SIGNIFICANT_DIGITS_FIELD.getPreferredName(), numberOfSignificantValueDigits); } builder.endObject(); return builder; }
/** * Read from a stream. */ public PercentileRanksAggregationBuilder(StreamInput in) throws IOException { super(in, ValuesSourceType.NUMERIC, ValueType.NUMERIC); values = in.readDoubleArray(); keyed = in.readBoolean(); numberOfSignificantValueDigits = in.readVInt(); compression = in.readDouble(); method = PercentilesMethod.readFromStream(in); }
@Override protected void innerWriteTo(StreamOutput out) throws IOException { out.writeDoubleArray(values); out.writeBoolean(keyed); out.writeVInt(numberOfSignificantValueDigits); out.writeDouble(compression); method.writeTo(out); }
@Override protected int innerHashCode() { switch (method) { case HDR: return Objects.hash(Arrays.hashCode(percents), keyed, numberOfSignificantValueDigits, method); case TDIGEST: return Objects.hash(Arrays.hashCode(percents), keyed, compression, method); default: throw new IllegalStateException("Illegal method [" + method.toString() + "]"); } }
/** * Read from a stream. */ public PercentilesAggregationBuilder(StreamInput in) throws IOException { super(in, ValuesSourceType.NUMERIC, ValueType.NUMERIC); percents = in.readDoubleArray(); keyed = in.readBoolean(); numberOfSignificantValueDigits = in.readVInt(); compression = in.readDouble(); method = PercentilesMethod.readFromStream(in); }
@Override protected void innerWriteTo(StreamOutput out) throws IOException { out.writeDoubleArray(percents); out.writeBoolean(keyed); out.writeVInt(numberOfSignificantValueDigits); out.writeDouble(compression); method.writeTo(out); }
@Override protected int innerHashCode() { switch (method) { case HDR: return Objects.hash(Arrays.hashCode(percents), keyed, numberOfSignificantValueDigits, method); case TDIGEST: return Objects.hash(Arrays.hashCode(percents), keyed, compression, method); default: throw new IllegalStateException("Illegal method [" + method.toString() + "]"); } }
/** * Read from a stream. */ public PercentilesAggregationBuilder(StreamInput in) throws IOException { super(in, ValuesSourceType.NUMERIC, ValueType.NUMERIC); percents = in.readDoubleArray(); keyed = in.readBoolean(); numberOfSignificantValueDigits = in.readVInt(); compression = in.readDouble(); method = PercentilesMethod.readFromStream(in); }