github-code-scanning[bot] commented on code in PR #14412:
URL: https://github.com/apache/druid/pull/14412#discussion_r1227493427
##########
processing/src/main/java/org/apache/druid/query/metadata/SegmentAnalyzer.java:
##########
@@ -346,6 +347,12 @@
.withTypeName(typeName);
try (final BaseColumn theColumn = columnHolder != null ?
columnHolder.getColumn() : null) {
+ bob.hasMultipleValues(capabilities.hasMultipleValues().isTrue())
Review Comment:
## Dereferenced variable may be null
Variable [capabilities](1) may be null at this access as suggested by
[this](2) null guard.
[Show more
details](https://github.com/apache/druid/security/code-scanning/4970)
##########
processing/src/main/java/org/apache/druid/segment/nested/ConstantColumnAndIndexSupplier.java:
##########
@@ -0,0 +1,328 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.segment.nested;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import org.apache.druid.collections.bitmap.BitmapFactory;
+import org.apache.druid.collections.bitmap.ImmutableBitmap;
+import org.apache.druid.java.util.common.RE;
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.math.expr.Evals;
+import org.apache.druid.query.filter.DruidDoublePredicate;
+import org.apache.druid.query.filter.DruidFloatPredicate;
+import org.apache.druid.query.filter.DruidLongPredicate;
+import org.apache.druid.query.filter.DruidPredicateFactory;
+import org.apache.druid.segment.IndexMerger;
+import org.apache.druid.segment.column.BitmapColumnIndex;
+import org.apache.druid.segment.column.ColumnIndexSupplier;
+import org.apache.druid.segment.column.ColumnType;
+import org.apache.druid.segment.column.DictionaryEncodedStringValueIndex;
+import org.apache.druid.segment.column.DictionaryEncodedValueIndex;
+import org.apache.druid.segment.column.DruidPredicateIndex;
+import org.apache.druid.segment.column.LexicographicalRangeIndex;
+import org.apache.druid.segment.column.NullValueIndex;
+import org.apache.druid.segment.column.NullableTypeStrategy;
+import org.apache.druid.segment.column.NumericRangeIndex;
+import org.apache.druid.segment.column.SimpleImmutableBitmapIndex;
+import org.apache.druid.segment.column.StringValueSetIndex;
+import org.apache.druid.segment.column.ValueType;
+import org.apache.druid.segment.data.BitmapSerdeFactory;
+import org.apache.druid.segment.data.VByte;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Objects;
+import java.util.SortedSet;
+
+public class ConstantColumnAndIndexSupplier implements
Supplier<NestedCommonFormatColumn>, ColumnIndexSupplier
+{
+ public static ConstantColumnAndIndexSupplier read(
+ ColumnType logicalType,
+ BitmapSerdeFactory bitmapSerdeFactory,
+ ByteBuffer bb
+ )
+ {
+ final byte version = bb.get();
+ final int columnNameLength = VByte.readInt(bb);
+ final String columnName = StringUtils.fromUtf8(bb, columnNameLength);
+
+ if (version == NestedCommonFormatColumnSerializer.V0) {
+ try {
+ final int rowCount = VByte.readInt(bb);
+ final int valueLength = VByte.readInt(bb);
+ final Object constantValue =
NestedDataComplexTypeSerde.OBJECT_MAPPER.readValue(
+ IndexMerger.SERIALIZER_UTILS.readBytes(bb, valueLength),
+ Object.class
+ );
+ return new ConstantColumnAndIndexSupplier(logicalType,
bitmapSerdeFactory, rowCount, constantValue);
+ }
+ catch (IOException ex) {
+ throw new RE(ex, "Failed to deserialize V%s column [%s].", version,
columnName);
+ }
+ } else {
+ throw new RE("Unknown version " + version);
+ }
+ }
+
+ private final ColumnType logicalType;
+ private final BitmapSerdeFactory bitmapSerdeFactory;
+ @Nullable
+ private final Object constantValue;
+
+ private final ImmutableBitmap matchBitmap;
+ private final SimpleImmutableBitmapIndex match;
+ private final ImmutableBitmap noMatchBitmap;
+ private final SimpleImmutableBitmapIndex noMatch;
+
+ public ConstantColumnAndIndexSupplier(
+ ColumnType logicalType,
+ BitmapSerdeFactory bitmapSerdeFactory,
+ int numRows,
+ @Nullable Object constantValue
+ )
+ {
+ this.logicalType = logicalType;
+ this.bitmapSerdeFactory = bitmapSerdeFactory;
+ this.constantValue = constantValue;
+ this.matchBitmap = bitmapSerdeFactory.getBitmapFactory().complement(
+ bitmapSerdeFactory.getBitmapFactory().makeEmptyImmutableBitmap(),
+ numRows
+ );
+ this.match = new SimpleImmutableBitmapIndex(matchBitmap);
+ this.noMatchBitmap =
bitmapSerdeFactory.getBitmapFactory().makeEmptyImmutableBitmap();
+ this.noMatch = new SimpleImmutableBitmapIndex(noMatchBitmap);
+ }
+
+ @Override
+ public NestedCommonFormatColumn get()
+ {
+ return new ConstantColumn(logicalType, constantValue);
+ }
+
+ @Nullable
+ @Override
+ public <T> T as(Class<T> clazz)
+ {
+ if (clazz.equals(NullValueIndex.class)) {
+ final BitmapColumnIndex nullIndex;
+ if (constantValue == null) {
+ nullIndex = match;
+ } else {
+ nullIndex = noMatch;
+ }
+ return (T) (NullValueIndex) () -> nullIndex;
+ } else if (logicalType.isPrimitive() &&
(clazz.equals(DictionaryEncodedStringValueIndex.class)
+ || clazz.equals(DictionaryEncodedValueIndex.class))) {
+ return (T) new ConstantDictionaryEncodedStringValueIndex();
+ } else if (logicalType.isPrimitive() &&
clazz.equals(StringValueSetIndex.class)) {
+ return (T) new ConstantStringValueSetIndex();
+ } else if (logicalType.is(ValueType.STRING) &&
clazz.equals(LexicographicalRangeIndex.class)) {
+ return (T) new ConstantLexicographicalRangeIndex();
+ } else if (logicalType.isNumeric() &&
clazz.equals(NumericRangeIndex.class)) {
+ return (T) new ConstantNumericRangeIndex();
+ } else if (logicalType.isPrimitive() &&
clazz.equals(DruidPredicateIndex.class)) {
+ return (T) new ConstantDruidPredicateIndex();
+ }
+ return null;
+ }
+
+ class ConstantStringValueSetIndex implements StringValueSetIndex
+ {
+ private final String theString = Evals.asString(constantValue);
+
+ @Override
+ public BitmapColumnIndex forValue(@Nullable String value)
+ {
+ if (Objects.equals(value, theString)) {
+ return match;
+ }
+ return noMatch;
+ }
+
+ @Override
+ public BitmapColumnIndex forSortedValues(SortedSet<String> values)
+ {
+ if (values.contains(theString)) {
+ return match;
+ }
+ return noMatch;
+ }
+ }
+
+ class ConstantLexicographicalRangeIndex implements LexicographicalRangeIndex
+ {
+ private final String theString = Evals.asString(constantValue);
+ private final NullableTypeStrategy<String> strategy =
logicalType.getNullableStrategy();
+
+ @Nullable
+ @Override
+ public BitmapColumnIndex forRange(
+ @Nullable String startValue,
+ boolean startStrict,
+ @Nullable String endValue,
+ boolean endStrict
+ )
+ {
+ if (inRange(startValue, startStrict, endValue, endStrict)) {
+ return match;
+ }
+ return noMatch;
+ }
+
+ @Nullable
+ @Override
+ public BitmapColumnIndex forRange(
+ @Nullable String startValue,
+ boolean startStrict,
+ @Nullable String endValue,
+ boolean endStrict,
+ Predicate<String> matcher
+ )
+ {
+ if (inRange(startValue, startStrict, endValue, endStrict) &&
matcher.apply(theString)) {
+ return match;
+ }
+ return noMatch;
+ }
+
+ private boolean inRange(
+ @Nullable String startValue,
+ boolean startStrict,
+ @Nullable String endValue,
+ boolean endStrict
+ )
+ {
+ final int startCompare = strategy.compare(startValue, theString);
+ final int endCompare = endValue == null ? -1 :
strategy.compare(theString, endValue);
+ final boolean startSatisfied = startStrict ? startCompare > 0 :
startCompare >= 0;
+ final boolean endSatisified = endStrict ? endCompare < 0 : endCompare <=
0;
+ return startSatisfied && endSatisified;
+ }
+ }
+
+ class ConstantNumericRangeIndex implements NumericRangeIndex
+ {
+ private final NullableTypeStrategy<Number> strategy =
logicalType.getNullableStrategy();
+
+ @Nullable
+ @Override
+ public BitmapColumnIndex forRange(
+ @Nullable Number startValue,
+ boolean startStrict,
+ @Nullable Number endValue,
+ boolean endStrict
+ )
+ {
+ if (constantValue == null) {
+ return noMatch;
+ }
+ final Number theNumber = (Number) constantValue;
+ final int startCompare = strategy.compare(startValue, theNumber);
+ final int endCompare = endValue == null ? -1 :
strategy.compare(theNumber, endValue);
+ final boolean startSatisfied = startStrict ? startCompare > 0 :
startCompare >= 0;
+ final boolean endSatisified = endStrict ? endCompare < 0 : endCompare <=
0;
+ if (startSatisfied && endSatisified) {
+ return match;
+ }
+ return noMatch;
+ }
+ }
+
+ class ConstantDruidPredicateIndex implements DruidPredicateIndex
+ {
+ @Nullable
+ @Override
+ public BitmapColumnIndex forPredicate(DruidPredicateFactory matcherFactory)
+ {
+ switch (logicalType.getType()) {
+ case STRING:
+ if (matcherFactory.makeStringPredicate().apply((String)
constantValue)) {
+ return match;
+ }
+ return noMatch;
+ case LONG:
+ DruidLongPredicate longPredicate =
matcherFactory.makeLongPredicate();
+ if (constantValue == null && longPredicate.applyNull()) {
+ return match;
+ } else if (longPredicate.applyLong((Long) constantValue)) {
+ return match;
+ }
+ return noMatch;
+ case FLOAT:
+ DruidFloatPredicate floatPredicate =
matcherFactory.makeFloatPredicate();
+ if (constantValue == null && floatPredicate.applyNull()) {
+ return match;
+ } else if (floatPredicate.applyFloat((Float) constantValue)) {
Review Comment:
## Dereferenced variable may be null
Variable [constantValue](1) may be null at this access as suggested by
[this](2) null guard.
Variable [constantValue](1) may be null at this access as suggested by
[this](3) null guard.
Variable [constantValue](1) may be null at this access as suggested by
[this](4) null guard.
[Show more
details](https://github.com/apache/druid/security/code-scanning/5044)
##########
processing/src/test/java/org/apache/druid/segment/serde/NestedCommonFormatColumnPartSerdeTest.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.segment.serde;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.druid.segment.TestHelper;
+import org.apache.druid.segment.column.ColumnType;
+import org.junit.Test;
+
+import java.nio.ByteOrder;
+
+public class NestedCommonFormatColumnPartSerdeTest
+{
+ private static final ObjectMapper OBJECT_MAPPER =
TestHelper.makeJsonMapper();
+
+ @Test
+ public void testSerde()
+ {
+ NestedCommonFormatColumnPartSerde partSerde =
NestedCommonFormatColumnPartSerde.serializerBuilder()
+
.isConstant(false)
+
.isVariantType(false)
+
.withByteOrder(ByteOrder.nativeOrder())
+
.withHasNulls(true)
+
.withLogicalType(ColumnType.LONG)
+
.build();
Review Comment:
## Unread local variable
Variable 'NestedCommonFormatColumnPartSerde partSerde' is never read.
[Show more
details](https://github.com/apache/druid/security/code-scanning/5048)
##########
processing/src/test/java/org/apache/druid/segment/nested/ConstantColumnSupplierTest.java:
##########
@@ -0,0 +1,454 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.segment.nested;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import org.apache.druid.guice.NestedDataModule;
+import org.apache.druid.java.util.common.concurrent.Execs;
+import org.apache.druid.java.util.common.io.Closer;
+import org.apache.druid.java.util.common.io.smoosh.FileSmoosher;
+import org.apache.druid.java.util.common.io.smoosh.SmooshedFileMapper;
+import org.apache.druid.java.util.common.io.smoosh.SmooshedWriter;
+import org.apache.druid.math.expr.ExprEval;
+import org.apache.druid.math.expr.ExpressionType;
+import org.apache.druid.query.DefaultBitmapResultFactory;
+import org.apache.druid.segment.AutoTypeColumnIndexer;
+import org.apache.druid.segment.AutoTypeColumnMerger;
+import org.apache.druid.segment.ColumnValueSelector;
+import org.apache.druid.segment.DimensionSelector;
+import org.apache.druid.segment.IndexSpec;
+import org.apache.druid.segment.IndexableAdapter;
+import org.apache.druid.segment.SimpleAscendingOffset;
+import org.apache.druid.segment.column.ColumnBuilder;
+import org.apache.druid.segment.column.ColumnType;
+import org.apache.druid.segment.column.DruidPredicateIndex;
+import org.apache.druid.segment.column.LexicographicalRangeIndex;
+import org.apache.druid.segment.column.NullValueIndex;
+import org.apache.druid.segment.column.NumericRangeIndex;
+import org.apache.druid.segment.column.StringValueSetIndex;
+import org.apache.druid.segment.data.BitmapSerdeFactory;
+import org.apache.druid.segment.data.RoaringBitmapSerdeFactory;
+import org.apache.druid.segment.vector.NoFilterVectorOffset;
+import org.apache.druid.segment.vector.SingleValueDimensionVectorSelector;
+import org.apache.druid.segment.vector.VectorObjectSelector;
+import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory;
+import org.apache.druid.segment.writeout.TmpFileSegmentWriteOutMediumFactory;
+import org.apache.druid.testing.InitializedNullHandlingTest;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.atomic.AtomicReference;
+
+@RunWith(Parameterized.class)
+public class ConstantColumnSupplierTest extends InitializedNullHandlingTest
+{
+
+ public static List<Object> CONSTANT_NULL = Arrays.asList(
+ null,
+ null,
+ null,
+ null,
+ null
+ );
+
+ public static List<String> CONSTANT_STRING = Arrays.asList(
+ "abcd",
+ "abcd",
+ "abcd",
+ "abcd",
+ "abcd"
+ );
+
+ public static List<Long> CONSTANT_LONG = Arrays.asList(
+ 1234L,
+ 1234L,
+ 1234L,
+ 1234L,
+ 1234L
+ );
+
+ public static List<List<Long>> CONSTANT_LONG_ARRAY = Arrays.asList(
+ Arrays.asList(1L, 2L, 3L, 4L),
+ Arrays.asList(1L, 2L, 3L, 4L),
+ Arrays.asList(1L, 2L, 3L, 4L),
+ Arrays.asList(1L, 2L, 3L, 4L),
+ Arrays.asList(1L, 2L, 3L, 4L)
+ );
+
+ public static List<Object> CONSTANT_EMPTY_OBJECTS = Arrays.asList(
+ Collections.emptyMap(),
+ Collections.emptyMap(),
+ Collections.emptyMap(),
+ Collections.emptyMap(),
+ Collections.emptyMap()
+ );
+
+ public static List<Object> CONSTANT_OBJECTS = Arrays.asList(
+ ImmutableMap.of("x", 1234, "y", 1.234, "z", "abcd"),
+ ImmutableMap.of("x", 1234, "y", 1.234, "z", "abcd"),
+ ImmutableMap.of("x", 1234, "y", 1.234, "z", "abcd"),
+ ImmutableMap.of("x", 1234, "y", 1.234, "z", "abcd"),
+ ImmutableMap.of("x", 1234, "y", 1.234, "z", "abcd")
+ );
+
+ @BeforeClass
+ public static void staticSetup()
+ {
+ NestedDataModule.registerHandlersAndSerde();
+ }
+
+ @Parameterized.Parameters(name = "data = {0}")
+ public static Collection<?> constructorFeeder()
+ {
+ final List<Object[]> constructors = ImmutableList.of(
+ new Object[]{"NULL", CONSTANT_NULL, IndexSpec.DEFAULT},
+ new Object[]{"STRING", CONSTANT_STRING, IndexSpec.DEFAULT},
+ new Object[]{"LONG", CONSTANT_LONG, IndexSpec.DEFAULT},
+ new Object[]{"ARRAY<LONG>", CONSTANT_LONG_ARRAY, IndexSpec.DEFAULT},
+ new Object[]{"EMPTY OBJECT", CONSTANT_EMPTY_OBJECTS,
IndexSpec.DEFAULT},
+ new Object[]{"OBJECT", CONSTANT_OBJECTS, IndexSpec.DEFAULT}
+ );
+
+ return constructors;
+ }
+
+ @Rule
+ public final TemporaryFolder tempFolder = new TemporaryFolder();
+
+ Closer closer = Closer.create();
+
+ SmooshedFileMapper fileMapper;
+
+ ByteBuffer baseBuffer;
+
+ FieldTypeInfo.MutableTypeSet expectedTypes;
+
+ ColumnType expectedLogicalType = null;
+
+ private final List<?> data;
+ private final IndexSpec indexSpec;
+
+ BitmapSerdeFactory bitmapSerdeFactory =
RoaringBitmapSerdeFactory.getInstance();
+ DefaultBitmapResultFactory resultFactory = new
DefaultBitmapResultFactory(bitmapSerdeFactory.getBitmapFactory());
+
+ public ConstantColumnSupplierTest(
+ @SuppressWarnings("unused") String name,
+ List<?> data,
+ IndexSpec indexSpec
+ )
+ {
+ this.data = data;
+ this.indexSpec = indexSpec;
+ }
+
+ @Before
+ public void setup() throws IOException
+ {
+ final String fileNameBase = "test";
+ fileMapper = smooshify(fileNameBase, tempFolder.newFolder());
+ baseBuffer = fileMapper.mapFile(fileNameBase);
+ }
+
+ private SmooshedFileMapper smooshify(
+ String fileNameBase,
+ File tmpFile
+ )
+ throws IOException
+ {
+ SegmentWriteOutMediumFactory writeOutMediumFactory =
TmpFileSegmentWriteOutMediumFactory.instance();
Review Comment:
## Unread local variable
Variable 'SegmentWriteOutMediumFactory writeOutMediumFactory' is never read.
[Show more
details](https://github.com/apache/druid/security/code-scanning/5047)
##########
processing/src/main/java/org/apache/druid/segment/nested/ConstantColumnAndIndexSupplier.java:
##########
@@ -0,0 +1,328 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.segment.nested;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import org.apache.druid.collections.bitmap.BitmapFactory;
+import org.apache.druid.collections.bitmap.ImmutableBitmap;
+import org.apache.druid.java.util.common.RE;
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.math.expr.Evals;
+import org.apache.druid.query.filter.DruidDoublePredicate;
+import org.apache.druid.query.filter.DruidFloatPredicate;
+import org.apache.druid.query.filter.DruidLongPredicate;
+import org.apache.druid.query.filter.DruidPredicateFactory;
+import org.apache.druid.segment.IndexMerger;
+import org.apache.druid.segment.column.BitmapColumnIndex;
+import org.apache.druid.segment.column.ColumnIndexSupplier;
+import org.apache.druid.segment.column.ColumnType;
+import org.apache.druid.segment.column.DictionaryEncodedStringValueIndex;
+import org.apache.druid.segment.column.DictionaryEncodedValueIndex;
+import org.apache.druid.segment.column.DruidPredicateIndex;
+import org.apache.druid.segment.column.LexicographicalRangeIndex;
+import org.apache.druid.segment.column.NullValueIndex;
+import org.apache.druid.segment.column.NullableTypeStrategy;
+import org.apache.druid.segment.column.NumericRangeIndex;
+import org.apache.druid.segment.column.SimpleImmutableBitmapIndex;
+import org.apache.druid.segment.column.StringValueSetIndex;
+import org.apache.druid.segment.column.ValueType;
+import org.apache.druid.segment.data.BitmapSerdeFactory;
+import org.apache.druid.segment.data.VByte;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Objects;
+import java.util.SortedSet;
+
+public class ConstantColumnAndIndexSupplier implements
Supplier<NestedCommonFormatColumn>, ColumnIndexSupplier
+{
+ public static ConstantColumnAndIndexSupplier read(
+ ColumnType logicalType,
+ BitmapSerdeFactory bitmapSerdeFactory,
+ ByteBuffer bb
+ )
+ {
+ final byte version = bb.get();
+ final int columnNameLength = VByte.readInt(bb);
+ final String columnName = StringUtils.fromUtf8(bb, columnNameLength);
+
+ if (version == NestedCommonFormatColumnSerializer.V0) {
+ try {
+ final int rowCount = VByte.readInt(bb);
+ final int valueLength = VByte.readInt(bb);
+ final Object constantValue =
NestedDataComplexTypeSerde.OBJECT_MAPPER.readValue(
+ IndexMerger.SERIALIZER_UTILS.readBytes(bb, valueLength),
+ Object.class
+ );
+ return new ConstantColumnAndIndexSupplier(logicalType,
bitmapSerdeFactory, rowCount, constantValue);
+ }
+ catch (IOException ex) {
+ throw new RE(ex, "Failed to deserialize V%s column [%s].", version,
columnName);
+ }
+ } else {
+ throw new RE("Unknown version " + version);
+ }
+ }
+
+ private final ColumnType logicalType;
+ private final BitmapSerdeFactory bitmapSerdeFactory;
+ @Nullable
+ private final Object constantValue;
+
+ private final ImmutableBitmap matchBitmap;
+ private final SimpleImmutableBitmapIndex match;
+ private final ImmutableBitmap noMatchBitmap;
+ private final SimpleImmutableBitmapIndex noMatch;
+
+ public ConstantColumnAndIndexSupplier(
+ ColumnType logicalType,
+ BitmapSerdeFactory bitmapSerdeFactory,
+ int numRows,
+ @Nullable Object constantValue
+ )
+ {
+ this.logicalType = logicalType;
+ this.bitmapSerdeFactory = bitmapSerdeFactory;
+ this.constantValue = constantValue;
+ this.matchBitmap = bitmapSerdeFactory.getBitmapFactory().complement(
+ bitmapSerdeFactory.getBitmapFactory().makeEmptyImmutableBitmap(),
+ numRows
+ );
+ this.match = new SimpleImmutableBitmapIndex(matchBitmap);
+ this.noMatchBitmap =
bitmapSerdeFactory.getBitmapFactory().makeEmptyImmutableBitmap();
+ this.noMatch = new SimpleImmutableBitmapIndex(noMatchBitmap);
+ }
+
+ @Override
+ public NestedCommonFormatColumn get()
+ {
+ return new ConstantColumn(logicalType, constantValue);
+ }
+
+ @Nullable
+ @Override
+ public <T> T as(Class<T> clazz)
+ {
+ if (clazz.equals(NullValueIndex.class)) {
+ final BitmapColumnIndex nullIndex;
+ if (constantValue == null) {
+ nullIndex = match;
+ } else {
+ nullIndex = noMatch;
+ }
+ return (T) (NullValueIndex) () -> nullIndex;
+ } else if (logicalType.isPrimitive() &&
(clazz.equals(DictionaryEncodedStringValueIndex.class)
+ || clazz.equals(DictionaryEncodedValueIndex.class))) {
+ return (T) new ConstantDictionaryEncodedStringValueIndex();
+ } else if (logicalType.isPrimitive() &&
clazz.equals(StringValueSetIndex.class)) {
+ return (T) new ConstantStringValueSetIndex();
+ } else if (logicalType.is(ValueType.STRING) &&
clazz.equals(LexicographicalRangeIndex.class)) {
+ return (T) new ConstantLexicographicalRangeIndex();
+ } else if (logicalType.isNumeric() &&
clazz.equals(NumericRangeIndex.class)) {
+ return (T) new ConstantNumericRangeIndex();
+ } else if (logicalType.isPrimitive() &&
clazz.equals(DruidPredicateIndex.class)) {
+ return (T) new ConstantDruidPredicateIndex();
+ }
+ return null;
+ }
+
+ class ConstantStringValueSetIndex implements StringValueSetIndex
+ {
+ private final String theString = Evals.asString(constantValue);
+
+ @Override
+ public BitmapColumnIndex forValue(@Nullable String value)
+ {
+ if (Objects.equals(value, theString)) {
+ return match;
+ }
+ return noMatch;
+ }
+
+ @Override
+ public BitmapColumnIndex forSortedValues(SortedSet<String> values)
+ {
+ if (values.contains(theString)) {
+ return match;
+ }
+ return noMatch;
+ }
+ }
+
+ class ConstantLexicographicalRangeIndex implements LexicographicalRangeIndex
+ {
+ private final String theString = Evals.asString(constantValue);
+ private final NullableTypeStrategy<String> strategy =
logicalType.getNullableStrategy();
+
+ @Nullable
+ @Override
+ public BitmapColumnIndex forRange(
+ @Nullable String startValue,
+ boolean startStrict,
+ @Nullable String endValue,
+ boolean endStrict
+ )
+ {
+ if (inRange(startValue, startStrict, endValue, endStrict)) {
+ return match;
+ }
+ return noMatch;
+ }
+
+ @Nullable
+ @Override
+ public BitmapColumnIndex forRange(
+ @Nullable String startValue,
+ boolean startStrict,
+ @Nullable String endValue,
+ boolean endStrict,
+ Predicate<String> matcher
+ )
+ {
+ if (inRange(startValue, startStrict, endValue, endStrict) &&
matcher.apply(theString)) {
+ return match;
+ }
+ return noMatch;
+ }
+
+ private boolean inRange(
+ @Nullable String startValue,
+ boolean startStrict,
+ @Nullable String endValue,
+ boolean endStrict
+ )
+ {
+ final int startCompare = strategy.compare(startValue, theString);
+ final int endCompare = endValue == null ? -1 :
strategy.compare(theString, endValue);
+ final boolean startSatisfied = startStrict ? startCompare > 0 :
startCompare >= 0;
+ final boolean endSatisified = endStrict ? endCompare < 0 : endCompare <=
0;
+ return startSatisfied && endSatisified;
+ }
+ }
+
+ class ConstantNumericRangeIndex implements NumericRangeIndex
+ {
+ private final NullableTypeStrategy<Number> strategy =
logicalType.getNullableStrategy();
+
+ @Nullable
+ @Override
+ public BitmapColumnIndex forRange(
+ @Nullable Number startValue,
+ boolean startStrict,
+ @Nullable Number endValue,
+ boolean endStrict
+ )
+ {
+ if (constantValue == null) {
+ return noMatch;
+ }
+ final Number theNumber = (Number) constantValue;
+ final int startCompare = strategy.compare(startValue, theNumber);
+ final int endCompare = endValue == null ? -1 :
strategy.compare(theNumber, endValue);
+ final boolean startSatisfied = startStrict ? startCompare > 0 :
startCompare >= 0;
+ final boolean endSatisified = endStrict ? endCompare < 0 : endCompare <=
0;
+ if (startSatisfied && endSatisified) {
+ return match;
+ }
+ return noMatch;
+ }
+ }
+
+ class ConstantDruidPredicateIndex implements DruidPredicateIndex
+ {
+ @Nullable
+ @Override
+ public BitmapColumnIndex forPredicate(DruidPredicateFactory matcherFactory)
+ {
+ switch (logicalType.getType()) {
+ case STRING:
+ if (matcherFactory.makeStringPredicate().apply((String)
constantValue)) {
+ return match;
+ }
+ return noMatch;
+ case LONG:
+ DruidLongPredicate longPredicate =
matcherFactory.makeLongPredicate();
+ if (constantValue == null && longPredicate.applyNull()) {
+ return match;
+ } else if (longPredicate.applyLong((Long) constantValue)) {
Review Comment:
## Dereferenced variable may be null
Variable [constantValue](1) may be null at this access as suggested by
[this](2) null guard.
Variable [constantValue](1) may be null at this access as suggested by
[this](3) null guard.
Variable [constantValue](1) may be null at this access as suggested by
[this](4) null guard.
[Show more
details](https://github.com/apache/druid/security/code-scanning/5043)
##########
processing/src/main/java/org/apache/druid/segment/nested/ConstantColumnAndIndexSupplier.java:
##########
@@ -0,0 +1,328 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.segment.nested;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import org.apache.druid.collections.bitmap.BitmapFactory;
+import org.apache.druid.collections.bitmap.ImmutableBitmap;
+import org.apache.druid.java.util.common.RE;
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.math.expr.Evals;
+import org.apache.druid.query.filter.DruidDoublePredicate;
+import org.apache.druid.query.filter.DruidFloatPredicate;
+import org.apache.druid.query.filter.DruidLongPredicate;
+import org.apache.druid.query.filter.DruidPredicateFactory;
+import org.apache.druid.segment.IndexMerger;
+import org.apache.druid.segment.column.BitmapColumnIndex;
+import org.apache.druid.segment.column.ColumnIndexSupplier;
+import org.apache.druid.segment.column.ColumnType;
+import org.apache.druid.segment.column.DictionaryEncodedStringValueIndex;
+import org.apache.druid.segment.column.DictionaryEncodedValueIndex;
+import org.apache.druid.segment.column.DruidPredicateIndex;
+import org.apache.druid.segment.column.LexicographicalRangeIndex;
+import org.apache.druid.segment.column.NullValueIndex;
+import org.apache.druid.segment.column.NullableTypeStrategy;
+import org.apache.druid.segment.column.NumericRangeIndex;
+import org.apache.druid.segment.column.SimpleImmutableBitmapIndex;
+import org.apache.druid.segment.column.StringValueSetIndex;
+import org.apache.druid.segment.column.ValueType;
+import org.apache.druid.segment.data.BitmapSerdeFactory;
+import org.apache.druid.segment.data.VByte;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Objects;
+import java.util.SortedSet;
+
+public class ConstantColumnAndIndexSupplier implements
Supplier<NestedCommonFormatColumn>, ColumnIndexSupplier
+{
+ public static ConstantColumnAndIndexSupplier read(
+ ColumnType logicalType,
+ BitmapSerdeFactory bitmapSerdeFactory,
+ ByteBuffer bb
+ )
+ {
+ final byte version = bb.get();
+ final int columnNameLength = VByte.readInt(bb);
+ final String columnName = StringUtils.fromUtf8(bb, columnNameLength);
+
+ if (version == NestedCommonFormatColumnSerializer.V0) {
+ try {
+ final int rowCount = VByte.readInt(bb);
+ final int valueLength = VByte.readInt(bb);
+ final Object constantValue =
NestedDataComplexTypeSerde.OBJECT_MAPPER.readValue(
+ IndexMerger.SERIALIZER_UTILS.readBytes(bb, valueLength),
+ Object.class
+ );
+ return new ConstantColumnAndIndexSupplier(logicalType,
bitmapSerdeFactory, rowCount, constantValue);
+ }
+ catch (IOException ex) {
+ throw new RE(ex, "Failed to deserialize V%s column [%s].", version,
columnName);
+ }
+ } else {
+ throw new RE("Unknown version " + version);
+ }
+ }
+
+ private final ColumnType logicalType;
+ private final BitmapSerdeFactory bitmapSerdeFactory;
+ @Nullable
+ private final Object constantValue;
+
+ private final ImmutableBitmap matchBitmap;
+ private final SimpleImmutableBitmapIndex match;
+ private final ImmutableBitmap noMatchBitmap;
+ private final SimpleImmutableBitmapIndex noMatch;
+
+ public ConstantColumnAndIndexSupplier(
+ ColumnType logicalType,
+ BitmapSerdeFactory bitmapSerdeFactory,
+ int numRows,
+ @Nullable Object constantValue
+ )
+ {
+ this.logicalType = logicalType;
+ this.bitmapSerdeFactory = bitmapSerdeFactory;
+ this.constantValue = constantValue;
+ this.matchBitmap = bitmapSerdeFactory.getBitmapFactory().complement(
+ bitmapSerdeFactory.getBitmapFactory().makeEmptyImmutableBitmap(),
+ numRows
+ );
+ this.match = new SimpleImmutableBitmapIndex(matchBitmap);
+ this.noMatchBitmap =
bitmapSerdeFactory.getBitmapFactory().makeEmptyImmutableBitmap();
+ this.noMatch = new SimpleImmutableBitmapIndex(noMatchBitmap);
+ }
+
+ @Override
+ public NestedCommonFormatColumn get()
+ {
+ return new ConstantColumn(logicalType, constantValue);
+ }
+
+ @Nullable
+ @Override
+ public <T> T as(Class<T> clazz)
+ {
+ if (clazz.equals(NullValueIndex.class)) {
+ final BitmapColumnIndex nullIndex;
+ if (constantValue == null) {
+ nullIndex = match;
+ } else {
+ nullIndex = noMatch;
+ }
+ return (T) (NullValueIndex) () -> nullIndex;
+ } else if (logicalType.isPrimitive() &&
(clazz.equals(DictionaryEncodedStringValueIndex.class)
+ || clazz.equals(DictionaryEncodedValueIndex.class))) {
+ return (T) new ConstantDictionaryEncodedStringValueIndex();
+ } else if (logicalType.isPrimitive() &&
clazz.equals(StringValueSetIndex.class)) {
+ return (T) new ConstantStringValueSetIndex();
+ } else if (logicalType.is(ValueType.STRING) &&
clazz.equals(LexicographicalRangeIndex.class)) {
+ return (T) new ConstantLexicographicalRangeIndex();
+ } else if (logicalType.isNumeric() &&
clazz.equals(NumericRangeIndex.class)) {
+ return (T) new ConstantNumericRangeIndex();
+ } else if (logicalType.isPrimitive() &&
clazz.equals(DruidPredicateIndex.class)) {
+ return (T) new ConstantDruidPredicateIndex();
+ }
+ return null;
+ }
+
+ class ConstantStringValueSetIndex implements StringValueSetIndex
+ {
+ private final String theString = Evals.asString(constantValue);
+
+ @Override
+ public BitmapColumnIndex forValue(@Nullable String value)
+ {
+ if (Objects.equals(value, theString)) {
+ return match;
+ }
+ return noMatch;
+ }
+
+ @Override
+ public BitmapColumnIndex forSortedValues(SortedSet<String> values)
+ {
+ if (values.contains(theString)) {
+ return match;
+ }
+ return noMatch;
+ }
+ }
+
+ class ConstantLexicographicalRangeIndex implements LexicographicalRangeIndex
+ {
+ private final String theString = Evals.asString(constantValue);
+ private final NullableTypeStrategy<String> strategy =
logicalType.getNullableStrategy();
+
+ @Nullable
+ @Override
+ public BitmapColumnIndex forRange(
+ @Nullable String startValue,
+ boolean startStrict,
+ @Nullable String endValue,
+ boolean endStrict
+ )
+ {
+ if (inRange(startValue, startStrict, endValue, endStrict)) {
+ return match;
+ }
+ return noMatch;
+ }
+
+ @Nullable
+ @Override
+ public BitmapColumnIndex forRange(
+ @Nullable String startValue,
+ boolean startStrict,
+ @Nullable String endValue,
+ boolean endStrict,
+ Predicate<String> matcher
+ )
+ {
+ if (inRange(startValue, startStrict, endValue, endStrict) &&
matcher.apply(theString)) {
+ return match;
+ }
+ return noMatch;
+ }
+
+ private boolean inRange(
+ @Nullable String startValue,
+ boolean startStrict,
+ @Nullable String endValue,
+ boolean endStrict
+ )
+ {
+ final int startCompare = strategy.compare(startValue, theString);
+ final int endCompare = endValue == null ? -1 :
strategy.compare(theString, endValue);
+ final boolean startSatisfied = startStrict ? startCompare > 0 :
startCompare >= 0;
+ final boolean endSatisified = endStrict ? endCompare < 0 : endCompare <=
0;
+ return startSatisfied && endSatisified;
+ }
+ }
+
+ class ConstantNumericRangeIndex implements NumericRangeIndex
+ {
+ private final NullableTypeStrategy<Number> strategy =
logicalType.getNullableStrategy();
+
+ @Nullable
+ @Override
+ public BitmapColumnIndex forRange(
+ @Nullable Number startValue,
+ boolean startStrict,
+ @Nullable Number endValue,
+ boolean endStrict
+ )
+ {
+ if (constantValue == null) {
+ return noMatch;
+ }
+ final Number theNumber = (Number) constantValue;
+ final int startCompare = strategy.compare(startValue, theNumber);
+ final int endCompare = endValue == null ? -1 :
strategy.compare(theNumber, endValue);
+ final boolean startSatisfied = startStrict ? startCompare > 0 :
startCompare >= 0;
+ final boolean endSatisified = endStrict ? endCompare < 0 : endCompare <=
0;
+ if (startSatisfied && endSatisified) {
+ return match;
+ }
+ return noMatch;
+ }
+ }
+
+ class ConstantDruidPredicateIndex implements DruidPredicateIndex
+ {
+ @Nullable
+ @Override
+ public BitmapColumnIndex forPredicate(DruidPredicateFactory matcherFactory)
+ {
+ switch (logicalType.getType()) {
+ case STRING:
+ if (matcherFactory.makeStringPredicate().apply((String)
constantValue)) {
+ return match;
+ }
+ return noMatch;
+ case LONG:
+ DruidLongPredicate longPredicate =
matcherFactory.makeLongPredicate();
+ if (constantValue == null && longPredicate.applyNull()) {
+ return match;
+ } else if (longPredicate.applyLong((Long) constantValue)) {
+ return match;
+ }
+ return noMatch;
+ case FLOAT:
+ DruidFloatPredicate floatPredicate =
matcherFactory.makeFloatPredicate();
+ if (constantValue == null && floatPredicate.applyNull()) {
+ return match;
+ } else if (floatPredicate.applyFloat((Float) constantValue)) {
+ return match;
+ }
+ return noMatch;
+ case DOUBLE:
+ DruidDoublePredicate doublePredicate =
matcherFactory.makeDoublePredicate();
+ if (constantValue == null && doublePredicate.applyNull()) {
+ return match;
+ } else if (doublePredicate.applyDouble((Double) constantValue)) {
Review Comment:
## Dereferenced variable may be null
Variable [constantValue](1) may be null at this access as suggested by
[this](2) null guard.
Variable [constantValue](1) may be null at this access as suggested by
[this](3) null guard.
Variable [constantValue](1) may be null at this access as suggested by
[this](4) null guard.
[Show more
details](https://github.com/apache/druid/security/code-scanning/5045)
##########
processing/src/test/java/org/apache/druid/segment/nested/ConstantColumnSupplierTest.java:
##########
@@ -0,0 +1,454 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.segment.nested;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import org.apache.druid.guice.NestedDataModule;
+import org.apache.druid.java.util.common.concurrent.Execs;
+import org.apache.druid.java.util.common.io.Closer;
+import org.apache.druid.java.util.common.io.smoosh.FileSmoosher;
+import org.apache.druid.java.util.common.io.smoosh.SmooshedFileMapper;
+import org.apache.druid.java.util.common.io.smoosh.SmooshedWriter;
+import org.apache.druid.math.expr.ExprEval;
+import org.apache.druid.math.expr.ExpressionType;
+import org.apache.druid.query.DefaultBitmapResultFactory;
+import org.apache.druid.segment.AutoTypeColumnIndexer;
+import org.apache.druid.segment.AutoTypeColumnMerger;
+import org.apache.druid.segment.ColumnValueSelector;
+import org.apache.druid.segment.DimensionSelector;
+import org.apache.druid.segment.IndexSpec;
+import org.apache.druid.segment.IndexableAdapter;
+import org.apache.druid.segment.SimpleAscendingOffset;
+import org.apache.druid.segment.column.ColumnBuilder;
+import org.apache.druid.segment.column.ColumnType;
+import org.apache.druid.segment.column.DruidPredicateIndex;
+import org.apache.druid.segment.column.LexicographicalRangeIndex;
+import org.apache.druid.segment.column.NullValueIndex;
+import org.apache.druid.segment.column.NumericRangeIndex;
+import org.apache.druid.segment.column.StringValueSetIndex;
+import org.apache.druid.segment.data.BitmapSerdeFactory;
+import org.apache.druid.segment.data.RoaringBitmapSerdeFactory;
+import org.apache.druid.segment.vector.NoFilterVectorOffset;
+import org.apache.druid.segment.vector.SingleValueDimensionVectorSelector;
+import org.apache.druid.segment.vector.VectorObjectSelector;
+import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory;
+import org.apache.druid.segment.writeout.TmpFileSegmentWriteOutMediumFactory;
+import org.apache.druid.testing.InitializedNullHandlingTest;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.atomic.AtomicReference;
+
+@RunWith(Parameterized.class)
+public class ConstantColumnSupplierTest extends InitializedNullHandlingTest
+{
+
+ public static List<Object> CONSTANT_NULL = Arrays.asList(
+ null,
+ null,
+ null,
+ null,
+ null
+ );
+
+ public static List<String> CONSTANT_STRING = Arrays.asList(
+ "abcd",
+ "abcd",
+ "abcd",
+ "abcd",
+ "abcd"
+ );
+
+ public static List<Long> CONSTANT_LONG = Arrays.asList(
+ 1234L,
+ 1234L,
+ 1234L,
+ 1234L,
+ 1234L
+ );
+
+ public static List<List<Long>> CONSTANT_LONG_ARRAY = Arrays.asList(
+ Arrays.asList(1L, 2L, 3L, 4L),
+ Arrays.asList(1L, 2L, 3L, 4L),
+ Arrays.asList(1L, 2L, 3L, 4L),
+ Arrays.asList(1L, 2L, 3L, 4L),
+ Arrays.asList(1L, 2L, 3L, 4L)
+ );
+
+ public static List<Object> CONSTANT_EMPTY_OBJECTS = Arrays.asList(
+ Collections.emptyMap(),
+ Collections.emptyMap(),
+ Collections.emptyMap(),
+ Collections.emptyMap(),
+ Collections.emptyMap()
+ );
+
+ public static List<Object> CONSTANT_OBJECTS = Arrays.asList(
+ ImmutableMap.of("x", 1234, "y", 1.234, "z", "abcd"),
+ ImmutableMap.of("x", 1234, "y", 1.234, "z", "abcd"),
+ ImmutableMap.of("x", 1234, "y", 1.234, "z", "abcd"),
+ ImmutableMap.of("x", 1234, "y", 1.234, "z", "abcd"),
+ ImmutableMap.of("x", 1234, "y", 1.234, "z", "abcd")
+ );
+
+ @BeforeClass
+ public static void staticSetup()
+ {
+ NestedDataModule.registerHandlersAndSerde();
+ }
+
+ @Parameterized.Parameters(name = "data = {0}")
+ public static Collection<?> constructorFeeder()
+ {
+ final List<Object[]> constructors = ImmutableList.of(
+ new Object[]{"NULL", CONSTANT_NULL, IndexSpec.DEFAULT},
+ new Object[]{"STRING", CONSTANT_STRING, IndexSpec.DEFAULT},
+ new Object[]{"LONG", CONSTANT_LONG, IndexSpec.DEFAULT},
+ new Object[]{"ARRAY<LONG>", CONSTANT_LONG_ARRAY, IndexSpec.DEFAULT},
+ new Object[]{"EMPTY OBJECT", CONSTANT_EMPTY_OBJECTS,
IndexSpec.DEFAULT},
+ new Object[]{"OBJECT", CONSTANT_OBJECTS, IndexSpec.DEFAULT}
+ );
+
+ return constructors;
+ }
+
+ @Rule
+ public final TemporaryFolder tempFolder = new TemporaryFolder();
+
+ Closer closer = Closer.create();
+
+ SmooshedFileMapper fileMapper;
+
+ ByteBuffer baseBuffer;
+
+ FieldTypeInfo.MutableTypeSet expectedTypes;
+
+ ColumnType expectedLogicalType = null;
+
+ private final List<?> data;
+ private final IndexSpec indexSpec;
+
+ BitmapSerdeFactory bitmapSerdeFactory =
RoaringBitmapSerdeFactory.getInstance();
+ DefaultBitmapResultFactory resultFactory = new
DefaultBitmapResultFactory(bitmapSerdeFactory.getBitmapFactory());
+
+ public ConstantColumnSupplierTest(
+ @SuppressWarnings("unused") String name,
+ List<?> data,
+ IndexSpec indexSpec
+ )
+ {
+ this.data = data;
+ this.indexSpec = indexSpec;
+ }
+
+ @Before
+ public void setup() throws IOException
+ {
+ final String fileNameBase = "test";
+ fileMapper = smooshify(fileNameBase, tempFolder.newFolder());
+ baseBuffer = fileMapper.mapFile(fileNameBase);
+ }
+
+ private SmooshedFileMapper smooshify(
+ String fileNameBase,
+ File tmpFile
+ )
+ throws IOException
+ {
+ SegmentWriteOutMediumFactory writeOutMediumFactory =
TmpFileSegmentWriteOutMediumFactory.instance();
+ try (final FileSmoosher smoosher = new FileSmoosher(tmpFile)) {
+
+ AutoTypeColumnIndexer indexer = new AutoTypeColumnIndexer();
+ for (Object o : data) {
+ indexer.processRowValsToUnsortedEncodedKeyComponent(o, false);
+ }
+ SortedMap<String, FieldTypeInfo.MutableTypeSet> sortedFields = new
TreeMap<>();
+
+ IndexableAdapter.NestedColumnMergable mergable = closer.register(
+ new IndexableAdapter.NestedColumnMergable(
+ indexer.getSortedValueLookups(),
+ indexer.getFieldTypeInfo(),
+ data.get(0) instanceof Map,
+ true,
+ data.get(0)
+ )
+ );
+ SortedValueDictionary globalDictionarySortedCollector =
mergable.getValueDictionary();
+ mergable.mergeFieldsInto(sortedFields);
+
+ expectedTypes = sortedFields.get(NestedPathFinder.JSON_PATH_ROOT);
+ if (expectedTypes != null) {
+ for (ColumnType type :
FieldTypeInfo.convertToSet(expectedTypes.getByteValue())) {
+ expectedLogicalType =
ColumnType.leastRestrictiveType(expectedLogicalType, type);
+ }
+ if (expectedLogicalType == null) {
+ expectedLogicalType = ColumnType.STRING;
+ }
+ } else {
+ expectedLogicalType = ColumnType.STRING;
+ }
+ if (data.get(0) instanceof Map) {
+ expectedLogicalType = ColumnType.NESTED_DATA;
+ }
+ ConstantColumnSerializer serializer = new ConstantColumnSerializer(
+ fileNameBase,
+ data.get(0)
+ );
+
+ serializer.openDictionaryWriter();
+ serializer.serializeDictionaries(
+ globalDictionarySortedCollector.getSortedStrings(),
+ globalDictionarySortedCollector.getSortedLongs(),
+ globalDictionarySortedCollector.getSortedDoubles(),
+ () -> new AutoTypeColumnMerger.ArrayDictionaryMergingIterator(
+ new
Iterable[]{globalDictionarySortedCollector.getSortedArrays()},
+ serializer.getGlobalLookup()
+ )
+ );
+ serializer.open();
+
+ NestedDataColumnSupplierTest.SettableSelector valueSelector = new
NestedDataColumnSupplierTest.SettableSelector();
+ for (Object o : data) {
+ valueSelector.setObject(StructuredData.wrap(o));
+ serializer.serialize(valueSelector);
+ }
+
+ try (SmooshedWriter writer =
smoosher.addWithSmooshedWriter(fileNameBase, serializer.getSerializedSize())) {
+ serializer.writeTo(writer, smoosher);
+ }
+ smoosher.close();
+ return closer.register(SmooshedFileMapper.load(tmpFile));
+ }
+ }
+
+ @After
+ public void teardown() throws IOException
+ {
+ closer.close();
+ }
+
+ @Test
+ public void testBasicFunctionality() throws IOException
+ {
+ ColumnBuilder bob = new ColumnBuilder();
+ bob.setFileMapper(fileMapper);
+ ConstantColumnAndIndexSupplier supplier =
ConstantColumnAndIndexSupplier.read(
+ expectedLogicalType,
+ bitmapSerdeFactory,
+ baseBuffer
+ );
+ try (ConstantColumn column = (ConstantColumn) supplier.get()) {
+ smokeTest(supplier, column, data, expectedTypes);
+ }
+ }
+
+ @Test
+ public void testConcurrency() throws ExecutionException, InterruptedException
+ {
+ // if this test ever starts being to be a flake, there might be thread
safety issues
+ ColumnBuilder bob = new ColumnBuilder();
+ bob.setFileMapper(fileMapper);
+ ConstantColumnAndIndexSupplier supplier =
ConstantColumnAndIndexSupplier.read(
+ expectedLogicalType,
+ bitmapSerdeFactory,
+ baseBuffer
+ );
+ final String expectedReason = "none";
+ final AtomicReference<String> failureReason = new
AtomicReference<>(expectedReason);
+
+ final int threads = 10;
+ ListeningExecutorService executorService =
MoreExecutors.listeningDecorator(
+ Execs.multiThreaded(threads, "StandardNestedColumnSupplierTest-%d")
+ );
+ Collection<ListenableFuture<?>> futures = new ArrayList<>(threads);
+ final CountDownLatch threadsStartLatch = new CountDownLatch(1);
+ for (int i = 0; i < threads; ++i) {
+ futures.add(
+ executorService.submit(() -> {
+ try {
+ threadsStartLatch.await();
+ for (int iter = 0; iter < 5000; iter++) {
+ try (ConstantColumn column = (ConstantColumn) supplier.get()) {
+ smokeTest(supplier, column, data, expectedTypes);
+ }
+ }
+ }
+ catch (Throwable ex) {
+ failureReason.set(ex.getMessage());
+ }
+ })
+ );
+ }
+ threadsStartLatch.countDown();
+ Futures.allAsList(futures).get();
+ Assert.assertEquals(expectedReason, failureReason.get());
+ }
+
+ private void smokeTest(
+ ConstantColumnAndIndexSupplier supplier,
+ ConstantColumn column,
+ List<?> data,
+ FieldTypeInfo.MutableTypeSet expectedType
+ )
+ {
+ SimpleAscendingOffset offset = new SimpleAscendingOffset(data.size());
+ NoFilterVectorOffset vectorOffset = new NoFilterVectorOffset(1, 0,
data.size());
+ ColumnValueSelector<?> valueSelector =
column.makeColumnValueSelector(offset);
+ DimensionSelector dimensionSelector =
+ expectedLogicalType.isPrimitive() ?
column.makeDimensionSelector(offset, null) : null;
+ VectorObjectSelector vectorObjectSelector =
column.makeVectorObjectSelector(vectorOffset);
+ SingleValueDimensionVectorSelector dimensionVectorSelector =
+ expectedLogicalType.isPrimitive() ?
column.makeSingleValueDimensionVectorSelector(vectorOffset) : null;
+
+ StringValueSetIndex valueSetIndex = supplier.as(StringValueSetIndex.class);
+ DruidPredicateIndex predicateIndex =
supplier.as(DruidPredicateIndex.class);
+ NullValueIndex nullValueIndex = supplier.as(NullValueIndex.class);
+ LexicographicalRangeIndex lexicographicalRangeIndex =
supplier.as(LexicographicalRangeIndex.class);
+ NumericRangeIndex rangeIndex = supplier.as(NumericRangeIndex.class);
+ if (!expectedLogicalType.isPrimitive()) {
+ Assert.assertNull(valueSetIndex);
+ Assert.assertNull(predicateIndex);
+ Assert.assertNull(lexicographicalRangeIndex);
+ Assert.assertNull(rangeIndex);
+ } else {
+ Assert.assertNotNull(valueSetIndex);
+ Assert.assertNotNull(predicateIndex);
+ if (expectedLogicalType.isNumeric()) {
+ Assert.assertNull(lexicographicalRangeIndex);
+ Assert.assertNotNull(rangeIndex);
+ } else {
+ Assert.assertNotNull(lexicographicalRangeIndex);
+ Assert.assertNull(rangeIndex);
+ }
+ }
+ Assert.assertNotNull(nullValueIndex);
+
+ SortedMap<String, FieldTypeInfo.MutableTypeSet> fields =
column.getFieldTypeInfo();
+ if (expectedType != null) {
+ Assert.assertEquals(
+ ImmutableMap.of(NestedPathFinder.JSON_PATH_ROOT, expectedType),
+ fields
+ );
+ }
+ final ExpressionType expressionType =
ExpressionType.fromColumnTypeStrict(expectedLogicalType);
+
+ for (int i = 0; i < data.size(); i++) {
+ Object row = data.get(i);
+
+ // in default value mode, even though the input row had an empty string,
the selector spits out null, so we want
+ // to take the null checking path
+
+ if (row != null) {
+ if (row instanceof List) {
+ Assert.assertArrayEquals(((List) row).toArray(), (Object[])
valueSelector.getObject());
+ if (expectedType.getSingleType() != null) {
Review Comment:
## Dereferenced variable may be null
Variable [expectedType](1) may be null at this access as suggested by
[this](2) null guard.
Variable [expectedType](1) may be null at this access as suggested by
[this](3) null guard.
[Show more
details](https://github.com/apache/druid/security/code-scanning/5046)
##########
processing/src/main/java/org/apache/druid/segment/nested/ConstantColumn.java:
##########
@@ -0,0 +1,363 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.segment.nested;
+
+import org.apache.druid.java.util.common.UOE;
+import org.apache.druid.math.expr.ExprEval;
+import org.apache.druid.math.expr.ExpressionType;
+import org.apache.druid.query.extraction.ExtractionFn;
+import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector;
+import org.apache.druid.segment.ColumnValueSelector;
+import org.apache.druid.segment.DimensionSelector;
+import org.apache.druid.segment.column.ColumnType;
+import org.apache.druid.segment.column.DictionaryEncodedColumn;
+import org.apache.druid.segment.column.ValueType;
+import org.apache.druid.segment.data.Indexed;
+import org.apache.druid.segment.data.IndexedInts;
+import org.apache.druid.segment.data.ListIndexed;
+import org.apache.druid.segment.data.ReadableOffset;
+import org.apache.druid.segment.vector.BaseDoubleVectorValueSelector;
+import org.apache.druid.segment.vector.BaseFloatVectorValueSelector;
+import org.apache.druid.segment.vector.BaseLongVectorValueSelector;
+import org.apache.druid.segment.vector.ConstantVectorSelectors;
+import org.apache.druid.segment.vector.MultiValueDimensionVectorSelector;
+import org.apache.druid.segment.vector.ReadableVectorOffset;
+import org.apache.druid.segment.vector.SingleValueDimensionVectorSelector;
+import org.apache.druid.segment.vector.VectorObjectSelector;
+import org.apache.druid.segment.vector.VectorValueSelector;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Objects;
+
+public class ConstantColumn implements NestedCommonFormatColumn,
DictionaryEncodedColumn<String>
+{
+ private final ColumnType logicalType;
+ private final ExprEval<?> value;
+ private final String stringVal;
+
+ public ConstantColumn(ColumnType logicalType, @Nullable Object value)
+ {
+ this.logicalType = logicalType;
+ this.value = ExprEval.ofType(ExpressionType.fromColumnType(logicalType),
value);
+ this.stringVal = value == null ? null : String.valueOf(value);
+ }
+
+ @Override
+ public int length()
+ {
+ return 0;
+ }
+
+ @Override
+ public boolean hasMultipleValues()
+ {
+ return false;
+ }
+
+ @Override
+ public int getSingleValueRow(int rowNum)
+ {
+ return 0;
+ }
+
+ @Override
+ public IndexedInts getMultiValueRow(int rowNum)
+ {
+ throw new UnsupportedOperationException("Not a multi-value column");
+ }
+
+ @Nullable
+ @Override
+ public String lookupName(int id)
+ {
+ if (id == 0) {
+ return stringVal;
+ }
+ return null;
+ }
+
+ @Override
+ public int lookupId(String name)
+ {
+ if (Objects.equals(name, stringVal)) {
+ return 0;
+ }
+ return -1;
+ }
+
+ @Override
+ public int getCardinality()
+ {
+ return 1;
+ }
+
+ @Override
+ public DimensionSelector makeDimensionSelector(ReadableOffset offset,
@Nullable ExtractionFn extractionFn)
+ {
+ return DimensionSelector.constant(stringVal, extractionFn);
+ }
+
+ @Override
+ public ColumnValueSelector<?> makeColumnValueSelector(ReadableOffset offset)
+ {
+ return new ColumnValueSelector<Object>()
+ {
+ @Override
+ public double getDouble()
+ {
+ return value.asDouble();
+ }
+
+ @Override
+ public float getFloat()
+ {
+ return (float) value.asDouble();
+ }
+
+ @Override
+ public long getLong()
+ {
+ return value.asLong();
+ }
+
+ @Override
+ public void inspectRuntimeShape(RuntimeShapeInspector inspector)
+ {
+
+ }
+
+ @Override
+ public boolean isNull()
+ {
+ return value.isNumericNull();
+ }
+
+ @Nullable
+ @Override
+ public Object getObject()
+ {
+ return value.valueOrDefault();
+ }
+
+ @Override
+ public Class<?> classOfObject()
+ {
+ return Object.class;
+ }
+ };
+ }
+
+ @Override
+ public SingleValueDimensionVectorSelector
makeSingleValueDimensionVectorSelector(ReadableVectorOffset vectorOffset)
+ {
+ return
ConstantVectorSelectors.singleValueDimensionVectorSelector(vectorOffset,
stringVal);
+ }
+
+ @Override
+ public MultiValueDimensionVectorSelector
makeMultiValueDimensionVectorSelector(ReadableVectorOffset vectorOffset)
+ {
+ throw new UnsupportedOperationException("Not a multi-value column");
+ }
+
+ @Override
+ public VectorValueSelector makeVectorValueSelector(ReadableVectorOffset
offset)
+ {
+ if (logicalType.isNumeric()) {
+ final boolean[] nulls;
+ if (value.isNumericNull()) {
+ nulls = new boolean[offset.getMaxVectorSize()];
+ Arrays.fill(nulls, true);
+ } else {
+ nulls = null;
+ }
+ switch (logicalType.getType()) {
Review Comment:
## Missing enum case in switch
Switch statement does not have a case for [ARRAY](1).
Switch statement does not have a case for [COMPLEX](2).
Switch statement does not have a case for [STRING](3).
[Show more
details](https://github.com/apache/druid/security/code-scanning/5050)
##########
processing/src/test/java/org/apache/druid/segment/nested/ConstantColumnSupplierTest.java:
##########
@@ -0,0 +1,454 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.segment.nested;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import org.apache.druid.guice.NestedDataModule;
+import org.apache.druid.java.util.common.concurrent.Execs;
+import org.apache.druid.java.util.common.io.Closer;
+import org.apache.druid.java.util.common.io.smoosh.FileSmoosher;
+import org.apache.druid.java.util.common.io.smoosh.SmooshedFileMapper;
+import org.apache.druid.java.util.common.io.smoosh.SmooshedWriter;
+import org.apache.druid.math.expr.ExprEval;
+import org.apache.druid.math.expr.ExpressionType;
+import org.apache.druid.query.DefaultBitmapResultFactory;
+import org.apache.druid.segment.AutoTypeColumnIndexer;
+import org.apache.druid.segment.AutoTypeColumnMerger;
+import org.apache.druid.segment.ColumnValueSelector;
+import org.apache.druid.segment.DimensionSelector;
+import org.apache.druid.segment.IndexSpec;
+import org.apache.druid.segment.IndexableAdapter;
+import org.apache.druid.segment.SimpleAscendingOffset;
+import org.apache.druid.segment.column.ColumnBuilder;
+import org.apache.druid.segment.column.ColumnType;
+import org.apache.druid.segment.column.DruidPredicateIndex;
+import org.apache.druid.segment.column.LexicographicalRangeIndex;
+import org.apache.druid.segment.column.NullValueIndex;
+import org.apache.druid.segment.column.NumericRangeIndex;
+import org.apache.druid.segment.column.StringValueSetIndex;
+import org.apache.druid.segment.data.BitmapSerdeFactory;
+import org.apache.druid.segment.data.RoaringBitmapSerdeFactory;
+import org.apache.druid.segment.vector.NoFilterVectorOffset;
+import org.apache.druid.segment.vector.SingleValueDimensionVectorSelector;
+import org.apache.druid.segment.vector.VectorObjectSelector;
+import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory;
+import org.apache.druid.segment.writeout.TmpFileSegmentWriteOutMediumFactory;
+import org.apache.druid.testing.InitializedNullHandlingTest;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.atomic.AtomicReference;
+
+@RunWith(Parameterized.class)
+public class ConstantColumnSupplierTest extends InitializedNullHandlingTest
+{
+
+ public static List<Object> CONSTANT_NULL = Arrays.asList(
+ null,
+ null,
+ null,
+ null,
+ null
+ );
+
+ public static List<String> CONSTANT_STRING = Arrays.asList(
+ "abcd",
+ "abcd",
+ "abcd",
+ "abcd",
+ "abcd"
+ );
+
+ public static List<Long> CONSTANT_LONG = Arrays.asList(
+ 1234L,
+ 1234L,
+ 1234L,
+ 1234L,
+ 1234L
+ );
+
+ public static List<List<Long>> CONSTANT_LONG_ARRAY = Arrays.asList(
+ Arrays.asList(1L, 2L, 3L, 4L),
+ Arrays.asList(1L, 2L, 3L, 4L),
+ Arrays.asList(1L, 2L, 3L, 4L),
+ Arrays.asList(1L, 2L, 3L, 4L),
+ Arrays.asList(1L, 2L, 3L, 4L)
+ );
+
+ public static List<Object> CONSTANT_EMPTY_OBJECTS = Arrays.asList(
+ Collections.emptyMap(),
+ Collections.emptyMap(),
+ Collections.emptyMap(),
+ Collections.emptyMap(),
+ Collections.emptyMap()
+ );
+
+ public static List<Object> CONSTANT_OBJECTS = Arrays.asList(
+ ImmutableMap.of("x", 1234, "y", 1.234, "z", "abcd"),
+ ImmutableMap.of("x", 1234, "y", 1.234, "z", "abcd"),
+ ImmutableMap.of("x", 1234, "y", 1.234, "z", "abcd"),
+ ImmutableMap.of("x", 1234, "y", 1.234, "z", "abcd"),
+ ImmutableMap.of("x", 1234, "y", 1.234, "z", "abcd")
+ );
+
+ @BeforeClass
+ public static void staticSetup()
+ {
+ NestedDataModule.registerHandlersAndSerde();
+ }
+
+ @Parameterized.Parameters(name = "data = {0}")
+ public static Collection<?> constructorFeeder()
+ {
+ final List<Object[]> constructors = ImmutableList.of(
+ new Object[]{"NULL", CONSTANT_NULL, IndexSpec.DEFAULT},
+ new Object[]{"STRING", CONSTANT_STRING, IndexSpec.DEFAULT},
+ new Object[]{"LONG", CONSTANT_LONG, IndexSpec.DEFAULT},
+ new Object[]{"ARRAY<LONG>", CONSTANT_LONG_ARRAY, IndexSpec.DEFAULT},
+ new Object[]{"EMPTY OBJECT", CONSTANT_EMPTY_OBJECTS,
IndexSpec.DEFAULT},
+ new Object[]{"OBJECT", CONSTANT_OBJECTS, IndexSpec.DEFAULT}
+ );
+
+ return constructors;
+ }
+
+ @Rule
+ public final TemporaryFolder tempFolder = new TemporaryFolder();
+
+ Closer closer = Closer.create();
+
+ SmooshedFileMapper fileMapper;
+
+ ByteBuffer baseBuffer;
+
+ FieldTypeInfo.MutableTypeSet expectedTypes;
+
+ ColumnType expectedLogicalType = null;
+
+ private final List<?> data;
+ private final IndexSpec indexSpec;
+
+ BitmapSerdeFactory bitmapSerdeFactory =
RoaringBitmapSerdeFactory.getInstance();
+ DefaultBitmapResultFactory resultFactory = new
DefaultBitmapResultFactory(bitmapSerdeFactory.getBitmapFactory());
+
+ public ConstantColumnSupplierTest(
+ @SuppressWarnings("unused") String name,
Review Comment:
## Useless parameter
The parameter 'name' is never used.
[Show more
details](https://github.com/apache/druid/security/code-scanning/5049)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]