clintropolis commented on code in PR #18722:
URL: https://github.com/apache/druid/pull/18722#discussion_r2607968404


##########
processing/src/main/java/org/apache/druid/segment/column/BitmapIndexType.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.column;
+
+import com.fasterxml.jackson.annotation.JsonSubTypes;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.google.common.base.Preconditions;
+import org.apache.druid.collections.bitmap.BitmapFactory;
+import org.apache.druid.collections.bitmap.ImmutableBitmap;
+import org.apache.druid.collections.bitmap.MutableBitmap;
+import org.apache.druid.error.DruidException;
+import org.apache.druid.segment.data.GenericIndexedWriter;
+import org.apache.druid.segment.file.SegmentFileBuilder;
+import org.apache.druid.segment.serde.Serializer;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.nio.channels.WritableByteChannel;
+import java.util.Objects;
+
+@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
+@JsonSubTypes({
+    @JsonSubTypes.Type(value = 
BitmapIndexType.DictionaryEncodedValueIndex.class, name = 
BitmapIndexType.TYPE_DICTIONARY),
+    @JsonSubTypes.Type(value = BitmapIndexType.NullValueIndex.class, name = 
BitmapIndexType.TYPE_NULL)
+})
+public abstract class BitmapIndexType implements Serializer
+{
+  protected static final String TYPE_DICTIONARY = 
"DictionaryEncodedValueIndex";
+  protected static final String TYPE_NULL = "NullValueIndex";

Review Comment:
   these should probably be `dictionaryEncodedValueIndex` and `nullValueIndex` 
to be consistent with other configuration type casing



##########
processing/src/main/java/org/apache/druid/segment/nested/CompressedNestedDataComplexColumn.java:
##########
@@ -1150,52 +1143,69 @@ private BaseColumnHolder readNestedFieldColumn(String 
field, int fieldIndex)
         );
         arrayElementBitmaps = GenericIndexed.read(
             dataBuffer,
-            bitmapSerdeFactory.getObjectStrategy(),
+            formatSpec.getBitmapEncoding().getObjectStrategy(),
             columnBuilder.getFileMapper()
         );
       } else {
         arrayElementDictionarySupplier = null;
         arrayElementBitmaps = null;
       }
-      final boolean hasNull = localDictionarySupplier.get().get(0) == 0;
-      Supplier<DictionaryEncodedColumn<?>> columnSupplier = () -> {
-        FixedIndexed<Integer> localDict = localDictionarySupplier.get();
-        return closer.register(new NestedFieldDictionaryEncodedColumn(
-            types,
-            longs.get(),
-            doubles.get(),
-            ints.get(),
-            stringDictionarySupplier.get(),
-            longDictionarySupplier.get(),
-            doubleDictionarySupplier.get(),
-            arrayDictionarySupplier != null ? arrayDictionarySupplier.get() : 
null,
-            localDict,
-            hasNull
-            ? rBitmaps.get(0)
-            : bitmapSerdeFactory.getBitmapFactory().makeEmptyImmutableBitmap()
-        ));
-      };
+      ColumnType theType = types.getSingleType();
+      BitmapIndexType indexType = (theType != null && theType.isNumeric())
+                                  ? 
formatSpec.getNumericFieldsBitmapIndexType()
+                                  : null;
       columnBuilder.setHasMultipleValues(false)
-                   .setHasNulls(hasNull)
-                   .setDictionaryEncodedColumnSupplier(columnSupplier);
-
-      columnBuilder.setIndexSupplier(
-          new NestedFieldColumnIndexSupplier(
-              types,
-              bitmapSerdeFactory.getBitmapFactory(),
-              columnConfig,
-              rBitmaps,
-              localDictionarySupplier,
-              stringDictionarySupplier,
-              longDictionarySupplier,
-              doubleDictionarySupplier,
-              arrayDictionarySupplier,
-              arrayElementDictionarySupplier,
-              arrayElementBitmaps
-          ),
-          true,
-          false
-      );
+                   .setType(theType != null
+                            ? theType
+                            : 
ColumnType.leastRestrictiveType(FieldTypeInfo.convertToSet(types.getByteValue())));
+      if (indexType != null && !(indexType instanceof 
BitmapIndexType.DictionaryEncodedValueIndex)) {
+        if (formatSpec.getNumericFieldsBitmapIndexType() instanceof 
BitmapIndexType.NullValueIndex) {
+          if (rBitmaps.size() != 1) {
+            throw DruidException.forPersona(DruidException.Persona.USER)
+                                
.ofCategory(DruidException.Category.INVALID_INPUT)
+                                .build(StringUtils.format(
+                                    "expecting 1 bitmap for %s type index, got 
[%d]",
+                                    indexType.toString(),
+                                    rBitmaps.size()
+                                ));
+          }

Review Comment:
   this case should set a `NullValueIndexSupplier`



##########
processing/src/test/java/org/apache/druid/guice/BuiltInTypesModuleTest.java:
##########
@@ -106,6 +107,7 @@ public void testOverride()
     
props.setProperty("druid.indexing.formats.indexSpec.autoColumnFormatSpec.stringDictionaryEncoding.type",
 StringEncodingStrategy.FRONT_CODED);
     
props.setProperty("druid.indexing.formats.indexSpec.autoColumnFormatSpec.stringDictionaryEncoding.bucketSize",
 "16");
     
props.setProperty("druid.indexing.formats.indexSpec.autoColumnFormatSpec.stringDictionaryEncoding.formatVersion",
 "1");
+    
props.setProperty("druid.indexing.formats.indexSpec.autoColumnFormatSpec.numericFieldsBitmapIndexEncoding.type",
 "nullsOnly");

Review Comment:
   oops, i think this needs updated



-- 
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]

Reply via email to