mirror of
https://github.com/apache/druid.git
synced 2025-02-16 23:15:16 +00:00
fix IndexedStringDruidPredicateIndexes to not needlessly lookup index of values (#16860)
This commit is contained in:
parent
7f67d26dfa
commit
6cd8c6be22
@ -62,9 +62,8 @@ public final class IndexedStringDruidPredicateIndexes<TDictionary extends Indexe
|
|||||||
return () -> new Iterator<ImmutableBitmap>()
|
return () -> new Iterator<ImmutableBitmap>()
|
||||||
{
|
{
|
||||||
final Iterator<String> iterator = dictionary.iterator();
|
final Iterator<String> iterator = dictionary.iterator();
|
||||||
@Nullable
|
|
||||||
String next = null;
|
|
||||||
boolean nextSet = false;
|
boolean nextSet = false;
|
||||||
|
int index = -1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext()
|
public boolean hasNext()
|
||||||
@ -85,23 +84,17 @@ public final class IndexedStringDruidPredicateIndexes<TDictionary extends Indexe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
nextSet = false;
|
nextSet = false;
|
||||||
final int idx = dictionary.indexOf(next);
|
|
||||||
if (idx < 0) {
|
|
||||||
return bitmapFactory.makeEmptyImmutableBitmap();
|
|
||||||
}
|
|
||||||
|
|
||||||
final ImmutableBitmap bitmap = bitmaps.get(idx);
|
final ImmutableBitmap bitmap = bitmaps.get(index);
|
||||||
return bitmap == null ? bitmapFactory.makeEmptyImmutableBitmap() : bitmap;
|
return bitmap == null ? bitmapFactory.makeEmptyImmutableBitmap() : bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findNext()
|
private void findNext()
|
||||||
{
|
{
|
||||||
while (!nextSet && iterator.hasNext()) {
|
while (!nextSet && iterator.hasNext()) {
|
||||||
String nextValue = iterator.next();
|
final String nextValue = iterator.next();
|
||||||
|
index++;
|
||||||
nextSet = stringPredicate.apply(nextValue).matches(includeUnknown);
|
nextSet = stringPredicate.apply(nextValue).matches(includeUnknown);
|
||||||
if (nextSet) {
|
|
||||||
next = nextValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -612,8 +612,7 @@ public class NestedFieldColumnIndexSupplier<TStringDictionary extends Indexed<By
|
|||||||
|
|
||||||
// in the future, this could use an int iterator
|
// in the future, this could use an int iterator
|
||||||
final Iterator<Integer> iterator = localDictionary.iterator();
|
final Iterator<Integer> iterator = localDictionary.iterator();
|
||||||
int next;
|
int index = -1;
|
||||||
int index = 0;
|
|
||||||
boolean nextSet = false;
|
boolean nextSet = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -635,19 +634,16 @@ public class NestedFieldColumnIndexSupplier<TStringDictionary extends Indexed<By
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
nextSet = false;
|
nextSet = false;
|
||||||
return getBitmap(next);
|
return getBitmap(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findNext()
|
private void findNext()
|
||||||
{
|
{
|
||||||
while (!nextSet && iterator.hasNext()) {
|
while (!nextSet && iterator.hasNext()) {
|
||||||
Integer nextValue = iterator.next();
|
Integer nextValue = iterator.next();
|
||||||
|
index++;
|
||||||
nextSet = stringPredicate.apply(StringUtils.fromUtf8Nullable(stringDictionary.get(nextValue)))
|
nextSet = stringPredicate.apply(StringUtils.fromUtf8Nullable(stringDictionary.get(nextValue)))
|
||||||
.matches(includeUnknown);
|
.matches(includeUnknown);
|
||||||
if (nextSet) {
|
|
||||||
next = index;
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -892,8 +888,7 @@ public class NestedFieldColumnIndexSupplier<TStringDictionary extends Indexed<By
|
|||||||
|
|
||||||
// in the future, this could use an int iterator
|
// in the future, this could use an int iterator
|
||||||
final Iterator<Integer> iterator = localDictionary.iterator();
|
final Iterator<Integer> iterator = localDictionary.iterator();
|
||||||
int next;
|
int index = -1;
|
||||||
int index = 0;
|
|
||||||
boolean nextSet = false;
|
boolean nextSet = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -916,22 +911,19 @@ public class NestedFieldColumnIndexSupplier<TStringDictionary extends Indexed<By
|
|||||||
}
|
}
|
||||||
nextSet = false;
|
nextSet = false;
|
||||||
|
|
||||||
return getBitmap(next);
|
return getBitmap(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findNext()
|
private void findNext()
|
||||||
{
|
{
|
||||||
while (!nextSet && iterator.hasNext()) {
|
while (!nextSet && iterator.hasNext()) {
|
||||||
Integer nextValue = iterator.next();
|
final Integer nextValue = iterator.next();
|
||||||
|
index++;
|
||||||
if (nextValue == 0) {
|
if (nextValue == 0) {
|
||||||
nextSet = longPredicate.applyNull().matches(includeUnknown);
|
nextSet = longPredicate.applyNull().matches(includeUnknown);
|
||||||
} else {
|
} else {
|
||||||
nextSet = longPredicate.applyLong(longDictionary.get(nextValue - adjustLongId)).matches(includeUnknown);
|
nextSet = longPredicate.applyLong(longDictionary.get(nextValue - adjustLongId)).matches(includeUnknown);
|
||||||
}
|
}
|
||||||
if (nextSet) {
|
|
||||||
next = index;
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1158,8 +1150,7 @@ public class NestedFieldColumnIndexSupplier<TStringDictionary extends Indexed<By
|
|||||||
|
|
||||||
// in the future, this could use an int iterator
|
// in the future, this could use an int iterator
|
||||||
final Iterator<Integer> iterator = localDictionary.iterator();
|
final Iterator<Integer> iterator = localDictionary.iterator();
|
||||||
int next;
|
int index = -1;
|
||||||
int index = 0;
|
|
||||||
boolean nextSet = false;
|
boolean nextSet = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1181,23 +1172,20 @@ public class NestedFieldColumnIndexSupplier<TStringDictionary extends Indexed<By
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
nextSet = false;
|
nextSet = false;
|
||||||
return getBitmap(next);
|
return getBitmap(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findNext()
|
private void findNext()
|
||||||
{
|
{
|
||||||
while (!nextSet && iterator.hasNext()) {
|
while (!nextSet && iterator.hasNext()) {
|
||||||
Integer nextValue = iterator.next();
|
final Integer nextValue = iterator.next();
|
||||||
|
index++;
|
||||||
if (nextValue == 0) {
|
if (nextValue == 0) {
|
||||||
nextSet = doublePredicate.applyNull().matches(includeUnknown);
|
nextSet = doublePredicate.applyNull().matches(includeUnknown);
|
||||||
} else {
|
} else {
|
||||||
nextSet = doublePredicate.applyDouble(doubleDictionary.get(nextValue - adjustDoubleId))
|
nextSet = doublePredicate.applyDouble(doubleDictionary.get(nextValue - adjustDoubleId))
|
||||||
.matches(includeUnknown);
|
.matches(includeUnknown);
|
||||||
}
|
}
|
||||||
if (nextSet) {
|
|
||||||
next = index;
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1384,8 +1372,7 @@ public class NestedFieldColumnIndexSupplier<TStringDictionary extends Indexed<By
|
|||||||
|
|
||||||
// in the future, this could use an int iterator
|
// in the future, this could use an int iterator
|
||||||
final Iterator<Integer> iterator = localDictionary.iterator();
|
final Iterator<Integer> iterator = localDictionary.iterator();
|
||||||
int next;
|
int index = -1;
|
||||||
int index;
|
|
||||||
boolean nextSet = false;
|
boolean nextSet = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1407,13 +1394,14 @@ public class NestedFieldColumnIndexSupplier<TStringDictionary extends Indexed<By
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
nextSet = false;
|
nextSet = false;
|
||||||
return getBitmap(next);
|
return getBitmap(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findNext()
|
private void findNext()
|
||||||
{
|
{
|
||||||
while (!nextSet && iterator.hasNext()) {
|
while (!nextSet && iterator.hasNext()) {
|
||||||
Integer nextValue = iterator.next();
|
final Integer nextValue = iterator.next();
|
||||||
|
index++;
|
||||||
if (nextValue >= adjustArrayId) {
|
if (nextValue >= adjustArrayId) {
|
||||||
// this shouldn't be possible since arrayIds will only exist if array dictionary is not null
|
// this shouldn't be possible since arrayIds will only exist if array dictionary is not null
|
||||||
// v4 columns however have a null array dictionary
|
// v4 columns however have a null array dictionary
|
||||||
@ -1442,10 +1430,6 @@ public class NestedFieldColumnIndexSupplier<TStringDictionary extends Indexed<By
|
|||||||
nextSet = stringPredicate.apply(StringUtils.fromUtf8Nullable(stringDictionary.get(nextValue)))
|
nextSet = stringPredicate.apply(StringUtils.fromUtf8Nullable(stringDictionary.get(nextValue)))
|
||||||
.matches(includeUnknown);
|
.matches(includeUnknown);
|
||||||
}
|
}
|
||||||
if (nextSet) {
|
|
||||||
next = index;
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -544,8 +544,7 @@ public class ScalarDoubleColumnAndIndexSupplier implements Supplier<NestedCommon
|
|||||||
final Iterator<Double> iterator = doubleDictionarySupplier.get().iterator();
|
final Iterator<Double> iterator = doubleDictionarySupplier.get().iterator();
|
||||||
final DruidDoublePredicate doublePredicate = matcherFactory.makeDoublePredicate();
|
final DruidDoublePredicate doublePredicate = matcherFactory.makeDoublePredicate();
|
||||||
|
|
||||||
int next;
|
int index = -1;
|
||||||
int index = 0;
|
|
||||||
boolean nextSet = false;
|
boolean nextSet = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -567,13 +566,14 @@ public class ScalarDoubleColumnAndIndexSupplier implements Supplier<NestedCommon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
nextSet = false;
|
nextSet = false;
|
||||||
return getBitmap(next);
|
return getBitmap(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findNext()
|
private void findNext()
|
||||||
{
|
{
|
||||||
while (!nextSet && iterator.hasNext()) {
|
while (!nextSet && iterator.hasNext()) {
|
||||||
Double nextValue = iterator.next();
|
Double nextValue = iterator.next();
|
||||||
|
index++;
|
||||||
if (nextValue == null) {
|
if (nextValue == null) {
|
||||||
if (NullHandling.sqlCompatible()) {
|
if (NullHandling.sqlCompatible()) {
|
||||||
nextSet = doublePredicate.applyNull().matches(includeUnknown);
|
nextSet = doublePredicate.applyNull().matches(includeUnknown);
|
||||||
@ -583,10 +583,6 @@ public class ScalarDoubleColumnAndIndexSupplier implements Supplier<NestedCommon
|
|||||||
} else {
|
} else {
|
||||||
nextSet = doublePredicate.applyDouble(nextValue).matches(includeUnknown);
|
nextSet = doublePredicate.applyDouble(nextValue).matches(includeUnknown);
|
||||||
}
|
}
|
||||||
if (nextSet) {
|
|
||||||
next = index;
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -554,8 +554,7 @@ public class ScalarLongColumnAndIndexSupplier implements Supplier<NestedCommonFo
|
|||||||
final Iterator<Long> iterator = dictionary.iterator();
|
final Iterator<Long> iterator = dictionary.iterator();
|
||||||
final DruidLongPredicate longPredicate = matcherFactory.makeLongPredicate();
|
final DruidLongPredicate longPredicate = matcherFactory.makeLongPredicate();
|
||||||
|
|
||||||
int next;
|
int index = -1;
|
||||||
int index = 0;
|
|
||||||
boolean nextSet = false;
|
boolean nextSet = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -578,13 +577,14 @@ public class ScalarLongColumnAndIndexSupplier implements Supplier<NestedCommonFo
|
|||||||
}
|
}
|
||||||
nextSet = false;
|
nextSet = false;
|
||||||
|
|
||||||
return getBitmap(next);
|
return getBitmap(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findNext()
|
private void findNext()
|
||||||
{
|
{
|
||||||
while (!nextSet && iterator.hasNext()) {
|
while (!nextSet && iterator.hasNext()) {
|
||||||
Long nextValue = iterator.next();
|
Long nextValue = iterator.next();
|
||||||
|
index++;
|
||||||
if (nextValue == null) {
|
if (nextValue == null) {
|
||||||
if (NullHandling.sqlCompatible()) {
|
if (NullHandling.sqlCompatible()) {
|
||||||
nextSet = longPredicate.applyNull().matches(includeUnknown);
|
nextSet = longPredicate.applyNull().matches(includeUnknown);
|
||||||
@ -594,10 +594,6 @@ public class ScalarLongColumnAndIndexSupplier implements Supplier<NestedCommonFo
|
|||||||
} else {
|
} else {
|
||||||
nextSet = longPredicate.applyLong(nextValue).matches(includeUnknown);
|
nextSet = longPredicate.applyLong(nextValue).matches(includeUnknown);
|
||||||
}
|
}
|
||||||
if (nextSet) {
|
|
||||||
next = index;
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user