From 6cd8c6be22c40688df7513a7c6c51768a5b24a10 Mon Sep 17 00:00:00 2001 From: Clint Wylie Date: Wed, 7 Aug 2024 23:29:56 -0700 Subject: [PATCH] fix IndexedStringDruidPredicateIndexes to not needlessly lookup index of values (#16860) --- .../IndexedStringDruidPredicateIndexes.java | 15 ++---- .../NestedFieldColumnIndexSupplier.java | 46 ++++++------------- .../ScalarDoubleColumnAndIndexSupplier.java | 10 ++-- .../ScalarLongColumnAndIndexSupplier.java | 10 ++-- 4 files changed, 25 insertions(+), 56 deletions(-) diff --git a/processing/src/main/java/org/apache/druid/segment/index/IndexedStringDruidPredicateIndexes.java b/processing/src/main/java/org/apache/druid/segment/index/IndexedStringDruidPredicateIndexes.java index 8429b8b6a9f..42a8982d7ba 100644 --- a/processing/src/main/java/org/apache/druid/segment/index/IndexedStringDruidPredicateIndexes.java +++ b/processing/src/main/java/org/apache/druid/segment/index/IndexedStringDruidPredicateIndexes.java @@ -62,9 +62,8 @@ public final class IndexedStringDruidPredicateIndexes new Iterator() { final Iterator iterator = dictionary.iterator(); - @Nullable - String next = null; boolean nextSet = false; + int index = -1; @Override public boolean hasNext() @@ -85,23 +84,17 @@ public final class IndexedStringDruidPredicateIndexes iterator = localDictionary.iterator(); - int next; - int index = 0; + int index = -1; boolean nextSet = false; @Override @@ -635,19 +634,16 @@ public class NestedFieldColumnIndexSupplier iterator = localDictionary.iterator(); - int next; - int index = 0; + int index = -1; boolean nextSet = false; @Override @@ -916,22 +911,19 @@ public class NestedFieldColumnIndexSupplier iterator = localDictionary.iterator(); - int next; - int index = 0; + int index = -1; boolean nextSet = false; @Override @@ -1181,23 +1172,20 @@ public class NestedFieldColumnIndexSupplier iterator = localDictionary.iterator(); - int next; - int index; + int index = -1; boolean nextSet = false; @Override @@ -1407,13 +1394,14 @@ public class NestedFieldColumnIndexSupplier= adjustArrayId) { // this shouldn't be possible since arrayIds will only exist if array dictionary is not null // v4 columns however have a null array dictionary @@ -1442,10 +1430,6 @@ public class NestedFieldColumnIndexSupplier iterator = doubleDictionarySupplier.get().iterator(); final DruidDoublePredicate doublePredicate = matcherFactory.makeDoublePredicate(); - int next; - int index = 0; + int index = -1; boolean nextSet = false; @Override @@ -567,13 +566,14 @@ public class ScalarDoubleColumnAndIndexSupplier implements Supplier iterator = dictionary.iterator(); final DruidLongPredicate longPredicate = matcherFactory.makeLongPredicate(); - int next; - int index = 0; + int index = -1; boolean nextSet = false; @Override @@ -578,13 +577,14 @@ public class ScalarLongColumnAndIndexSupplier implements Supplier