-
Notifications
You must be signed in to change notification settings - Fork 173
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
Add select_entries processor #4147
Conversation
Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
super(pluginMetrics); | ||
this.entries = Arrays.asList(config.getIncludeKeys()); | ||
this.selectWhen = config.getSelectWhen(); | ||
this.expressionEvaluator = expressionEvaluator; |
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.
Please validate the selectWhen
in this block.
See for example:
Lines 48 to 53 in 3e3f302
if (decompressProcessorConfig.getDecompressWhen() != null | |
&& !expressionEvaluator.isValidExpressionStatement(decompressProcessorConfig.getDecompressWhen())) { | |
throw new InvalidPluginConfigurationException( | |
String.format("decompress_when value of %s is not a valid expression statement. " + | |
"See https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/ for valid expression syntax.", decompressProcessorConfig.getDecompressWhen())); | |
} |
// Delete all entries from the event | ||
Set keysToDelete = recordEvent.toMap().keySet(); | ||
Iterator iter = keysToDelete.iterator(); | ||
while (iter.hasNext()) { |
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.
It might make more sense to have a clear()
method. We could add that.
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.
I thought about. OK, will add taht to JacksonEvent.
But is this is the optimal way or just creating a new event with the entries of interest is better>
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.
I'm not sure which way is optimal from a performance perspective. But, in terms of tracking all the metadata and keeping the handles, wouldn't clearing and setting be more straightforward?
@NotEmpty | ||
@NotNull | ||
@JsonProperty("include_keys") | ||
private String[] includeKeys; |
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.
Why does this need to be String[]? Why not just make it a List
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.
I just copied from DeleteEntries processor code :-) I guess I can make it a list.
@DataPrepperPluginConstructor | ||
public SelectEntriesProcessor(final PluginMetrics pluginMetrics, final SelectEntriesProcessorConfig config, final ExpressionEvaluator expressionEvaluator) { | ||
super(pluginMetrics); | ||
this.entries = Arrays.asList(config.getIncludeKeys()); |
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.
If include_keys is a List this is unnecessary
// To handle nested case, just get the values and store | ||
// in a temporary map. | ||
Map<String, Object> outMap = new HashMap<>(); | ||
for (String entry: entries) { |
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.
Can we rename this for (String keyToInclude : config.getInlcudeKeys())
Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
Description
Added
select_entries
processor to select a few entries from input events.Configuration
If the input event is as follows
Then the output event would be
Issues Resolved
Resolves #[Issue number to be closed when this PR is merged]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.