SteNicholas commented on code in PR #3318:
URL: https://github.com/apache/celeborn/pull/3318#discussion_r2135187662
##########
worker/src/main/java/org/apache/celeborn/service/deploy/worker/storage/MapPartitionData.java:
##########
@@ -186,14 +188,20 @@ public synchronized void readBuffers() {
}
try {
- PriorityQueue<MapPartitionDataReader> sortedReaders =
- new PriorityQueue<>(
- readers.values().stream()
- .filter(MapPartitionDataReader::shouldReadData)
- .collect(Collectors.toList()));
- for (MapPartitionDataReader reader : sortedReaders) {
+ // Find all readers that can read data.
+ // We use a fixed-size array instead of Java Stream's collect operation
+ // because the internal array used by Stream.collect() may be copied
multiple times
+ // if it doesn't know the exact size of the final result.
+ canReadReaders.clear();
Review Comment:
```
PriorityQueue<MapPartitionDataReader> sortedReaders = new PriorityQueue<>();
for (MapPartitionDataReader reader : readers.values()) {
if (!reader.shouldReadData()) {
continue;
}
openReader(reader);
sortedReaders.add(reader);
}
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]