Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,6 @@ class BeamModulePlugin implements Plugin<Project> {
"UndefinedEquals",
"UnescapedEntity",
"UnnecessaryLambda",
"UnnecessaryMethodReference",
"UnnecessaryParentheses",
"UnrecognisedJavadocTag",
"UnsafeReflectiveConstructionCast",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,38 +328,35 @@ public void testDynamicDefaultFilenamePolicy() throws Exception {
StreamSupport.stream(
elements.stream()
.filter(
Predicates.compose(new StartsWith("a"), new ExtractWriteDestination())
::apply)
Predicates.compose(new StartsWith("a"), new ExtractWriteDestination()))
.collect(Collectors.toList())
.spliterator(),
false)
.map(Functions.toStringFunction()::apply)
.map(Functions.toStringFunction())
.collect(Collectors.toList()),
Comment on lines 328 to 336
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This stream processing logic can be simplified. The intermediate collection to a list, getting a spliterator, and then creating a new stream via StreamSupport.stream is unnecessary and less efficient than chaining the stream operations directly. This simplification can be applied to the logic for bElements and cElements as well.

            elements.stream()
                .filter(
                    Predicates.compose(new StartsWith("a"), new ExtractWriteDestination()))
                .map(Functions.toStringFunction())
                .collect(Collectors.toList()),

String.class);
String[] bElements =
Iterables.toArray(
StreamSupport.stream(
elements.stream()
.filter(
Predicates.compose(new StartsWith("b"), new ExtractWriteDestination())
::apply)
Predicates.compose(new StartsWith("b"), new ExtractWriteDestination()))
.collect(Collectors.toList())
.spliterator(),
false)
.map(Functions.toStringFunction()::apply)
.map(Functions.toStringFunction())
.collect(Collectors.toList()),
String.class);
String[] cElements =
Iterables.toArray(
StreamSupport.stream(
elements.stream()
.filter(
Predicates.compose(new StartsWith("c"), new ExtractWriteDestination())
::apply)
Predicates.compose(new StartsWith("c"), new ExtractWriteDestination()))
.collect(Collectors.toList())
.spliterator(),
false)
.map(Functions.toStringFunction()::apply)
.map(Functions.toStringFunction())
.collect(Collectors.toList()),
String.class);
assertOutputFiles(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ void startBundle() {
}

void processElement(WindowedValue<KV<KeyT, InputT>> elem) throws Exception {
getGroupingTable().put(elem, output::accept);
getGroupingTable().put(elem, output);
}

void finishBundle() throws Exception {
getGroupingTable().flush(output::accept);
getGroupingTable().flush(output);
groupingTable = null;
}
}
Expand Down
Loading