Skip to content

Commit

Permalink
Revert "Add flatten_result_index_mapping field to Config (#1317)"
Browse files Browse the repository at this point in the history
This reverts commit cbe1f33.
  • Loading branch information
jackiehanyang committed Oct 22, 2024
1 parent 9d3bb72 commit bb12ebe
Show file tree
Hide file tree
Showing 19 changed files with 2 additions and 144 deletions.
1 change: 0 additions & 1 deletion src/main/java/org/opensearch/ad/model/ADTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ public static ADTask parse(XContentParser parser, String taskId) throws IOExcept
detector.getCustomResultIndexMinSize(),
detector.getCustomResultIndexMinAge(),
detector.getCustomResultIndexTTL(),
detector.getFlattenResultIndexMapping(),
detector.getLastBreakingUIChangeTime()
);
return new Builder()
Expand Down
17 changes: 0 additions & 17 deletions src/main/java/org/opensearch/ad/model/AnomalyDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ public Integer getShingleSize(Integer customShingleSize) {
* @param customResultIndexMinSize custom result index lifecycle management min size condition
* @param customResultIndexMinAge custom result index lifecycle management min age condition
* @param customResultIndexTTL custom result index lifecycle management ttl
* @param flattenResultIndexMapping flag to indicate whether to flatten result index mapping or not
* @param lastBreakingUIChangeTime last update time to configuration that can break UI and we have
* to display updates from the changed time
*/
Expand Down Expand Up @@ -182,7 +181,6 @@ public AnomalyDetector(
Integer customResultIndexMinSize,
Integer customResultIndexMinAge,
Integer customResultIndexTTL,
Boolean flattenResultIndexMapping,
Instant lastBreakingUIChangeTime
) {
super(
Expand Down Expand Up @@ -211,7 +209,6 @@ public AnomalyDetector(
customResultIndexMinSize,
customResultIndexMinAge,
customResultIndexTTL,
flattenResultIndexMapping,
lastBreakingUIChangeTime
);

Expand Down Expand Up @@ -291,7 +288,6 @@ public AnomalyDetector(StreamInput input) throws IOException {
this.customResultIndexMinSize = input.readOptionalInt();
this.customResultIndexMinAge = input.readOptionalInt();
this.customResultIndexTTL = input.readOptionalInt();
this.flattenResultIndexMapping = input.readOptionalBoolean();
this.lastUIBreakingChangeTime = input.readOptionalInstant();
}

Expand Down Expand Up @@ -358,7 +354,6 @@ public void writeTo(StreamOutput output) throws IOException {
output.writeOptionalInt(customResultIndexMinSize);
output.writeOptionalInt(customResultIndexMinAge);
output.writeOptionalInt(customResultIndexTTL);
output.writeOptionalBoolean(flattenResultIndexMapping);
output.writeOptionalInstant(lastUIBreakingChangeTime);
}

Expand Down Expand Up @@ -456,7 +451,6 @@ public static AnomalyDetector parse(
Integer customResultIndexMinSize = null;
Integer customResultIndexMinAge = null;
Integer customResultIndexTTL = null;
Boolean flattenResultIndexMapping = null;
Instant lastBreakingUIChangeTime = null;

ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.currentToken(), parser);
Expand Down Expand Up @@ -592,9 +586,6 @@ public static AnomalyDetector parse(
case RESULT_INDEX_FIELD_TTL:
customResultIndexTTL = onlyParseNumberValue(parser);
break;
case FLATTEN_RESULT_INDEX_MAPPING:
flattenResultIndexMapping = onlyParseBooleanValue(parser);
break;
case BREAKING_UI_CHANGE_TIME:
lastBreakingUIChangeTime = ParseUtils.toInstant(parser);
break;
Expand Down Expand Up @@ -629,7 +620,6 @@ public static AnomalyDetector parse(
customResultIndexMinSize,
customResultIndexMinAge,
customResultIndexTTL,
flattenResultIndexMapping,
lastBreakingUIChangeTime
);
detector.setDetectionDateRange(detectionDateRange);
Expand Down Expand Up @@ -718,13 +708,6 @@ private static Integer onlyParseNumberValue(XContentParser parser) throws IOExce
return null;
}

private static Boolean onlyParseBooleanValue(XContentParser parser) throws IOException {
if (parser.currentToken() == XContentParser.Token.VALUE_BOOLEAN) {
return parser.booleanValue();
}
return null;
}

/**
* Validates each condition in the list of rules against the list of features.
* Checks that:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ protected AnomalyDetector copyConfig(User user, Config config) {
config.getCustomResultIndexMinSize(),
config.getCustomResultIndexMinAge(),
config.getCustomResultIndexTTL(),
config.getFlattenResultIndexMapping(),
breakingUIChange ? Instant.now() : config.getLastBreakingUIChangeTime()
);
}
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/org/opensearch/forecast/model/ForecastTask.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
/*
<<<<<<< HEAD
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
=======
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
>>>>>>> f22eaa95 (test)
*/

package org.opensearch.forecast.model;
Expand Down Expand Up @@ -343,7 +339,6 @@ public static ForecastTask parse(XContentParser parser, String taskId) throws IO
forecaster.getCustomResultIndexMinSize(),
forecaster.getCustomResultIndexMinAge(),
forecaster.getCustomResultIndexTTL(),
forecaster.getFlattenResultIndexMapping(),
forecaster.getLastBreakingUIChangeTime()
);
return new Builder()
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/org/opensearch/forecast/model/Forecaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ public Forecaster(
Integer customResultIndexMinSize,
Integer customResultIndexMinAge,
Integer customResultIndexTTL,
Boolean flattenResultIndexMapping,
Instant lastBreakingUIChangeTime
) {
super(
Expand Down Expand Up @@ -164,7 +163,6 @@ public Forecaster(
customResultIndexMinSize,
customResultIndexMinAge,
customResultIndexTTL,
flattenResultIndexMapping,
lastBreakingUIChangeTime
);

Expand Down Expand Up @@ -307,7 +305,6 @@ public static Forecaster parse(
Integer customResultIndexMinSize = null;
Integer customResultIndexMinAge = null;
Integer customResultIndexTTL = null;
Boolean flattenResultIndexMapping = null;
Instant lastBreakingUIChangeTime = null;

ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.currentToken(), parser);
Expand Down Expand Up @@ -437,9 +434,6 @@ public static Forecaster parse(
case RESULT_INDEX_FIELD_TTL:
customResultIndexTTL = parser.intValue();
break;
case FLATTEN_RESULT_INDEX_MAPPING:
flattenResultIndexMapping = parser.booleanValue();
break;
case BREAKING_UI_CHANGE_TIME:
lastBreakingUIChangeTime = ParseUtils.toInstant(parser);
break;
Expand Down Expand Up @@ -474,7 +468,6 @@ public static Forecaster parse(
customResultIndexMinSize,
customResultIndexMinAge,
customResultIndexTTL,
flattenResultIndexMapping,
lastBreakingUIChangeTime
);
return forecaster;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ protected Config copyConfig(User user, Config config) {
config.getCustomResultIndexMinSize(),
config.getCustomResultIndexMinAge(),
config.getCustomResultIndexTTL(),
config.getFlattenResultIndexMapping(),
breakingUIChange ? Instant.now() : config.getLastBreakingUIChangeTime()
);
}
Expand Down
20 changes: 2 additions & 18 deletions src/main/java/org/opensearch/timeseries/model/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public abstract class Config implements Writeable, ToXContentObject {
public static final String RESULT_INDEX_FIELD_MIN_SIZE = "result_index_min_size";
public static final String RESULT_INDEX_FIELD_MIN_AGE = "result_index_min_age";
public static final String RESULT_INDEX_FIELD_TTL = "result_index_ttl";
public static final String FLATTEN_RESULT_INDEX_MAPPING = "flatten_result_index_mapping";
// Changing categorical field, feature attributes, interval, windowDelay, time field, horizon, indices,
// result index would force us to display results only from the most recent update. Otherwise,
// the UI appear cluttered and unclear.
Expand Down Expand Up @@ -124,7 +123,6 @@ public abstract class Config implements Writeable, ToXContentObject {
protected Integer customResultIndexMinSize;
protected Integer customResultIndexMinAge;
protected Integer customResultIndexTTL;
protected Boolean flattenResultIndexMapping;
protected Instant lastUIBreakingChangeTime;

public static String INVALID_RESULT_INDEX_NAME_SIZE = "Result index name size must contains less than "
Expand Down Expand Up @@ -157,7 +155,6 @@ protected Config(
Integer customResultIndexMinSize,
Integer customResultIndexMinAge,
Integer customResultIndexTTL,
Boolean flattenResultIndexMapping,
Instant lastBreakingUIChangeTime
) {
if (Strings.isBlank(name)) {
Expand Down Expand Up @@ -297,7 +294,6 @@ protected Config(
this.customResultIndexMinSize = Strings.trimToNull(resultIndex) == null ? null : customResultIndexMinSize;
this.customResultIndexMinAge = Strings.trimToNull(resultIndex) == null ? null : customResultIndexMinAge;
this.customResultIndexTTL = Strings.trimToNull(resultIndex) == null ? null : customResultIndexTTL;
this.flattenResultIndexMapping = Strings.trimToNull(resultIndex) == null ? null : flattenResultIndexMapping;
this.lastUIBreakingChangeTime = lastBreakingUIChangeTime;
}

Expand Down Expand Up @@ -342,7 +338,6 @@ public Config(StreamInput input) throws IOException {
this.customResultIndexMinSize = input.readOptionalInt();
this.customResultIndexMinAge = input.readOptionalInt();
this.customResultIndexTTL = input.readOptionalInt();
this.flattenResultIndexMapping = input.readOptionalBoolean();
this.lastUIBreakingChangeTime = input.readOptionalInstant();
}

Expand Down Expand Up @@ -396,7 +391,6 @@ public void writeTo(StreamOutput output) throws IOException {
output.writeOptionalInt(customResultIndexMinSize);
output.writeOptionalInt(customResultIndexMinAge);
output.writeOptionalInt(customResultIndexTTL);
output.writeOptionalBoolean(flattenResultIndexMapping);
output.writeOptionalInstant(lastUIBreakingChangeTime);
}

Expand Down Expand Up @@ -454,8 +448,7 @@ public boolean equals(Object o) {
&& Objects.equal(historyIntervals, config.historyIntervals)
&& Objects.equal(customResultIndexMinSize, config.customResultIndexMinSize)
&& Objects.equal(customResultIndexMinAge, config.customResultIndexMinAge)
&& Objects.equal(customResultIndexTTL, config.customResultIndexTTL)
&& Objects.equal(flattenResultIndexMapping, config.flattenResultIndexMapping);
&& Objects.equal(customResultIndexTTL, config.customResultIndexTTL);
}

@Generated
Expand All @@ -482,8 +475,7 @@ public int hashCode() {
historyIntervals,
customResultIndexMinSize,
customResultIndexMinAge,
customResultIndexTTL,
flattenResultIndexMapping
customResultIndexTTL
);
}

Expand Down Expand Up @@ -532,9 +524,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
if (customResultIndexTTL != null) {
builder.field(RESULT_INDEX_FIELD_TTL, customResultIndexTTL);
}
if (flattenResultIndexMapping != null) {
builder.field(FLATTEN_RESULT_INDEX_MAPPING, flattenResultIndexMapping);
}
if (lastUIBreakingChangeTime != null) {
builder.field(BREAKING_UI_CHANGE_TIME, lastUIBreakingChangeTime.toEpochMilli());
}
Expand Down Expand Up @@ -746,10 +735,6 @@ public Integer getCustomResultIndexTTL() {
return customResultIndexTTL;
}

public Boolean getFlattenResultIndexMapping() {
return flattenResultIndexMapping;
}

public Instant getLastBreakingUIChangeTime() {
return lastUIBreakingChangeTime;
}
Expand Down Expand Up @@ -806,7 +791,6 @@ public String toString() {
.append("customResultIndexMinSize", customResultIndexMinSize)
.append("customResultIndexMinAge", customResultIndexMinAge)
.append("customResultIndexTTL", customResultIndexTTL)
.append("flattenResultIndexMapping", flattenResultIndexMapping)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,6 @@ public <Request extends ActionRequest, Response extends ActionResponse> void doE
detector.getCustomResultIndexMinSize(),
detector.getCustomResultIndexMinAge(),
detector.getCustomResultIndexTTL(),
detector.getFlattenResultIndexMapping(),
Instant.now()
);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ public ToXContentObject[] getConfig(String detectorId, BasicHeader header, boole
detector.getCustomResultIndexMinSize(),
detector.getCustomResultIndexMinAge(),
detector.getCustomResultIndexTTL(),
detector.getFlattenResultIndexMapping(),
detector.getLastBreakingUIChangeTime()
),
detectorJob,
Expand Down Expand Up @@ -584,7 +583,6 @@ protected AnomalyDetector cloneDetector(AnomalyDetector anomalyDetector, String
anomalyDetector.getCustomResultIndexMinSize(),
anomalyDetector.getCustomResultIndexMinAge(),
anomalyDetector.getCustomResultIndexTTL(),
anomalyDetector.getFlattenResultIndexMapping(),
Instant.now()
);
return detector;
Expand Down
Loading

0 comments on commit bb12ebe

Please sign in to comment.