siddhantsangwan commented on PR #6974:
URL: https://github.com/apache/ozone/pull/6974#issuecomment-2301197191
@whbing thanks for the update and benchmark. I agree, the map introduces a
bit more complexity than necessary. Have you also considered another simple
approach - using a nested loop to check if the index is present?
```
List<Long> uncachePipelines = result.entrySet().stream()
.filter(e -> {
Pipeline pipeline = e.getValue();
// filter empty pipelines
if (pipeline.isEmpty()) {
return true;
}
// filter insufficient EC pipelines which missing any data index
ReplicationConfig repConfig = pipeline.getReplicationConfig();
if (repConfig instanceof ECReplicationConfig) {
int d = ((ECReplicationConfig) repConfig).getData();
// List<Integer> indexes =
pipeline.getReplicaIndexes().values().stream()
// .sorted()
// .distinct()
// .collect(Collectors.toList());
// return !(indexes.size() >= d && indexes.get(d - 1) == d);
for (int i = 1; i <= d; i++) { // another approach
if (!pipeline.getReplicaIndexes().containsValue(i)) {
return true;
}
}
}
return false;
})
.map(Map.Entry::getKey)
.collect(Collectors.toList());
```
The tests you wrote pass with this approach. We expect the number of indexes
for EC to be less than 20, so this should barely take any time and is also
thread-safe. Let me know if you see any problems with this.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]