github-advanced-security[bot] commented on code in PR #17762:
URL: https://github.com/apache/druid/pull/17762#discussion_r2369389563


##########
processing/src/main/java/org/apache/druid/segment/AutoTypeColumnIndexer.java:
##########
@@ -754,57 +757,17 @@
     }
   }
 
-  static class Format implements ColumnFormat
+  static class Format extends NestedCommonFormatColumn.Format

Review Comment:
   ## Class has same name as super class
   
   Format has the same name as its supertype 
[org.apache.druid.segment.nested.NestedCommonFormatColumn$Format](1).
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/10402)



##########
processing/src/main/java/org/apache/druid/segment/nested/NestedCommonFormatColumnFormatSpec.java:
##########
@@ -0,0 +1,442 @@
+/*
+ * 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.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.druid.java.util.common.ISE;
+import org.apache.druid.segment.IndexSpec;
+import org.apache.druid.segment.column.StringEncodingStrategy;
+import org.apache.druid.segment.data.BitmapSerdeFactory;
+import org.apache.druid.segment.data.CompressionFactory;
+import org.apache.druid.segment.data.CompressionStrategy;
+
+import javax.annotation.Nullable;
+import java.util.Objects;
+
+public class NestedCommonFormatColumnFormatSpec
+{
+  public static Builder builder()
+  {
+    return new Builder();
+  }
+
+  public static NestedCommonFormatColumnFormatSpec getEffectiveFormatSpec(
+      @Nullable NestedCommonFormatColumnFormatSpec columnFormatSpec,
+      IndexSpec indexSpec
+  )
+  {
+    return Objects.requireNonNullElseGet(
+        columnFormatSpec,
+        () -> NestedCommonFormatColumnFormatSpec.builder()
+                                                
.setObjectFieldsDictionaryEncoding(StringEncodingStrategy.UTF8_STRATEGY)
+                                                
.setObjectStorageEncoding(ObjectStorageEncoding.SMILE)
+                                                .build()
+    ).getEffectiveSpec(indexSpec);
+  }
+
+  @Nullable
+  private final StringEncodingStrategy objectFieldsDictionaryEncoding;
+  @Nullable
+  private final ObjectStorageEncoding objectStorageEncoding;
+  @Nullable
+  private final CompressionStrategy objectStorageCompression;
+  @Nullable
+  private final StringEncodingStrategy stringDictionaryEncoding;
+  @Nullable
+  private final CompressionStrategy dictionaryEncodedColumnCompression;
+  @Nullable
+  private final CompressionFactory.LongEncodingStrategy longColumnEncoding;
+  @Nullable
+  private final CompressionStrategy longColumnCompression;
+  @Nullable
+  private final CompressionStrategy doubleColumnCompression;
+  @Nullable
+  private final BitmapSerdeFactory bitmapEncoding;
+
+  @JsonCreator
+  public NestedCommonFormatColumnFormatSpec(
+      @JsonProperty("objectFieldsDictionaryEncoding") @Nullable 
StringEncodingStrategy objectFieldsDictionaryEncoding,
+      @JsonProperty("objectStorageEncoding") @Nullable ObjectStorageEncoding 
objectStorageEncoding,
+      @JsonProperty("objectStorageCompression") @Nullable CompressionStrategy 
objectStorageCompression,
+      @JsonProperty("stringDictionaryEncoding") @Nullable 
StringEncodingStrategy stringDictionaryEncoding,
+      @JsonProperty("dictionaryEncodedColumnCompression") @Nullable 
CompressionStrategy dictionaryEncodedColumnCompression,
+      @JsonProperty("longColumnEncoding") @Nullable 
CompressionFactory.LongEncodingStrategy longColumnEncoding,
+      @JsonProperty("longColumnCompression") @Nullable CompressionStrategy 
longColumnCompression,
+      @JsonProperty("doubleColumnCompression") @Nullable CompressionStrategy 
doubleColumnCompression
+  )
+  {
+    this(
+        objectFieldsDictionaryEncoding,
+        objectStorageEncoding,
+        objectStorageCompression,
+        stringDictionaryEncoding,
+        dictionaryEncodedColumnCompression,
+        longColumnEncoding,
+        longColumnCompression,
+        doubleColumnCompression,
+        null
+    );
+  }
+
+  /**
+   * Internal constructor used by {@link Builder} to set {@link 
#bitmapEncoding} during the process of resolving values
+   * for {@link #getEffectiveSpec(IndexSpec)}. {@link #bitmapEncoding} cannot 
vary per column, and is always set from
+   * {@link IndexSpec#getBitmapSerdeFactory()}.
+   */
+  protected NestedCommonFormatColumnFormatSpec(
+      @Nullable StringEncodingStrategy objectFieldsDictionaryEncoding,
+      @Nullable ObjectStorageEncoding objectStorageEncoding,
+      @Nullable CompressionStrategy objectStorageCompression,
+      @Nullable StringEncodingStrategy stringDictionaryEncoding,
+      @Nullable CompressionStrategy dictionaryEncodedColumnCompression,
+      @Nullable CompressionFactory.LongEncodingStrategy longColumnEncoding,
+      @Nullable CompressionStrategy longColumnCompression,
+      @Nullable CompressionStrategy doubleColumnCompression,
+      @Nullable BitmapSerdeFactory bitmapEncoding
+  )
+  {
+    this.objectFieldsDictionaryEncoding = objectFieldsDictionaryEncoding;
+    this.objectStorageEncoding = objectStorageEncoding;
+    this.objectStorageCompression = objectStorageCompression;
+    this.stringDictionaryEncoding = stringDictionaryEncoding;
+    this.dictionaryEncodedColumnCompression = 
dictionaryEncodedColumnCompression;
+    this.longColumnEncoding = longColumnEncoding;
+    this.longColumnCompression = longColumnCompression;
+    this.doubleColumnCompression = doubleColumnCompression;
+    this.bitmapEncoding = bitmapEncoding;
+  }
+
+  /**
+   * Fully populate all fields of {@link NestedCommonFormatColumnFormatSpec}. 
Null values are populated first checking
+   * {@link IndexSpec#getAutoColumnFormatSpec()}, then falling back to fields 
on {@link IndexSpec} itself if applicable,
+   * and finally resorting to hard coded defaults.
+   */
+  public NestedCommonFormatColumnFormatSpec getEffectiveSpec(IndexSpec 
indexSpec)
+  {
+    // this is a defensive check, the json spec can't set this, only the 
builder can
+    if (bitmapEncoding != null && 
!bitmapEncoding.equals(indexSpec.getBitmapSerdeFactory())) {
+      throw new ISE(
+          "bitmapEncoding[%s] does not match indexSpec.bitmap[%s]",
+          bitmapEncoding,
+          indexSpec.getBitmapSerdeFactory()
+      );
+    }
+    Builder builder = new Builder(this);
+    builder.setBitmapEncoding(indexSpec.getBitmapSerdeFactory());
+
+    if (objectFieldsDictionaryEncoding == null) {
+      if 
(indexSpec.getAutoColumnFormatSpec().getObjectFieldsDictionaryEncoding() != 
null) {
+        builder.setObjectFieldsDictionaryEncoding(
+            
indexSpec.getAutoColumnFormatSpec().getObjectFieldsDictionaryEncoding()
+        );
+      } else {
+        
builder.setObjectFieldsDictionaryEncoding(StringEncodingStrategy.DEFAULT);
+      }
+    }
+
+    if (objectStorageEncoding == null) {
+      if (indexSpec.getAutoColumnFormatSpec().getObjectStorageEncoding() != 
null) {
+        
builder.setObjectStorageEncoding(indexSpec.getAutoColumnFormatSpec().getObjectStorageEncoding());
+      } else {
+        builder.setObjectStorageEncoding(ObjectStorageEncoding.SMILE);
+      }
+    }
+
+    if (objectStorageCompression == null) {
+      if (indexSpec.getAutoColumnFormatSpec().getObjectStorageCompression() != 
null) {
+        
builder.setObjectStorageCompression(indexSpec.getAutoColumnFormatSpec().getObjectStorageCompression());
+      } else if (indexSpec.getJsonCompression() != null) {

Review Comment:
   ## Deprecated method or constructor invocation
   
   Invoking [IndexSpec.getJsonCompression](1) should be avoided because it has 
been deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/10403)



##########
processing/src/main/java/org/apache/druid/segment/nested/NestedCommonFormatColumnFormatSpec.java:
##########
@@ -0,0 +1,442 @@
+/*
+ * 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.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.druid.java.util.common.ISE;
+import org.apache.druid.segment.IndexSpec;
+import org.apache.druid.segment.column.StringEncodingStrategy;
+import org.apache.druid.segment.data.BitmapSerdeFactory;
+import org.apache.druid.segment.data.CompressionFactory;
+import org.apache.druid.segment.data.CompressionStrategy;
+
+import javax.annotation.Nullable;
+import java.util.Objects;
+
+public class NestedCommonFormatColumnFormatSpec
+{
+  public static Builder builder()
+  {
+    return new Builder();
+  }
+
+  public static NestedCommonFormatColumnFormatSpec getEffectiveFormatSpec(
+      @Nullable NestedCommonFormatColumnFormatSpec columnFormatSpec,
+      IndexSpec indexSpec
+  )
+  {
+    return Objects.requireNonNullElseGet(
+        columnFormatSpec,
+        () -> NestedCommonFormatColumnFormatSpec.builder()
+                                                
.setObjectFieldsDictionaryEncoding(StringEncodingStrategy.UTF8_STRATEGY)
+                                                
.setObjectStorageEncoding(ObjectStorageEncoding.SMILE)
+                                                .build()
+    ).getEffectiveSpec(indexSpec);
+  }
+
+  @Nullable
+  private final StringEncodingStrategy objectFieldsDictionaryEncoding;
+  @Nullable
+  private final ObjectStorageEncoding objectStorageEncoding;
+  @Nullable
+  private final CompressionStrategy objectStorageCompression;
+  @Nullable
+  private final StringEncodingStrategy stringDictionaryEncoding;
+  @Nullable
+  private final CompressionStrategy dictionaryEncodedColumnCompression;
+  @Nullable
+  private final CompressionFactory.LongEncodingStrategy longColumnEncoding;
+  @Nullable
+  private final CompressionStrategy longColumnCompression;
+  @Nullable
+  private final CompressionStrategy doubleColumnCompression;
+  @Nullable
+  private final BitmapSerdeFactory bitmapEncoding;
+
+  @JsonCreator
+  public NestedCommonFormatColumnFormatSpec(
+      @JsonProperty("objectFieldsDictionaryEncoding") @Nullable 
StringEncodingStrategy objectFieldsDictionaryEncoding,
+      @JsonProperty("objectStorageEncoding") @Nullable ObjectStorageEncoding 
objectStorageEncoding,
+      @JsonProperty("objectStorageCompression") @Nullable CompressionStrategy 
objectStorageCompression,
+      @JsonProperty("stringDictionaryEncoding") @Nullable 
StringEncodingStrategy stringDictionaryEncoding,
+      @JsonProperty("dictionaryEncodedColumnCompression") @Nullable 
CompressionStrategy dictionaryEncodedColumnCompression,
+      @JsonProperty("longColumnEncoding") @Nullable 
CompressionFactory.LongEncodingStrategy longColumnEncoding,
+      @JsonProperty("longColumnCompression") @Nullable CompressionStrategy 
longColumnCompression,
+      @JsonProperty("doubleColumnCompression") @Nullable CompressionStrategy 
doubleColumnCompression
+  )
+  {
+    this(
+        objectFieldsDictionaryEncoding,
+        objectStorageEncoding,
+        objectStorageCompression,
+        stringDictionaryEncoding,
+        dictionaryEncodedColumnCompression,
+        longColumnEncoding,
+        longColumnCompression,
+        doubleColumnCompression,
+        null
+    );
+  }
+
+  /**
+   * Internal constructor used by {@link Builder} to set {@link 
#bitmapEncoding} during the process of resolving values
+   * for {@link #getEffectiveSpec(IndexSpec)}. {@link #bitmapEncoding} cannot 
vary per column, and is always set from
+   * {@link IndexSpec#getBitmapSerdeFactory()}.
+   */
+  protected NestedCommonFormatColumnFormatSpec(
+      @Nullable StringEncodingStrategy objectFieldsDictionaryEncoding,
+      @Nullable ObjectStorageEncoding objectStorageEncoding,
+      @Nullable CompressionStrategy objectStorageCompression,
+      @Nullable StringEncodingStrategy stringDictionaryEncoding,
+      @Nullable CompressionStrategy dictionaryEncodedColumnCompression,
+      @Nullable CompressionFactory.LongEncodingStrategy longColumnEncoding,
+      @Nullable CompressionStrategy longColumnCompression,
+      @Nullable CompressionStrategy doubleColumnCompression,
+      @Nullable BitmapSerdeFactory bitmapEncoding
+  )
+  {
+    this.objectFieldsDictionaryEncoding = objectFieldsDictionaryEncoding;
+    this.objectStorageEncoding = objectStorageEncoding;
+    this.objectStorageCompression = objectStorageCompression;
+    this.stringDictionaryEncoding = stringDictionaryEncoding;
+    this.dictionaryEncodedColumnCompression = 
dictionaryEncodedColumnCompression;
+    this.longColumnEncoding = longColumnEncoding;
+    this.longColumnCompression = longColumnCompression;
+    this.doubleColumnCompression = doubleColumnCompression;
+    this.bitmapEncoding = bitmapEncoding;
+  }
+
+  /**
+   * Fully populate all fields of {@link NestedCommonFormatColumnFormatSpec}. 
Null values are populated first checking
+   * {@link IndexSpec#getAutoColumnFormatSpec()}, then falling back to fields 
on {@link IndexSpec} itself if applicable,
+   * and finally resorting to hard coded defaults.
+   */
+  public NestedCommonFormatColumnFormatSpec getEffectiveSpec(IndexSpec 
indexSpec)
+  {
+    // this is a defensive check, the json spec can't set this, only the 
builder can
+    if (bitmapEncoding != null && 
!bitmapEncoding.equals(indexSpec.getBitmapSerdeFactory())) {
+      throw new ISE(
+          "bitmapEncoding[%s] does not match indexSpec.bitmap[%s]",
+          bitmapEncoding,
+          indexSpec.getBitmapSerdeFactory()
+      );
+    }
+    Builder builder = new Builder(this);
+    builder.setBitmapEncoding(indexSpec.getBitmapSerdeFactory());
+
+    if (objectFieldsDictionaryEncoding == null) {
+      if 
(indexSpec.getAutoColumnFormatSpec().getObjectFieldsDictionaryEncoding() != 
null) {
+        builder.setObjectFieldsDictionaryEncoding(
+            
indexSpec.getAutoColumnFormatSpec().getObjectFieldsDictionaryEncoding()
+        );
+      } else {
+        
builder.setObjectFieldsDictionaryEncoding(StringEncodingStrategy.DEFAULT);
+      }
+    }
+
+    if (objectStorageEncoding == null) {
+      if (indexSpec.getAutoColumnFormatSpec().getObjectStorageEncoding() != 
null) {
+        
builder.setObjectStorageEncoding(indexSpec.getAutoColumnFormatSpec().getObjectStorageEncoding());
+      } else {
+        builder.setObjectStorageEncoding(ObjectStorageEncoding.SMILE);
+      }
+    }
+
+    if (objectStorageCompression == null) {
+      if (indexSpec.getAutoColumnFormatSpec().getObjectStorageCompression() != 
null) {
+        
builder.setObjectStorageCompression(indexSpec.getAutoColumnFormatSpec().getObjectStorageCompression());
+      } else if (indexSpec.getJsonCompression() != null) {
+        builder.setObjectStorageCompression(indexSpec.getJsonCompression());

Review Comment:
   ## Deprecated method or constructor invocation
   
   Invoking [IndexSpec.getJsonCompression](1) should be avoided because it has 
been deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/10404)



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