-
Notifications
You must be signed in to change notification settings - Fork 24.7k
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
[ML][Data Frame] adds new pipeline field to dest config #43124
Merged
benwtrent
merged 8 commits into
elastic:master
from
benwtrent:feature/ml-df-add-pipeline-support
Jun 19, 2019
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f9fe735
[ML][Data Frame] adds new pipeline field to dest config
benwtrent bdb7231
Merge remote-tracking branch 'upstream/master' into feature/ml-df-add…
benwtrent 7dccdca
Adding pipeline support to _preview
benwtrent 8c1d974
removing unused import
benwtrent 104d796
moving towards extracting _source from pipeline simulation
benwtrent 1a6850d
Merge branch 'master' into feature/ml-df-add-pipeline-support
benwtrent 97d1283
fixing permission requirement, adding _index entry to doc
benwtrent 0614fe0
Merge branch 'master' into feature/ml-df-add-pipeline-support
benwtrent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
package org.elasticsearch.xpack.core.dataframe.transforms; | ||
|
||
import org.elasticsearch.Version; | ||
import org.elasticsearch.common.ParseField; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
|
@@ -20,49 +21,69 @@ | |
import java.util.Objects; | ||
|
||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg; | ||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optionalConstructorArg; | ||
|
||
public class DestConfig implements Writeable, ToXContentObject { | ||
|
||
public static final ParseField INDEX = new ParseField("index"); | ||
public static final ParseField PIPELINE = new ParseField("pipeline"); | ||
|
||
public static final ConstructingObjectParser<DestConfig, Void> STRICT_PARSER = createParser(false); | ||
public static final ConstructingObjectParser<DestConfig, Void> LENIENT_PARSER = createParser(true); | ||
|
||
private static ConstructingObjectParser<DestConfig, Void> createParser(boolean lenient) { | ||
ConstructingObjectParser<DestConfig, Void> parser = new ConstructingObjectParser<>("data_frame_config_dest", | ||
lenient, | ||
args -> new DestConfig((String)args[0])); | ||
args -> new DestConfig((String)args[0], (String) args[1])); | ||
parser.declareString(constructorArg(), INDEX); | ||
parser.declareString(optionalConstructorArg(), PIPELINE); | ||
return parser; | ||
} | ||
|
||
private final String index; | ||
private final String pipeline; | ||
|
||
public DestConfig(String index) { | ||
public DestConfig(String index, String pipeline) { | ||
this.index = ExceptionsHelper.requireNonNull(index, INDEX.getPreferredName()); | ||
this.pipeline = pipeline; | ||
} | ||
|
||
public DestConfig(final StreamInput in) throws IOException { | ||
index = in.readString(); | ||
if (in.getVersion().onOrAfter(Version.CURRENT)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be adjusted after backport |
||
pipeline = in.readOptionalString(); | ||
} else { | ||
pipeline = null; | ||
} | ||
} | ||
|
||
public String getIndex() { | ||
return index; | ||
} | ||
|
||
public String getPipeline() { | ||
return pipeline; | ||
} | ||
|
||
public boolean isValid() { | ||
return index.isEmpty() == false; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(index); | ||
if (out.getVersion().onOrAfter(Version.CURRENT)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be adjusted after backport |
||
out.writeOptionalString(pipeline); | ||
} | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
builder.field(INDEX.getPreferredName(), index); | ||
if (pipeline != null) { | ||
builder.field(PIPELINE.getPreferredName(), pipeline); | ||
} | ||
builder.endObject(); | ||
return builder; | ||
} | ||
|
@@ -77,12 +98,13 @@ public boolean equals(Object other) { | |
} | ||
|
||
DestConfig that = (DestConfig) other; | ||
return Objects.equals(index, that.index); | ||
return Objects.equals(index, that.index) && | ||
Objects.equals(pipeline, that.pipeline); | ||
} | ||
|
||
@Override | ||
public int hashCode(){ | ||
return Objects.hash(index); | ||
return Objects.hash(index, pipeline); | ||
} | ||
|
||
public static DestConfig fromXContent(final XContentParser parser, boolean lenient) throws IOException { | ||
|
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
Objects.requireNonNull(index)
here so the error that the constructor will throw is traced to the root cause.