-
Notifications
You must be signed in to change notification settings - Fork 24.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This commit replaces the _estimate_memory_usage API with a new API, the _explain API. The API consolidates information that is useful before creating a data frame analytics job. It includes: - memory estimation - field selection explanation Memory estimation is moved here from what was previously calculated in the _estimate_memory_usage API. Field selection is a new feature that explains to the user whether each available field was selected to be included or not in the analysis. In the case it was not included, it also explains the reason why. Backport of #49455
- Loading branch information
1 parent
69f570e
commit 8eaee7c
Showing
46 changed files
with
2,312 additions
and
851 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...igh-level/src/main/java/org/elasticsearch/client/ml/ExplainDataFrameAnalyticsRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* 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.client.ml; | ||
|
||
import org.elasticsearch.client.Validatable; | ||
import org.elasticsearch.client.ml.dataframe.DataFrameAnalyticsConfig; | ||
import org.elasticsearch.common.Nullable; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Request to explain the following about a data frame analytics job: | ||
* <ul> | ||
* <li>field selection: which fields are included or are not in the analysis</li> | ||
* <li>memory estimation: how much memory the job is estimated to require</li> | ||
* </ul> | ||
*/ | ||
public class ExplainDataFrameAnalyticsRequest implements Validatable { | ||
|
||
private final String id; | ||
private final DataFrameAnalyticsConfig config; | ||
|
||
public ExplainDataFrameAnalyticsRequest(String id) { | ||
this.id = Objects.requireNonNull(id); | ||
this.config = null; | ||
} | ||
|
||
public ExplainDataFrameAnalyticsRequest(DataFrameAnalyticsConfig config) { | ||
this.id = null; | ||
this.config = Objects.requireNonNull(config); | ||
} | ||
|
||
@Nullable | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
@Nullable | ||
public DataFrameAnalyticsConfig getConfig() { | ||
return config; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
ExplainDataFrameAnalyticsRequest other = (ExplainDataFrameAnalyticsRequest) o; | ||
return Objects.equals(id, other.id) && Objects.equals(config, other.config); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id, config); | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
...gh-level/src/main/java/org/elasticsearch/client/ml/ExplainDataFrameAnalyticsResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* 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.client.ml; | ||
|
||
import org.elasticsearch.client.ml.dataframe.explain.FieldSelection; | ||
import org.elasticsearch.client.ml.dataframe.explain.MemoryEstimation; | ||
import org.elasticsearch.common.ParseField; | ||
import org.elasticsearch.common.xcontent.ConstructingObjectParser; | ||
import org.elasticsearch.common.xcontent.ToXContentObject; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
import org.elasticsearch.common.xcontent.XContentParser; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class ExplainDataFrameAnalyticsResponse implements ToXContentObject { | ||
|
||
public static final ParseField TYPE = new ParseField("explain_data_frame_analytics_response"); | ||
|
||
public static final ParseField FIELD_SELECTION = new ParseField("field_selection"); | ||
public static final ParseField MEMORY_ESTIMATION = new ParseField("memory_estimation"); | ||
|
||
public static ExplainDataFrameAnalyticsResponse fromXContent(XContentParser parser) throws IOException { | ||
return PARSER.parse(parser, null); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
static final ConstructingObjectParser<ExplainDataFrameAnalyticsResponse, Void> PARSER = | ||
new ConstructingObjectParser<>( | ||
TYPE.getPreferredName(), true, | ||
args -> new ExplainDataFrameAnalyticsResponse((List<FieldSelection>) args[0], (MemoryEstimation) args[1])); | ||
|
||
static { | ||
PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), FieldSelection.PARSER, FIELD_SELECTION); | ||
PARSER.declareObject(ConstructingObjectParser.constructorArg(), MemoryEstimation.PARSER, MEMORY_ESTIMATION); | ||
} | ||
|
||
private final List<FieldSelection> fieldSelection; | ||
private final MemoryEstimation memoryEstimation; | ||
|
||
public ExplainDataFrameAnalyticsResponse(List<FieldSelection> fieldSelection, MemoryEstimation memoryEstimation) { | ||
this.fieldSelection = Objects.requireNonNull(fieldSelection); | ||
this.memoryEstimation = Objects.requireNonNull(memoryEstimation); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
builder.field(FIELD_SELECTION.getPreferredName(), fieldSelection); | ||
builder.field(MEMORY_ESTIMATION.getPreferredName(), memoryEstimation); | ||
builder.endObject(); | ||
return builder; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (this == other) return true; | ||
if (other == null || getClass() != other.getClass()) return false; | ||
|
||
ExplainDataFrameAnalyticsResponse that = (ExplainDataFrameAnalyticsResponse) other; | ||
return Objects.equals(fieldSelection, that.fieldSelection) | ||
&& Objects.equals(memoryEstimation, that.memoryEstimation); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(fieldSelection, memoryEstimation); | ||
} | ||
|
||
public MemoryEstimation getMemoryEstimation() { | ||
return memoryEstimation; | ||
} | ||
|
||
public List<FieldSelection> getFieldSelection() { | ||
return fieldSelection; | ||
} | ||
} |
Oops, something went wrong.