This commit is contained in:
Clint Wylie 2024-10-22 00:39:24 -07:00
parent be01fe0346
commit 6d10f29892

View File

@ -25,6 +25,7 @@ import org.apache.druid.collections.bitmap.BitmapFactory;
import org.apache.druid.collections.bitmap.MutableBitmap;
import org.apache.druid.common.config.NullHandling;
import org.apache.druid.data.input.impl.DimensionSchema.MultiValueHandling;
import org.apache.druid.error.DruidException;
import org.apache.druid.java.util.common.ISE;
import org.apache.druid.java.util.common.StringUtils;
import org.apache.druid.java.util.common.guava.Comparators;
@ -294,6 +295,7 @@ public class StringDimensionIndexer extends DictionaryEncodedColumnIndexer<int[]
{
final Object[] dims = currEntry.get().getDims();
@Nullable
int[] indices;
if (dimIndex < dims.length) {
indices = (int[]) dims[dimIndex];
@ -308,26 +310,19 @@ public class StringDimensionIndexer extends DictionaryEncodedColumnIndexer<int[]
if (indices == null || indices.length == 0) {
if (hasMultipleValues) {
row = IntArrays.EMPTY_ARRAY;
rowSize = 0;
} else {
final int nullId = getEncodedValue(null, false);
if (nullId >= 0 && nullId < maxId) {
// null was added to the dictionary before this selector was created; return its ID.
DruidException.conditionalDefensive(
nullId >= 0 && nullId < maxId,
"Null value not present in dictionary, how did this happen?"
);
if (nullIdIntArray == null) {
nullIdIntArray = new int[]{nullId};
}
row = nullIdIntArray;
rowSize = 1;
}
} else {
// null doesn't exist in the dictionary; return an empty array.
// Choose to use ArrayBasedIndexedInts later, instead of special "empty" IndexedInts, for monomorphism
row = IntArrays.EMPTY_ARRAY;
rowSize = 0;
}
}
}
if (row == null && indices != null && indices.length > 0) {
row = indices;
rowSize = indices.length;
}
@ -337,9 +332,12 @@ public class StringDimensionIndexer extends DictionaryEncodedColumnIndexer<int[]
}
@Override
public ValueMatcher makeValueMatcher(final String value)
public ValueMatcher makeValueMatcher(@Nullable final String value)
{
if (extractionFn == null) {
if (extractionFn != null) {
// Employ caching BitSet optimization
return makeValueMatcher(StringPredicateDruidPredicateFactory.equalTo(value));
}
final int valueId = lookupId(value);
final int nullValueId = lookupId(null);
if (valueId >= 0 || value == null) {
@ -403,10 +401,6 @@ public class StringDimensionIndexer extends DictionaryEncodedColumnIndexer<int[]
}
};
}
} else {
// Employ caching BitSet optimization
return makeValueMatcher(StringPredicateDruidPredicateFactory.equalTo(value));
}
}
@Override
@ -488,7 +482,7 @@ public class StringDimensionIndexer extends DictionaryEncodedColumnIndexer<int[]
}
@Override
public int lookupId(String name)
public int lookupId(@Nullable String name)
{
if (extractionFn != null) {
throw new UnsupportedOperationException(