Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Add flatten_result_index_mapping field to Config (#1276) (#12… #1291

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/main/java/org/opensearch/ad/model/ADTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@ public static ADTask parse(XContentParser parser, String taskId) throws IOExcept
detector.getRules(),
detector.getCustomResultIndexMinSize(),
detector.getCustomResultIndexMinAge(),
detector.getCustomResultIndexTTL(),
detector.getFlattenResultIndexMapping()
detector.getCustomResultIndexTTL()
);
return new Builder()
.taskId(parsedTaskId)
Expand Down
23 changes: 3 additions & 20 deletions src/main/java/org/opensearch/ad/model/AnomalyDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,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
*/
public AnomalyDetector(
String detectorId,
Expand All @@ -177,8 +176,7 @@ public AnomalyDetector(
List<Rule> rules,
Integer customResultIndexMinSize,
Integer customResultIndexMinAge,
Integer customResultIndexTTL,
Boolean flattenResultIndexMapping
Integer customResultIndexTTL
) {
super(
detectorId,
Expand All @@ -205,8 +203,7 @@ public AnomalyDetector(
historyIntervals,
customResultIndexMinSize,
customResultIndexMinAge,
customResultIndexTTL,
flattenResultIndexMapping
customResultIndexTTL
);

checkAndThrowValidationErrors(ValidationAspect.DETECTOR);
Expand Down Expand Up @@ -283,7 +280,6 @@ public AnomalyDetector(StreamInput input) throws IOException {
this.customResultIndexMinSize = input.readOptionalInt();
this.customResultIndexMinAge = input.readOptionalInt();
this.customResultIndexTTL = input.readOptionalInt();
this.flattenResultIndexMapping = input.readOptionalBoolean();
}

public XContentBuilder toXContent(XContentBuilder builder) throws IOException {
Expand Down Expand Up @@ -349,7 +345,6 @@ public void writeTo(StreamOutput output) throws IOException {
output.writeOptionalInt(customResultIndexMinSize);
output.writeOptionalInt(customResultIndexMinAge);
output.writeOptionalInt(customResultIndexTTL);
output.writeOptionalBoolean(flattenResultIndexMapping);
}

@Override
Expand Down Expand Up @@ -446,7 +441,6 @@ public static AnomalyDetector parse(
Integer customResultIndexMinSize = null;
Integer customResultIndexMinAge = null;
Integer customResultIndexTTL = null;
Boolean flattenResultIndexMapping = null;

ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.currentToken(), parser);
while (parser.nextToken() != XContentParser.Token.END_OBJECT) {
Expand Down Expand Up @@ -581,9 +575,6 @@ public static AnomalyDetector parse(
case RESULT_INDEX_FIELD_TTL:
customResultIndexTTL = onlyParseNumberValue(parser);
break;
case FLATTEN_RESULT_INDEX_MAPPING:
flattenResultIndexMapping = onlyParseBooleanValue(parser);
break;
default:
parser.skipChildren();
break;
Expand Down Expand Up @@ -614,8 +605,7 @@ public static AnomalyDetector parse(
rules,
customResultIndexMinSize,
customResultIndexMinAge,
customResultIndexTTL,
flattenResultIndexMapping
customResultIndexTTL
);
detector.setDetectionDateRange(detectionDateRange);
return detector;
Expand Down Expand Up @@ -702,11 +692,4 @@ 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ protected AnomalyDetector copyConfig(User user, Config config) {
detector.getRules(),
config.getCustomResultIndexMinSize(),
config.getCustomResultIndexMinAge(),
config.getCustomResultIndexTTL(),
config.getFlattenResultIndexMapping()
config.getCustomResultIndexTTL()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,7 @@ public static ForecastTask parse(XContentParser parser, String taskId) throws IO
forecaster.getHistoryIntervals(),
forecaster.getCustomResultIndexMinSize(),
forecaster.getCustomResultIndexMinAge(),
forecaster.getCustomResultIndexTTL(),
forecaster.getFlattenResultIndexMapping()
forecaster.getCustomResultIndexTTL()
);
return new Builder()
.taskId(parsedTaskId)
Expand Down
13 changes: 3 additions & 10 deletions src/main/java/org/opensearch/forecast/model/Forecaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ public Forecaster(
Integer historyIntervals,
Integer customResultIndexMinSize,
Integer customResultIndexMinAge,
Integer customResultIndexTTL,
Boolean flattenResultIndexMapping
Integer customResultIndexTTL
) {
super(
forecasterId,
Expand All @@ -162,8 +161,7 @@ public Forecaster(
historyIntervals,
customResultIndexMinSize,
customResultIndexMinAge,
customResultIndexTTL,
flattenResultIndexMapping
customResultIndexTTL
);

checkAndThrowValidationErrors(ValidationAspect.FORECASTER);
Expand Down Expand Up @@ -305,7 +303,6 @@ public static Forecaster parse(
Integer customResultIndexMinSize = null;
Integer customResultIndexMinAge = null;
Integer customResultIndexTTL = null;
Boolean flattenResultIndexMapping = null;

ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.currentToken(), parser);
while (parser.nextToken() != XContentParser.Token.END_OBJECT) {
Expand Down Expand Up @@ -434,9 +431,6 @@ public static Forecaster parse(
case RESULT_INDEX_FIELD_TTL:
customResultIndexTTL = parser.intValue();
break;
case FLATTEN_RESULT_INDEX_MAPPING:
flattenResultIndexMapping = parser.booleanValue();
break;
default:
parser.skipChildren();
break;
Expand Down Expand Up @@ -467,8 +461,7 @@ public static Forecaster parse(
historyIntervals,
customResultIndexMinSize,
customResultIndexMinAge,
customResultIndexTTL,
flattenResultIndexMapping
customResultIndexTTL
);
return forecaster;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ protected Config copyConfig(User user, Config config) {
config.getHistoryIntervals(),
config.getCustomResultIndexMinSize(),
config.getCustomResultIndexMinAge(),
config.getCustomResultIndexTTL(),
config.getFlattenResultIndexMapping()
config.getCustomResultIndexTTL()
);
}

Expand Down
22 changes: 3 additions & 19 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";

protected String id;
protected Long version;
Expand Down Expand Up @@ -119,7 +118,6 @@ public abstract class Config implements Writeable, ToXContentObject {
protected Integer customResultIndexMinSize;
protected Integer customResultIndexMinAge;
protected Integer customResultIndexTTL;
protected Boolean flattenResultIndexMapping;

public static String INVALID_RESULT_INDEX_NAME_SIZE = "Result index name size must contains less than "
+ MAX_RESULT_INDEX_NAME_SIZE
Expand Down Expand Up @@ -150,8 +148,7 @@ protected Config(
Integer historyIntervals,
Integer customResultIndexMinSize,
Integer customResultIndexMinAge,
Integer customResultIndexTTL,
Boolean flattenResultIndexMapping
Integer customResultIndexTTL
) {
if (Strings.isBlank(name)) {
errorMessage = CommonMessages.EMPTY_NAME;
Expand Down Expand Up @@ -290,7 +287,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;
}

public int suggestHistory() {
Expand Down Expand Up @@ -334,7 +330,6 @@ public Config(StreamInput input) throws IOException {
this.customResultIndexMinSize = input.readOptionalInt();
this.customResultIndexMinAge = input.readOptionalInt();
this.customResultIndexTTL = input.readOptionalInt();
this.flattenResultIndexMapping = input.readOptionalBoolean();
}

/*
Expand Down Expand Up @@ -387,7 +382,6 @@ public void writeTo(StreamOutput output) throws IOException {
output.writeOptionalInt(customResultIndexMinSize);
output.writeOptionalInt(customResultIndexMinAge);
output.writeOptionalInt(customResultIndexTTL);
output.writeOptionalBoolean(flattenResultIndexMapping);
}

public boolean invalidShingleSizeRange(Integer shingleSizeToTest) {
Expand Down Expand Up @@ -444,8 +438,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 @@ -472,8 +465,7 @@ public int hashCode() {
historyIntervals,
customResultIndexMinSize,
customResultIndexMinAge,
customResultIndexTTL,
flattenResultIndexMapping
customResultIndexTTL
);
}

Expand Down Expand Up @@ -522,9 +514,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);
}
return builder;
}

Expand Down Expand Up @@ -733,10 +722,6 @@ public Integer getCustomResultIndexTTL() {
return customResultIndexTTL;
}

public Boolean getFlattenResultIndexMapping() {
return flattenResultIndexMapping;
}

/**
* Identifies redundant feature names.
*
Expand Down Expand Up @@ -789,7 +774,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 @@ -853,8 +853,7 @@ public <Request extends ActionRequest, Response extends ActionResponse> void doE
null,
detector.getCustomResultIndexMinSize(),
detector.getCustomResultIndexMinAge(),
detector.getCustomResultIndexTTL(),
false
detector.getCustomResultIndexTTL()
);
try {
listener.onResponse((Response) TestHelpers.createGetResponse(clone, clone.getId(), CommonName.CONFIG_INDEX));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,7 @@ public ToXContentObject[] getConfig(String detectorId, BasicHeader header, boole
null,
detector.getCustomResultIndexMinSize(),
detector.getCustomResultIndexMinAge(),
detector.getCustomResultIndexTTL(),
detector.getFlattenResultIndexMapping()
detector.getCustomResultIndexTTL()
),
detectorJob,
historicalAdTask,
Expand Down Expand Up @@ -641,8 +640,7 @@ protected AnomalyDetector cloneDetector(AnomalyDetector anomalyDetector, String
null,
anomalyDetector.getCustomResultIndexMinSize(),
anomalyDetector.getCustomResultIndexMinAge(),
anomalyDetector.getCustomResultIndexTTL(),
anomalyDetector.getFlattenResultIndexMapping()
anomalyDetector.getCustomResultIndexTTL()
);
return detector;
}
Expand Down
Loading
Loading