Skip to content

Commit

Permalink
INGEST: Clean up Java8 Stream Usage (#32059) (#32485)
Browse files Browse the repository at this point in the history
* GrokProcessor: Rationalize the loop over the map to save allocations and indirection
* IngestDocument: Rationalize way we append to `List`
  • Loading branch information
original-brownbear authored Jul 31, 2018
1 parent adeec7e commit 7551fbc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public void execute(IngestDocument ingestDocument) throws Exception {
throw new IllegalArgumentException("Provided Grok expressions do not match field value: [" + fieldValue + "]");
}

matches.entrySet().stream()
.forEach((e) -> ingestDocument.setFieldValue(e.getKey(), e.getValue()));
matches.forEach(ingestDocument::setFieldValue);

if (traceMatch) {
if (matchPatterns.size() > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,7 @@ private static List<Object> appendValues(Object maybeList, Object value) {

private static void appendValues(List<Object> list, Object value) {
if (value instanceof List) {
List<?> valueList = (List<?>) value;
valueList.stream().forEach(list::add);
list.addAll((List<?>) value);
} else {
list.add(value);
}
Expand Down

0 comments on commit 7551fbc

Please sign in to comment.