keith-turner edited a comment on issue #1764:
URL: https://github.com/apache/accumulo/issues/1764#issuecomment-723115201
> While I don't think the flatMap will mess with the ordering, it does look
like it will prevent parallelization, without using the collector strategy I
mentioned above.
Good catch @ctubbsii, I was thinking the stream would buffer some between
steps. But there is no good reason the stream should do that. I attempted to
explicitly force buffering of all the futures in the stream below.
```java
String finalFilterText = filterText;
Predicate<String> textFilter = finalFilterText == null ? t -> true : t
-> t.matches(finalFilterText);
Comparator<ActiveCompaction> acComp =
Comparator.comparingLong(ActiveCompaction::getAge).reversed();
// The following stream buffers all futures mid stream before proceeding
to ensure all tservers are submitted to executor
Iterator<String> activeCompactionIterator =
tservers.stream().map(tserver -> CompletableFuture.supplyAsync(() ->
{
try {
return instanceOps.getActiveCompactions(tserver);
} catch (Exception e) {
throw new RuntimeException(e);
}
}, executor)).collect(toList()).stream()
.flatMap(cf -> cf.join().stream().sorted(acComp)).map(ac ->
toDisplay(ac))
.filter(textFilter).iterator();
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]