This is an automated email from the ASF dual-hosted git repository.
abhishekrb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new e12a63ae620 Speed up CustomTierSelectorStrategy compartor. (#19052)
e12a63ae620 is described below
commit e12a63ae620a75d8e0fd079e1ccd702f02328f91
Author: Abhishek Radhakrishnan <[email protected]>
AuthorDate: Thu Feb 26 08:48:13 2026 -0800
Speed up CustomTierSelectorStrategy compartor. (#19052)
Remove redundant map lookups in CustomTierSelectorStrategy comparator
---
.../client/selector/CustomTierSelectorStrategy.java | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git
a/server/src/main/java/org/apache/druid/client/selector/CustomTierSelectorStrategy.java
b/server/src/main/java/org/apache/druid/client/selector/CustomTierSelectorStrategy.java
index d21afaceb6f..68a7ce1d298 100644
---
a/server/src/main/java/org/apache/druid/client/selector/CustomTierSelectorStrategy.java
+++
b/server/src/main/java/org/apache/druid/client/selector/CustomTierSelectorStrategy.java
@@ -48,18 +48,23 @@ public class CustomTierSelectorStrategy extends
AbstractTierSelectorStrategy
}
// Tiers with priorities explicitly specified in the custom priority list
config always have higher priority than
- // those not and those not specified fall back to use highest priority
strategy among themselves
+ // those not and those not specified fall back to use the highest priority
strategy among themselves
this.comparator = (p1, p2) -> {
- if (lookup.containsKey(p1) && lookup.containsKey(p2)) {
- return Integer.compare(lookup.get(p1), lookup.get(p2));
- } else if (lookup.containsKey(p1)) {
+ final Integer rank1 = lookup.get(p1);
+ final Integer rank2 = lookup.get(p2);
+
+ if (rank1 != null && rank2 != null) {
+ return Integer.compare(rank1, rank2);
+ }
+ if (rank1 != null) {
return -1;
- } else if (lookup.containsKey(p2)) {
+ }
+ if (rank2 != null) {
return 1;
- } else {
- // Fall back to use highest priority strategy
- return Integer.compare(p2, p1);
}
+
+ // Fall back to highest priority first
+ return Integer.compare(p2, p1);
};
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]