You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/01/31 13:13:08 UTC
[GitHub] [pulsar] mattisonchao commented on a change in pull request #14077: [Issue 14073] Fixes key shared subscription: hash ranges are not fully reported in stats.
mattisonchao commented on a change in pull request #14077:
URL: https://github.com/apache/pulsar/pull/14077#discussion_r795656276
##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/HashRangeExclusiveStickyKeyConsumerSelector.java
##########
@@ -67,20 +68,22 @@ public void removeConsumer(Consumer consumer) {
@Override
public Map<Consumer, List<Range>> getConsumerKeyHashRanges() {
- Map<Consumer, List<Range>> result = new HashMap<>();
- Map.Entry<Integer, Consumer> prev = null;
- for (Map.Entry<Integer, Consumer> entry: rangeMap.entrySet()) {
- if (prev == null) {
- prev = entry;
- } else {
- if (prev.getValue().equals(entry.getValue())) {
- result.computeIfAbsent(entry.getValue(), key -> new ArrayList<>())
- .add(Range.of(prev.getKey(), entry.getKey()));
- }
- prev = null;
- }
- }
- return result;
+ return rangeMap.entrySet().stream()
+ .collect(Collectors.groupingBy(Map.Entry::getValue))
+ .entrySet().stream().map(groupedEntry -> {
+ Consumer consumer = groupedEntry.getKey();
+ List<Integer> consumerHash = groupedEntry.getValue().stream()
+ .map(Map.Entry::getKey)
+ .sorted(Integer::compareTo)
+ .collect(Collectors.toList());
+ List<Range> ranges = Lists.newArrayList();
Review comment:
sure, i will fix it.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org