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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]