You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2022/08/12 16:46:50 UTC
[GitHub] [accumulo] DomGarguilo commented on issue #2856: Remove use of Guava from ScanAttemptsImpl
DomGarguilo commented on issue #2856:
URL: https://github.com/apache/accumulo/issues/2856#issuecomment-1213317340
I came up with two alternatives for replacement logic:
create new map then use for loop to iterate over `attempts` to fill it:
```java
Map<TabletId,Collection<ScanAttemptImpl>> result = new ConcurrentHashMap<>();
for (var entry : attempts.entrySet()) {
TabletId tabletId = entry.getKey();
// filter out ScanAttempt objects that were added after this call
List<ScanAttemptImpl> scanAttemptList = entry.getValue().stream()
.filter(sai -> sai.getMutationCount() < snapMC).collect(Collectors.toList());
// only add an entry to the resulting map if there are ScanAttempt objects for the TabletId
if (!scanAttemptList.isEmpty())
result.put(tabletId, scanAttemptList);
}
return result;
```
using streams to filter and collect:
```java
// @formatter:off
return attempts.entrySet().stream()
.map(entry ->
new AbstractMap.SimpleEntry<>(
entry.getKey(),
// filter out ScanAttempt objects that were added after this call
entry.getValue().stream().filter(sai -> sai.getMutationCount() < snapMC).collect(Collectors.toList())
)
)
// filter out entries if there are no ScanAttempts for the TabletId
.filter(entry -> !entry.getValue().isEmpty())
.collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue));
// @formatter:on
```
Both behave the same. Any preferences?
--
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: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org