28 lines
1.7 KiB
Diff
28 lines
1.7 KiB
Diff
# UNDF: UNDF-2026-000000738
|
||
--- a/clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignor.java
|
||
+++ b/clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignor.java
|
||
@@ -975,6 +975,8 @@ Map<String, List<String>> consumer2AllPotentialTopics
|
||
- // values are ArrayList<String> — O(T) .contains() per consumer per partition
|
||
+ // values are HashSet<String> — O(1) .contains() per consumer per partition
|
||
for (Map.Entry<String, Subscription> subscriptionEntry : subscriptions.entrySet()) {
|
||
String consumer = subscriptionEntry.getKey();
|
||
- consumer2AllPotentialTopics.put(consumer, new ArrayList<>(subscriptionEntry.getValue().topics()));
|
||
+ consumer2AllPotentialTopics.put(consumer, new HashSet<>(subscriptionEntry.getValue().topics()));
|
||
}
|
||
|
||
@@ -1052,1 +1052,2 @@
|
||
- } else if (!consumerSubscription.topics().contains(partition.topic())) { /* O(T) */
|
||
+ } else if (!consumerSubscription.topicsSet().contains(partition.topic())) { /* O(1) via HashSet accessor */
|
||
|
||
@@ -1267,1 +1267,2 @@
|
||
- if (consumer2AllPotentialTopics.get(consumer).contains(partition.topic())) { /* O(T) */
|
||
+ if (consumer2AllPotentialTopics.get(consumer).contains(partition.topic())) { /* O(1) now HashSet */
|
||
|
||
@@ -1458,1 +1458,2 @@
|
||
- if (consumer2AllPotentialTopics.get(consumer).contains(partition.topic())) { /* O(T) */
|
||
+ if (consumer2AllPotentialTopics.get(consumer).contains(partition.topic())) { /* O(1) now HashSet */
|
||
|
||
/* Also add topicsSet() accessor to ConsumerPartitionAssignor.Subscription:
|
||
* public Set<String> topicsSet() { return new HashSet<>(topics()); }
|
||
* or change the internal field from List<String> to Set<String>.
|
||
* Reduces O(P×C×T) rebalance pass to O(P×C). */
|