Normalize registration of MovAvgModels
This is what happens when you pull on the "Remove the PROTOTYPEs from MovAvgModels" string. This removes MovAvgModelStreams in favor of readNamedWriteable and MovAvgParserMapper in favor of ParseFieldRegistry<MovAvgModel.AbstractModelParser>. Relates to #17085
This commit is contained in:
parent
ca8ea36b30
commit
8126c08400
|
@ -232,8 +232,12 @@ import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativePipel
|
|||
import org.elasticsearch.search.aggregations.pipeline.derivative.InternalDerivative;
|
||||
import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgPipelineAggregator;
|
||||
import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgPipelineAggregatorBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.movavg.models.EwmaModel;
|
||||
import org.elasticsearch.search.aggregations.pipeline.movavg.models.HoltLinearModel;
|
||||
import org.elasticsearch.search.aggregations.pipeline.movavg.models.HoltWintersModel;
|
||||
import org.elasticsearch.search.aggregations.pipeline.movavg.models.LinearModel;
|
||||
import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModel;
|
||||
import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModelParserMapper;
|
||||
import org.elasticsearch.search.aggregations.pipeline.movavg.models.SimpleModel;
|
||||
import org.elasticsearch.search.aggregations.pipeline.serialdiff.SerialDiffPipelineAggregator;
|
||||
import org.elasticsearch.search.aggregations.pipeline.serialdiff.SerialDiffPipelineAggregatorBuilder;
|
||||
import org.elasticsearch.search.controller.SearchPhaseController;
|
||||
|
@ -281,9 +285,10 @@ public class SearchModule extends AbstractModule {
|
|||
private final AggregatorParsers aggregatorParsers = new AggregatorParsers(aggregationParserRegistry, pipelineAggregationParserRegistry);
|
||||
private final ParseFieldRegistry<SignificanceHeuristicParser> significanceHeuristicParserRegistry = new ParseFieldRegistry<>(
|
||||
"significance_heuristic");
|
||||
private final ParseFieldRegistry<MovAvgModel.AbstractModelParser> movingAverageModelParserRegistry = new ParseFieldRegistry<>(
|
||||
"moving_avg_model");
|
||||
|
||||
private final Set<Class<? extends FetchSubPhase>> fetchSubPhases = new HashSet<>();
|
||||
private final Set<MovAvgModel.AbstractModelParser> modelParsers = new HashSet<>();
|
||||
|
||||
private final Settings settings;
|
||||
private final NamedWriteableRegistry namedWriteableRegistry;
|
||||
|
@ -302,6 +307,7 @@ public class SearchModule extends AbstractModule {
|
|||
registerBuiltinSorts();
|
||||
registerBuiltinValueFormats();
|
||||
registerBuiltinSignificanceHeuristics();
|
||||
registerBuiltinMovingAverageModels();
|
||||
}
|
||||
|
||||
public void registerHighlighter(String key, Class<? extends Highlighter> clazz) {
|
||||
|
@ -373,7 +379,7 @@ public class SearchModule extends AbstractModule {
|
|||
* @param heuristicName the name(s) at which the heuristic is parsed and streamed. The {@link ParseField#getPreferredName()} is the name
|
||||
* under which it is streamed. All names work for the parser.
|
||||
* @param reader reads the heuristic from a stream
|
||||
* @param parser reads the heuristic from a XContentParser
|
||||
* @param parser reads the heuristic from an XContentParser
|
||||
*/
|
||||
public void registerSignificanceHeuristic(ParseField heuristicName, Writeable.Reader<SignificanceHeuristic> reader,
|
||||
SignificanceHeuristicParser parser) {
|
||||
|
@ -388,8 +394,25 @@ public class SearchModule extends AbstractModule {
|
|||
return significanceHeuristicParserRegistry;
|
||||
}
|
||||
|
||||
public void registerModelParser(MovAvgModel.AbstractModelParser parser) {
|
||||
modelParsers.add(parser);
|
||||
/**
|
||||
* Register a {@link MovAvgModel}.
|
||||
*
|
||||
* @param modelName the name(s) at which the model is parsed and streamed. The {@link ParseField#getPreferredName()} is the name under
|
||||
* which it is streamed. All named work for the parser.
|
||||
* @param reader reads the model from a stream
|
||||
* @param parser reads the model from an XContentParser
|
||||
*/
|
||||
public void registerMovingAverageModel(ParseField modelName, Writeable.Reader<MovAvgModel> reader,
|
||||
MovAvgModel.AbstractModelParser parser) {
|
||||
movingAverageModelParserRegistry.register(parser, modelName);
|
||||
namedWriteableRegistry.register(MovAvgModel.class, modelName.getPreferredName(), reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* The registry of {@link MovAvgModel}s.
|
||||
*/
|
||||
public ParseFieldRegistry<MovAvgModel.AbstractModelParser> getMovingAverageMdelParserRegistry() {
|
||||
return movingAverageModelParserRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -457,8 +480,6 @@ public class SearchModule extends AbstractModule {
|
|||
}
|
||||
|
||||
protected void configureAggs() {
|
||||
MovAvgModelParserMapper movAvgModelParserMapper = new MovAvgModelParserMapper(modelParsers);
|
||||
|
||||
registerAggregation(AvgAggregatorBuilder::new, new AvgParser(), AvgAggregatorBuilder.AGGREGATION_NAME_FIELD);
|
||||
registerAggregation(SumAggregatorBuilder::new, new SumParser(), SumAggregatorBuilder.AGGREGATION_NAME_FIELD);
|
||||
registerAggregation(MinAggregatorBuilder::new, new MinParser(), MinAggregatorBuilder.AGGREGATION_NAME_FIELD);
|
||||
|
@ -525,7 +546,7 @@ public class SearchModule extends AbstractModule {
|
|||
registerPipelineAggregation(PercentilesBucketPipelineAggregatorBuilder::new, PercentilesBucketPipelineAggregatorBuilder.PARSER,
|
||||
PercentilesBucketPipelineAggregatorBuilder.AGGREGATION_NAME_FIELD);
|
||||
registerPipelineAggregation(MovAvgPipelineAggregatorBuilder::new,
|
||||
(n, c) -> MovAvgPipelineAggregatorBuilder.parse(movAvgModelParserMapper, n, c),
|
||||
(n, c) -> MovAvgPipelineAggregatorBuilder.parse(movingAverageModelParserRegistry, n, c),
|
||||
MovAvgPipelineAggregatorBuilder.AGGREGATION_FIELD_NAME);
|
||||
registerPipelineAggregation(CumulativeSumPipelineAggregatorBuilder::new, CumulativeSumPipelineAggregatorBuilder::parse,
|
||||
CumulativeSumPipelineAggregatorBuilder.AGGREGATION_NAME_FIELD);
|
||||
|
@ -612,6 +633,14 @@ public class SearchModule extends AbstractModule {
|
|||
registerSignificanceHeuristic(ScriptHeuristic.NAMES_FIELD, ScriptHeuristic::new, ScriptHeuristic::parse);
|
||||
}
|
||||
|
||||
private void registerBuiltinMovingAverageModels() {
|
||||
registerMovingAverageModel(SimpleModel.NAME_FIELD, SimpleModel::new, SimpleModel.PARSER);
|
||||
registerMovingAverageModel(LinearModel.NAME_FIELD, LinearModel::new, LinearModel.PARSER);
|
||||
registerMovingAverageModel(EwmaModel.NAME_FIELD, EwmaModel::new, EwmaModel.PARSER);
|
||||
registerMovingAverageModel(HoltLinearModel.NAME_FIELD, HoltLinearModel::new, HoltLinearModel.PARSER);
|
||||
registerMovingAverageModel(HoltWintersModel.NAME_FIELD, HoltWintersModel::new, HoltWintersModel.PARSER);
|
||||
}
|
||||
|
||||
private void registerBuiltinQueryParsers() {
|
||||
registerQuery(MatchQueryBuilder::new, MatchQueryBuilder::fromXContent, MatchQueryBuilder.QUERY_NAME_FIELD);
|
||||
registerQuery(MatchPhraseQueryBuilder::new, MatchPhraseQueryBuilder::fromXContent, MatchPhraseQueryBuilder.QUERY_NAME_FIELD);
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue;
|
|||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
|
||||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams;
|
||||
import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModel;
|
||||
import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModelStreams;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -254,7 +253,7 @@ public class MovAvgPipelineAggregator extends PipelineAggregator {
|
|||
gapPolicy = GapPolicy.readFrom(in);
|
||||
window = in.readVInt();
|
||||
predict = in.readVInt();
|
||||
model = MovAvgModelStreams.read(in);
|
||||
model = in.readNamedWriteable(MovAvgModel.class);
|
||||
minimize = in.readBoolean();
|
||||
|
||||
}
|
||||
|
@ -265,7 +264,7 @@ public class MovAvgPipelineAggregator extends PipelineAggregator {
|
|||
gapPolicy.writeTo(out);
|
||||
out.writeVInt(window);
|
||||
out.writeVInt(predict);
|
||||
model.writeTo(out);
|
||||
out.writeNamedWriteable(model);
|
||||
out.writeBoolean(minimize);
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.elasticsearch.common.ParseField;
|
|||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.xcontent.ParseFieldRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
@ -34,8 +35,6 @@ import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
|
|||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModel;
|
||||
import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModelBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModelParserMapper;
|
||||
import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModelStreams;
|
||||
import org.elasticsearch.search.aggregations.pipeline.movavg.models.SimpleModel;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -78,7 +77,7 @@ public class MovAvgPipelineAggregatorBuilder extends PipelineAggregatorBuilder<M
|
|||
format = in.readOptionalString();
|
||||
gapPolicy = GapPolicy.readFrom(in);
|
||||
window = in.readVInt();
|
||||
model = MovAvgModelStreams.read(in);
|
||||
model = in.readNamedWriteable(MovAvgModel.class);
|
||||
predict = in.readVInt();
|
||||
minimize = in.readOptionalBoolean();
|
||||
}
|
||||
|
@ -88,7 +87,7 @@ public class MovAvgPipelineAggregatorBuilder extends PipelineAggregatorBuilder<M
|
|||
out.writeOptionalString(format);
|
||||
gapPolicy.writeTo(out);
|
||||
out.writeVInt(window);
|
||||
model.writeTo(out);
|
||||
out.writeNamedWriteable(model);
|
||||
out.writeVInt(predict);
|
||||
out.writeOptionalBoolean(minimize);
|
||||
}
|
||||
|
@ -296,8 +295,8 @@ public class MovAvgPipelineAggregatorBuilder extends PipelineAggregatorBuilder<M
|
|||
return builder;
|
||||
}
|
||||
|
||||
public static MovAvgPipelineAggregatorBuilder parse(MovAvgModelParserMapper movAvgModelParserMapper, String pipelineAggregatorName,
|
||||
QueryParseContext context) throws IOException {
|
||||
public static MovAvgPipelineAggregatorBuilder parse(ParseFieldRegistry<MovAvgModel.AbstractModelParser> movingAverageMdelParserRegistry,
|
||||
String pipelineAggregatorName, QueryParseContext context) throws IOException {
|
||||
XContentParser parser = context.parser();
|
||||
XContentParser.Token token;
|
||||
String currentFieldName = null;
|
||||
|
@ -396,12 +395,8 @@ public class MovAvgPipelineAggregatorBuilder extends PipelineAggregatorBuilder<M
|
|||
factory.predict(predict);
|
||||
}
|
||||
if (model != null) {
|
||||
MovAvgModel.AbstractModelParser modelParser = movAvgModelParserMapper.get(model);
|
||||
if (modelParser == null) {
|
||||
throw new ParsingException(parser.getTokenLocation(),
|
||||
"Unknown model [" + model + "] specified. Valid options are:" + movAvgModelParserMapper.getAllNames().toString());
|
||||
}
|
||||
|
||||
MovAvgModel.AbstractModelParser modelParser = movingAverageMdelParserRegistry.lookup(model, parser,
|
||||
context.getParseFieldMatcher());
|
||||
MovAvgModel movAvgModel;
|
||||
try {
|
||||
movAvgModel = modelParser.parse(settings, pipelineAggregatorName, factory.window(), context.getParseFieldMatcher());
|
||||
|
|
|
@ -38,9 +38,9 @@ import java.util.Objects;
|
|||
* Calculate a exponentially weighted moving average
|
||||
*/
|
||||
public class EwmaModel extends MovAvgModel {
|
||||
public static final String NAME = "ewma";
|
||||
public static final ParseField NAME_FIELD = new ParseField(NAME);
|
||||
|
||||
private static final EwmaModel PROTOTYPE = new EwmaModel();
|
||||
protected static final ParseField NAME_FIELD = new ParseField("ewma");
|
||||
public static final double DEFAULT_ALPHA = 0.3;
|
||||
|
||||
/**
|
||||
|
@ -59,6 +59,23 @@ public class EwmaModel extends MovAvgModel {
|
|||
this.alpha = alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read from a stream.
|
||||
*/
|
||||
public EwmaModel(StreamInput in) throws IOException {
|
||||
alpha = in.readDouble();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeDouble(alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWriteableName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeMinimized() {
|
||||
return true;
|
||||
|
@ -101,18 +118,6 @@ public class EwmaModel extends MovAvgModel {
|
|||
return avg;
|
||||
}
|
||||
|
||||
public static final MovAvgModelStreams.Stream STREAM = new MovAvgModelStreams.Stream() {
|
||||
@Override
|
||||
public MovAvgModel readResult(StreamInput in) throws IOException {
|
||||
return PROTOTYPE.readFrom(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME_FIELD.getPreferredName();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.field(MovAvgPipelineAggregatorBuilder.MODEL.getPreferredName(), NAME_FIELD.getPreferredName());
|
||||
|
@ -122,16 +127,15 @@ public class EwmaModel extends MovAvgModel {
|
|||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovAvgModel readFrom(StreamInput in) throws IOException {
|
||||
return new EwmaModel(in.readDouble());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeString(STREAM.getName());
|
||||
out.writeDouble(alpha);
|
||||
}
|
||||
public static final AbstractModelParser PARSER = new AbstractModelParser() {
|
||||
@Override
|
||||
public MovAvgModel parse(@Nullable Map<String, Object> settings, String pipelineName, int windowSize,
|
||||
ParseFieldMatcher parseFieldMatcher) throws ParseException {
|
||||
double alpha = parseDoubleParam(settings, "alpha", DEFAULT_ALPHA);
|
||||
checkUnrecognizedParams(settings);
|
||||
return new EwmaModel(alpha);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
@ -150,24 +154,6 @@ public class EwmaModel extends MovAvgModel {
|
|||
return Objects.equals(alpha, other.alpha);
|
||||
}
|
||||
|
||||
public static class SingleExpModelParser extends AbstractModelParser {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME_FIELD.getPreferredName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovAvgModel parse(@Nullable Map<String, Object> settings, String pipelineName, int windowSize,
|
||||
ParseFieldMatcher parseFieldMatcher) throws ParseException {
|
||||
|
||||
double alpha = parseDoubleParam(settings, "alpha", DEFAULT_ALPHA);
|
||||
checkUnrecognizedParams(settings);
|
||||
return new EwmaModel(alpha);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class EWMAModelBuilder implements MovAvgModelBuilder {
|
||||
|
||||
private double alpha = DEFAULT_ALPHA;
|
||||
|
|
|
@ -37,9 +37,9 @@ import java.util.Objects;
|
|||
* Calculate a doubly exponential weighted moving average
|
||||
*/
|
||||
public class HoltLinearModel extends MovAvgModel {
|
||||
public static final String NAME = "holt";
|
||||
public static final ParseField NAME_FIELD = new ParseField(NAME);
|
||||
|
||||
private static final HoltLinearModel PROTOTYPE = new HoltLinearModel();
|
||||
protected static final ParseField NAME_FIELD = new ParseField("holt");
|
||||
public static final double DEFAULT_ALPHA = 0.3;
|
||||
public static final double DEFAULT_BETA = 0.1;
|
||||
|
||||
|
@ -68,6 +68,25 @@ public class HoltLinearModel extends MovAvgModel {
|
|||
this.beta = beta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read from a stream.
|
||||
*/
|
||||
public HoltLinearModel(StreamInput in) throws IOException {
|
||||
alpha = in.readDouble();
|
||||
beta = in.readDouble();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeDouble(alpha);
|
||||
out.writeDouble(beta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWriteableName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeMinimized() {
|
||||
return true;
|
||||
|
@ -162,18 +181,6 @@ public class HoltLinearModel extends MovAvgModel {
|
|||
return forecastValues;
|
||||
}
|
||||
|
||||
public static final MovAvgModelStreams.Stream STREAM = new MovAvgModelStreams.Stream() {
|
||||
@Override
|
||||
public MovAvgModel readResult(StreamInput in) throws IOException {
|
||||
return PROTOTYPE.readFrom(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME_FIELD.getPreferredName();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.field(MovAvgPipelineAggregatorBuilder.MODEL.getPreferredName(), NAME_FIELD.getPreferredName());
|
||||
|
@ -184,17 +191,18 @@ public class HoltLinearModel extends MovAvgModel {
|
|||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovAvgModel readFrom(StreamInput in) throws IOException {
|
||||
return new HoltLinearModel(in.readDouble(), in.readDouble());
|
||||
}
|
||||
public static final AbstractModelParser PARSER = new AbstractModelParser() {
|
||||
@Override
|
||||
public MovAvgModel parse(@Nullable Map<String, Object> settings, String pipelineName, int windowSize,
|
||||
ParseFieldMatcher parseFieldMatcher) throws ParseException {
|
||||
|
||||
double alpha = parseDoubleParam(settings, "alpha", DEFAULT_ALPHA);
|
||||
double beta = parseDoubleParam(settings, "beta", DEFAULT_BETA);
|
||||
checkUnrecognizedParams(settings);
|
||||
return new HoltLinearModel(alpha, beta);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeString(STREAM.getName());
|
||||
out.writeDouble(alpha);
|
||||
out.writeDouble(beta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
@ -214,27 +222,8 @@ public class HoltLinearModel extends MovAvgModel {
|
|||
&& Objects.equals(beta, other.beta);
|
||||
}
|
||||
|
||||
public static class DoubleExpModelParser extends AbstractModelParser {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME_FIELD.getPreferredName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovAvgModel parse(@Nullable Map<String, Object> settings, String pipelineName, int windowSize,
|
||||
ParseFieldMatcher parseFieldMatcher) throws ParseException {
|
||||
|
||||
double alpha = parseDoubleParam(settings, "alpha", DEFAULT_ALPHA);
|
||||
double beta = parseDoubleParam(settings, "beta", DEFAULT_BETA);
|
||||
checkUnrecognizedParams(settings);
|
||||
return new HoltLinearModel(alpha, beta);
|
||||
}
|
||||
}
|
||||
|
||||
public static class HoltLinearModelBuilder implements MovAvgModelBuilder {
|
||||
|
||||
|
||||
private double alpha = DEFAULT_ALPHA;
|
||||
private double beta = DEFAULT_BETA;
|
||||
|
||||
|
|
|
@ -43,56 +43,15 @@ import java.util.Objects;
|
|||
* Calculate a triple exponential weighted moving average
|
||||
*/
|
||||
public class HoltWintersModel extends MovAvgModel {
|
||||
public static final String NAME = "holt_winters";
|
||||
public static final ParseField NAME_FIELD = new ParseField(NAME);
|
||||
|
||||
protected static final ParseField NAME_FIELD = new ParseField("holt_winters");
|
||||
public static final double DEFAULT_ALPHA = 0.3;
|
||||
public static final double DEFAULT_BETA = 0.1;
|
||||
public static final double DEFAULT_GAMMA = 0.3;
|
||||
public static final int DEFAULT_PERIOD = 1;
|
||||
public static final SeasonalityType DEFAULT_SEASONALITY_TYPE = SeasonalityType.ADDITIVE;
|
||||
public static final boolean DEFAULT_PAD = false;
|
||||
private static final HoltWintersModel PROTOTYPE = new HoltWintersModel();
|
||||
|
||||
/**
|
||||
* Controls smoothing of data. Also known as "level" value.
|
||||
* Alpha = 1 retains no memory of past values
|
||||
* (e.g. random walk), while alpha = 0 retains infinite memory of past values (e.g.
|
||||
* mean of the series).
|
||||
*/
|
||||
private final double alpha;
|
||||
|
||||
/**
|
||||
* Controls smoothing of trend.
|
||||
* Beta = 1 retains no memory of past values
|
||||
* (e.g. random walk), while alpha = 0 retains infinite memory of past values (e.g.
|
||||
* mean of the series).
|
||||
*/
|
||||
private final double beta;
|
||||
|
||||
/**
|
||||
* Controls smoothing of seasonality.
|
||||
* Gamma = 1 retains no memory of past values
|
||||
* (e.g. random walk), while alpha = 0 retains infinite memory of past values (e.g.
|
||||
* mean of the series).
|
||||
*/
|
||||
private final double gamma;
|
||||
|
||||
/**
|
||||
* Periodicity of the data
|
||||
*/
|
||||
private final int period;
|
||||
|
||||
/**
|
||||
* Whether this is a multiplicative or additive HW
|
||||
*/
|
||||
private final SeasonalityType seasonalityType;
|
||||
|
||||
/**
|
||||
* Padding is used to add a very small amount to values, so that zeroes do not interfere
|
||||
* with multiplicative seasonality math (e.g. division by zero)
|
||||
*/
|
||||
private final boolean pad;
|
||||
private final double padding;
|
||||
|
||||
public enum SeasonalityType {
|
||||
ADDITIVE((byte) 0, "add"), MULTIPLICATIVE((byte) 1, "mult");
|
||||
|
@ -167,6 +126,47 @@ public class HoltWintersModel extends MovAvgModel {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls smoothing of data. Also known as "level" value.
|
||||
* Alpha = 1 retains no memory of past values
|
||||
* (e.g. random walk), while alpha = 0 retains infinite memory of past values (e.g.
|
||||
* mean of the series).
|
||||
*/
|
||||
private final double alpha;
|
||||
|
||||
/**
|
||||
* Controls smoothing of trend.
|
||||
* Beta = 1 retains no memory of past values
|
||||
* (e.g. random walk), while alpha = 0 retains infinite memory of past values (e.g.
|
||||
* mean of the series).
|
||||
*/
|
||||
private final double beta;
|
||||
|
||||
/**
|
||||
* Controls smoothing of seasonality.
|
||||
* Gamma = 1 retains no memory of past values
|
||||
* (e.g. random walk), while alpha = 0 retains infinite memory of past values (e.g.
|
||||
* mean of the series).
|
||||
*/
|
||||
private final double gamma;
|
||||
|
||||
/**
|
||||
* Periodicity of the data
|
||||
*/
|
||||
private final int period;
|
||||
|
||||
/**
|
||||
* Whether this is a multiplicative or additive HW
|
||||
*/
|
||||
private final SeasonalityType seasonalityType;
|
||||
|
||||
/**
|
||||
* Padding is used to add a very small amount to values, so that zeroes do not interfere
|
||||
* with multiplicative seasonality math (e.g. division by zero)
|
||||
*/
|
||||
private final boolean pad;
|
||||
private final double padding;
|
||||
|
||||
public HoltWintersModel() {
|
||||
this(DEFAULT_ALPHA, DEFAULT_BETA, DEFAULT_GAMMA, DEFAULT_PERIOD, DEFAULT_SEASONALITY_TYPE, DEFAULT_PAD);
|
||||
}
|
||||
|
@ -178,10 +178,42 @@ public class HoltWintersModel extends MovAvgModel {
|
|||
this.period = period;
|
||||
this.seasonalityType = seasonalityType;
|
||||
this.pad = pad;
|
||||
this.padding = inferPadding();
|
||||
}
|
||||
|
||||
// Only pad if we are multiplicative and padding is enabled
|
||||
// The padding amount is not currently user-configurable...i don't see a reason to expose it?
|
||||
this.padding = seasonalityType.equals(SeasonalityType.MULTIPLICATIVE) && pad ? 0.0000000001 : 0;
|
||||
/**
|
||||
* Read from a stream.
|
||||
*/
|
||||
public HoltWintersModel(StreamInput in) throws IOException {
|
||||
alpha = in.readDouble();
|
||||
beta = in.readDouble();
|
||||
gamma = in.readDouble();
|
||||
period = in.readVInt();
|
||||
seasonalityType = SeasonalityType.readFrom(in);
|
||||
pad = in.readBoolean();
|
||||
this.padding = inferPadding();
|
||||
}
|
||||
|
||||
/**
|
||||
* Only pad if we are multiplicative and padding is enabled. the padding amount is not currently user-configurable.
|
||||
*/
|
||||
private double inferPadding() {
|
||||
return seasonalityType.equals(SeasonalityType.MULTIPLICATIVE) && pad ? 0.0000000001 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeDouble(alpha);
|
||||
out.writeDouble(beta);
|
||||
out.writeDouble(gamma);
|
||||
out.writeVInt(period);
|
||||
seasonalityType.writeTo(out);
|
||||
out.writeBoolean(pad);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWriteableName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -332,18 +364,6 @@ public class HoltWintersModel extends MovAvgModel {
|
|||
return forecastValues;
|
||||
}
|
||||
|
||||
public static final MovAvgModelStreams.Stream STREAM = new MovAvgModelStreams.Stream() {
|
||||
@Override
|
||||
public MovAvgModel readResult(StreamInput in) throws IOException {
|
||||
return PROTOTYPE.readFrom(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME_FIELD.getPreferredName();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.field(MovAvgPipelineAggregatorBuilder.MODEL.getPreferredName(), NAME_FIELD.getPreferredName());
|
||||
|
@ -358,52 +378,7 @@ public class HoltWintersModel extends MovAvgModel {
|
|||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovAvgModel readFrom(StreamInput in) throws IOException {
|
||||
return new HoltWintersModel(in.readDouble(), in.readDouble(), in.readDouble(), in.readVInt(), SeasonalityType.readFrom(in),
|
||||
in.readBoolean());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeString(STREAM.getName());
|
||||
out.writeDouble(alpha);
|
||||
out.writeDouble(beta);
|
||||
out.writeDouble(gamma);
|
||||
out.writeVInt(period);
|
||||
seasonalityType.writeTo(out);
|
||||
out.writeBoolean(pad);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(alpha, beta, gamma, period, seasonalityType, pad);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
HoltWintersModel other = (HoltWintersModel) obj;
|
||||
return Objects.equals(alpha, other.alpha)
|
||||
&& Objects.equals(beta, other.beta)
|
||||
&& Objects.equals(gamma, other.gamma)
|
||||
&& Objects.equals(period, other.period)
|
||||
&& Objects.equals(seasonalityType, other.seasonalityType)
|
||||
&& Objects.equals(pad, other.pad);
|
||||
}
|
||||
|
||||
public static class HoltWintersModelParser extends AbstractModelParser {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME_FIELD.getPreferredName();
|
||||
}
|
||||
|
||||
public static final AbstractModelParser PARSER = new AbstractModelParser() {
|
||||
@Override
|
||||
public MovAvgModel parse(@Nullable Map<String, Object> settings, String pipelineName, int windowSize,
|
||||
ParseFieldMatcher parseFieldMatcher) throws ParseException {
|
||||
|
@ -439,6 +414,28 @@ public class HoltWintersModel extends MovAvgModel {
|
|||
checkUnrecognizedParams(settings);
|
||||
return new HoltWintersModel(alpha, beta, gamma, period, seasonalityType, pad);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(alpha, beta, gamma, period, seasonalityType, pad);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
HoltWintersModel other = (HoltWintersModel) obj;
|
||||
return Objects.equals(alpha, other.alpha)
|
||||
&& Objects.equals(beta, other.beta)
|
||||
&& Objects.equals(gamma, other.gamma)
|
||||
&& Objects.equals(period, other.period)
|
||||
&& Objects.equals(seasonalityType, other.seasonalityType)
|
||||
&& Objects.equals(pad, other.pad);
|
||||
}
|
||||
|
||||
public static class HoltWintersModelBuilder implements MovAvgModelBuilder {
|
||||
|
|
|
@ -39,10 +39,27 @@ import java.util.Map;
|
|||
* linearly less important. "Time" is determined by position in collection
|
||||
*/
|
||||
public class LinearModel extends MovAvgModel {
|
||||
public static final String NAME = "linear";
|
||||
public static final ParseField NAME_FIELD = new ParseField("linear");
|
||||
|
||||
private static final LinearModel PROTOTYPE = new LinearModel();
|
||||
protected static final ParseField NAME_FIELD = new ParseField("linear");
|
||||
public LinearModel() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Read from a stream.
|
||||
*/
|
||||
public LinearModel(StreamInput in) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
// No state to write
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWriteableName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeMinimized() {
|
||||
|
@ -83,48 +100,20 @@ public class LinearModel extends MovAvgModel {
|
|||
return avg / totalWeight;
|
||||
}
|
||||
|
||||
public static final MovAvgModelStreams.Stream STREAM = new MovAvgModelStreams.Stream() {
|
||||
@Override
|
||||
public MovAvgModel readResult(StreamInput in) throws IOException {
|
||||
return PROTOTYPE.readFrom(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME_FIELD.getPreferredName();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.field(MovAvgPipelineAggregatorBuilder.MODEL.getPreferredName(), NAME_FIELD.getPreferredName());
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovAvgModel readFrom(StreamInput in) throws IOException {
|
||||
return new LinearModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeString(STREAM.getName());
|
||||
}
|
||||
|
||||
public static class LinearModelParser extends AbstractModelParser {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME_FIELD.getPreferredName();
|
||||
}
|
||||
|
||||
public static final AbstractModelParser PARSER = new AbstractModelParser() {
|
||||
@Override
|
||||
public MovAvgModel parse(@Nullable Map<String, Object> settings, String pipelineName, int windowSize,
|
||||
ParseFieldMatcher parseFieldMatcher) throws ParseException {
|
||||
checkUnrecognizedParams(settings);
|
||||
return new LinearModel();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static class LinearModelBuilder implements MovAvgModelBuilder {
|
||||
@Override
|
||||
|
|
|
@ -21,8 +21,8 @@ package org.elasticsearch.search.aggregations.pipeline.movavg.models;
|
|||
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.ParseFieldMatcher;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteable;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -31,7 +31,7 @@ import java.util.Arrays;
|
|||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class MovAvgModel implements Writeable<MovAvgModel>, ToXContent {
|
||||
public abstract class MovAvgModel implements NamedWriteable<MovAvgModel>, ToXContent {
|
||||
|
||||
/**
|
||||
* Should this model be fit to the data via a cost minimizing algorithm by default?
|
||||
|
@ -137,14 +137,6 @@ public abstract class MovAvgModel implements Writeable<MovAvgModel>, ToXContent
|
|||
* Abstract class which also provides some concrete parsing functionality.
|
||||
*/
|
||||
public abstract static class AbstractModelParser {
|
||||
|
||||
/**
|
||||
* Returns the name of the model
|
||||
*
|
||||
* @return The model's name
|
||||
*/
|
||||
public abstract String getName();
|
||||
|
||||
/**
|
||||
* Parse a settings hash that is specific to this model
|
||||
*
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.search.aggregations.pipeline.movavg.models;
|
||||
|
||||
import org.elasticsearch.common.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Contains a map of all concrete model parsers which can be used to build Models
|
||||
*/
|
||||
public class MovAvgModelParserMapper {
|
||||
|
||||
protected Map<String, MovAvgModel.AbstractModelParser> movAvgParsers;
|
||||
|
||||
public MovAvgModelParserMapper(Set<MovAvgModel.AbstractModelParser> parsers) {
|
||||
Map<String, MovAvgModel.AbstractModelParser> map = new HashMap<>();
|
||||
add(map, new SimpleModel.SimpleModelParser());
|
||||
add(map, new LinearModel.LinearModelParser());
|
||||
add(map, new EwmaModel.SingleExpModelParser());
|
||||
add(map, new HoltLinearModel.DoubleExpModelParser());
|
||||
add(map, new HoltWintersModel.HoltWintersModelParser());
|
||||
for (MovAvgModel.AbstractModelParser parser : parsers) {
|
||||
add(map, parser);
|
||||
}
|
||||
movAvgParsers = Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
||||
public @Nullable
|
||||
MovAvgModel.AbstractModelParser get(String parserName) {
|
||||
return movAvgParsers.get(parserName);
|
||||
}
|
||||
|
||||
public Set<String> getAllNames() {
|
||||
return movAvgParsers.keySet();
|
||||
}
|
||||
|
||||
private void add(Map<String, MovAvgModel.AbstractModelParser> map, MovAvgModel.AbstractModelParser parser) {
|
||||
map.put(parser.getName(), parser);
|
||||
}
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.search.aggregations.pipeline.movavg.models;
|
||||
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A registry for all moving average models. This is needed for reading them from a stream without knowing which
|
||||
* one it is.
|
||||
*/
|
||||
public class MovAvgModelStreams {
|
||||
|
||||
private static Map<String, Stream> STREAMS = Collections.emptyMap();
|
||||
|
||||
static {
|
||||
HashMap<String, Stream> map = new HashMap<>();
|
||||
map.put(SimpleModel.STREAM.getName(), SimpleModel.STREAM);
|
||||
map.put(LinearModel.STREAM.getName(), LinearModel.STREAM);
|
||||
map.put(EwmaModel.STREAM.getName(), EwmaModel.STREAM);
|
||||
map.put(HoltLinearModel.STREAM.getName(), HoltLinearModel.STREAM);
|
||||
map.put(HoltWintersModel.STREAM.getName(), HoltWintersModel.STREAM);
|
||||
STREAMS = Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
||||
public static MovAvgModel read(StreamInput in) throws IOException {
|
||||
return stream(in.readString()).readResult(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* A stream that knows how to read an heuristic from the input.
|
||||
*/
|
||||
public interface Stream {
|
||||
|
||||
MovAvgModel readResult(StreamInput in) throws IOException;
|
||||
|
||||
String getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the given stream and associate it with the given types.
|
||||
*
|
||||
* @param stream The stream to register
|
||||
*/
|
||||
public static synchronized void registerStream(Stream stream) {
|
||||
if (STREAMS.containsKey(stream.getName())) {
|
||||
throw new IllegalArgumentException("Can't register stream with name [" + stream.getName() + "] more than once");
|
||||
}
|
||||
HashMap<String, Stream> map = new HashMap<>();
|
||||
map.putAll(STREAMS);
|
||||
map.put(stream.getName(), stream);
|
||||
STREAMS = Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stream that is registered for the given name
|
||||
*
|
||||
* @param name The given name
|
||||
* @return The associated stream
|
||||
*/
|
||||
private static synchronized Stream stream(String name) {
|
||||
return STREAMS.get(name);
|
||||
}
|
||||
|
||||
}
|
|
@ -37,10 +37,27 @@ import java.util.Map;
|
|||
* Calculate a simple unweighted (arithmetic) moving average
|
||||
*/
|
||||
public class SimpleModel extends MovAvgModel {
|
||||
public static final String NAME = "simple";
|
||||
public static final ParseField NAME_FIELD = new ParseField(NAME);
|
||||
|
||||
private static final SimpleModel PROTOTYPE = new SimpleModel();
|
||||
protected static final ParseField NAME_FIELD = new ParseField("simple");
|
||||
public SimpleModel() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Read from a stream.
|
||||
*/
|
||||
public SimpleModel(StreamInput in) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
// Nothing to write
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWriteableName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeMinimized() {
|
||||
|
@ -76,48 +93,20 @@ public class SimpleModel extends MovAvgModel {
|
|||
return avg / values.size();
|
||||
}
|
||||
|
||||
public static final MovAvgModelStreams.Stream STREAM = new MovAvgModelStreams.Stream() {
|
||||
@Override
|
||||
public MovAvgModel readResult(StreamInput in) throws IOException {
|
||||
return PROTOTYPE.readFrom(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME_FIELD.getPreferredName();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.field(MovAvgPipelineAggregatorBuilder.MODEL.getPreferredName(), NAME_FIELD.getPreferredName());
|
||||
builder.field(MovAvgPipelineAggregatorBuilder.MODEL.getPreferredName(), NAME);
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovAvgModel readFrom(StreamInput in) throws IOException {
|
||||
return new SimpleModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeString(STREAM.getName());
|
||||
}
|
||||
|
||||
public static class SimpleModelParser extends AbstractModelParser {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME_FIELD.getPreferredName();
|
||||
}
|
||||
|
||||
public static final AbstractModelParser PARSER = new AbstractModelParser() {
|
||||
@Override
|
||||
public MovAvgModel parse(@Nullable Map<String, Object> settings, String pipelineName, int windowSize,
|
||||
ParseFieldMatcher parseFieldMatcher) throws ParseException {
|
||||
checkUnrecognizedParams(settings);
|
||||
return new SimpleModel();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static class SimpleModelBuilder implements MovAvgModelBuilder {
|
||||
@Override
|
||||
|
|
|
@ -590,13 +590,12 @@ public class MovAvgUnitTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testNumericValidation() {
|
||||
List<MovAvgModel.AbstractModelParser> parsers = new ArrayList<>(5);
|
||||
List<MovAvgModel.AbstractModelParser> parsers = new ArrayList<>(3);
|
||||
|
||||
// Simple and Linear don't have any settings to test
|
||||
parsers.add(new EwmaModel.SingleExpModelParser());
|
||||
parsers.add(new HoltWintersModel.HoltWintersModelParser());
|
||||
parsers.add(new HoltLinearModel.DoubleExpModelParser());
|
||||
|
||||
parsers.add(EwmaModel.PARSER);
|
||||
parsers.add(HoltWintersModel.PARSER);
|
||||
parsers.add(HoltLinearModel.PARSER);
|
||||
|
||||
Object[] values = {(byte)1, 1, 1L, (short)1, (double)1};
|
||||
Map<String, Object> settings = new HashMap<>(2);
|
||||
|
@ -608,10 +607,9 @@ public class MovAvgUnitTests extends ESTestCase {
|
|||
try {
|
||||
parser.parse(settings, "pipeline", 10, ParseFieldMatcher.STRICT);
|
||||
} catch (ParseException e) {
|
||||
fail(parser.getName() + " parser should not have thrown SearchParseException while parsing [" +
|
||||
fail(parser + " parser should not have thrown SearchParseException while parsing [" +
|
||||
v.getClass().getSimpleName() +"]");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -627,7 +625,7 @@ public class MovAvgUnitTests extends ESTestCase {
|
|||
continue;
|
||||
}
|
||||
|
||||
fail(parser.getName() + " parser should have thrown SearchParseException while parsing [String]");
|
||||
fail(parser + " parser should have thrown SearchParseException while parsing [String]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue