This is an automated email from the ASF dual-hosted git repository.

jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 21f1cc4f0b Fix segment reload on custom forward index setting (#14150)
21f1cc4f0b is described below

commit 21f1cc4f0bf60dc083e91243df59956fd2580986
Author: Xiaotian (Jackie) Jiang <[email protected]>
AuthorDate: Thu Oct 3 17:01:25 2024 -0700

    Fix segment reload on custom forward index setting (#14150)
---
 .../segment/index/forward/ForwardIndexType.java    |  55 ++---------
 .../segment/index/loader/IndexLoadingConfig.java   |  62 -------------
 .../index/loader/IndexLoadingConfigTest.java       | 101 ++++++++++++++++++++-
 .../index/loader/SegmentPreProcessorTest.java      |  20 ++--
 4 files changed, 119 insertions(+), 119 deletions(-)

diff --git 
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/forward/ForwardIndexType.java
 
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/forward/ForwardIndexType.java
index 4172a6bdbb..3846b983fb 100644
--- 
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/forward/ForwardIndexType.java
+++ 
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/forward/ForwardIndexType.java
@@ -19,23 +19,18 @@
 
 package org.apache.pinot.segment.local.segment.index.forward;
 
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import java.io.IOException;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import javax.annotation.Nullable;
 import 
org.apache.pinot.segment.local.realtime.impl.forward.CLPMutableForwardIndex;
 import 
org.apache.pinot.segment.local.realtime.impl.forward.FixedByteMVMutableForwardIndex;
 import 
org.apache.pinot.segment.local.realtime.impl.forward.FixedByteSVMutableForwardIndex;
 import 
org.apache.pinot.segment.local.realtime.impl.forward.VarByteSVMutableForwardIndex;
-import 
org.apache.pinot.segment.local.segment.index.loader.ConfigurableFromIndexLoadingConfig;
 import org.apache.pinot.segment.local.segment.index.loader.ForwardIndexHandler;
-import org.apache.pinot.segment.local.segment.index.loader.IndexLoadingConfig;
 import org.apache.pinot.segment.spi.ColumnMetadata;
 import org.apache.pinot.segment.spi.V1Constants;
 import org.apache.pinot.segment.spi.compression.ChunkCompressionType;
@@ -64,21 +59,22 @@ import org.apache.pinot.spi.data.FieldSpec;
 import org.apache.pinot.spi.data.Schema;
 
 
-public class ForwardIndexType extends AbstractIndexType<ForwardIndexConfig, 
ForwardIndexReader, ForwardIndexCreator>
-    implements ConfigurableFromIndexLoadingConfig<ForwardIndexConfig> {
+public class ForwardIndexType extends AbstractIndexType<ForwardIndexConfig, 
ForwardIndexReader, ForwardIndexCreator> {
   public static final String INDEX_DISPLAY_NAME = "forward";
   // For multi-valued column, forward-index.
   // Maximum number of multi-values per row. We assert on this.
   public static final int MAX_MULTI_VALUES_PER_ROW = 1000;
   private static final int 
NODICT_VARIABLE_WIDTH_ESTIMATED_AVERAGE_VALUE_LENGTH_DEFAULT = 100;
   private static final int 
NODICT_VARIABLE_WIDTH_ESTIMATED_NUMBER_OF_VALUES_DEFAULT = 100_000;
-  private static final List<String> EXTENSIONS = Lists.newArrayList(
+  //@formatter:off
+  private static final List<String> EXTENSIONS = List.of(
       V1Constants.Indexes.RAW_SV_FORWARD_INDEX_FILE_EXTENSION,
       V1Constants.Indexes.SORTED_SV_FORWARD_INDEX_FILE_EXTENSION,
       V1Constants.Indexes.UNSORTED_SV_FORWARD_INDEX_FILE_EXTENSION,
       V1Constants.Indexes.RAW_MV_FORWARD_INDEX_FILE_EXTENSION,
       V1Constants.Indexes.UNSORTED_MV_FORWARD_INDEX_FILE_EXTENSION
   );
+  //@formatter:on
 
   protected ForwardIndexType() {
     super(StandardIndexes.FORWARD_ID);
@@ -89,35 +85,6 @@ public class ForwardIndexType extends 
AbstractIndexType<ForwardIndexConfig, Forw
     return ForwardIndexConfig.class;
   }
 
-  @Override
-  public Map<String, ForwardIndexConfig> 
fromIndexLoadingConfig(IndexLoadingConfig indexLoadingConfig) {
-    Set<String> disabledColumns = 
indexLoadingConfig.getForwardIndexDisabledColumns();
-    Map<String, CompressionCodec> compressionCodecMap = 
indexLoadingConfig.getCompressionConfigs();
-    Map<String, ForwardIndexConfig> result = new HashMap<>();
-    for (String column : indexLoadingConfig.getAllKnownColumns()) {
-      ForwardIndexConfig forwardIndexConfig;
-      if (!disabledColumns.contains(column)) {
-        CompressionCodec compressionCodec = compressionCodecMap.get(column);
-        if (compressionCodec == null) {
-          TableConfig tableConfig = indexLoadingConfig.getTableConfig();
-          if (tableConfig != null && tableConfig.getFieldConfigList() != null) 
{
-            FieldConfig fieldConfig =
-                tableConfig.getFieldConfigList().stream().filter(fc -> 
fc.getName().equals(column)).findAny()
-                    .orElse(null);
-            if (fieldConfig != null) {
-              compressionCodec = fieldConfig.getCompressionCodec();
-            }
-          }
-        }
-        forwardIndexConfig = new 
ForwardIndexConfig.Builder().withCompressionCodec(compressionCodec).build();
-      } else {
-        forwardIndexConfig = ForwardIndexConfig.DISABLED;
-      }
-      result.put(column, forwardIndexConfig);
-    }
-    return result;
-  }
-
   @Override
   public ForwardIndexConfig getDefaultConfig() {
     return ForwardIndexConfig.DEFAULT;
@@ -134,8 +101,8 @@ public class ForwardIndexType extends 
AbstractIndexType<ForwardIndexConfig, Forw
     ColumnConfigDeserializer<ForwardIndexConfig> fromOld = (tableConfig, 
schema) -> {
       Map<String, DictionaryIndexConfig> dictConfigs = 
StandardIndexes.dictionary().getConfig(tableConfig, schema);
 
-      Map<String, ForwardIndexConfig> fwdConfig = 
Maps.newHashMapWithExpectedSize(
-          Math.max(dictConfigs.size(), schema.size()));
+      Map<String, ForwardIndexConfig> fwdConfig =
+          Maps.newHashMapWithExpectedSize(Math.max(dictConfigs.size(), 
schema.size()));
 
       Collection<FieldConfig> fieldConfigs = tableConfig.getFieldConfigList();
       if (fieldConfigs != null) {
@@ -228,8 +195,7 @@ public class ForwardIndexType extends 
AbstractIndexType<ForwardIndexConfig, Forw
    *
    * This method will return the default reader, skipping any index overload.
    */
-  public static ForwardIndexReader<?> read(SegmentDirectory.Reader 
segmentReader,
-      ColumnMetadata columnMetadata)
+  public static ForwardIndexReader<?> read(SegmentDirectory.Reader 
segmentReader, ColumnMetadata columnMetadata)
       throws IOException {
     PinotDataBuffer dataBuffer = 
segmentReader.getIndexFor(columnMetadata.getColumnName(), 
StandardIndexes.forward());
     return read(dataBuffer, columnMetadata);
@@ -282,8 +248,8 @@ public class ForwardIndexType extends 
AbstractIndexType<ForwardIndexConfig, Forw
           //       columns as well
           // TODO: Use the stats to get estimated average length
           // Use a smaller capacity as opposed to segment flush size
-          int initialCapacity = Math.min(context.getCapacity(),
-              NODICT_VARIABLE_WIDTH_ESTIMATED_NUMBER_OF_VALUES_DEFAULT);
+          int initialCapacity =
+              Math.min(context.getCapacity(), 
NODICT_VARIABLE_WIDTH_ESTIMATED_NUMBER_OF_VALUES_DEFAULT);
           if (config.getCompressionCodec() == CompressionCodec.CLP) {
             return new CLPMutableForwardIndex(column, storedType, 
context.getMemoryManager(), context.getCapacity());
           }
@@ -298,8 +264,7 @@ public class ForwardIndexType extends 
AbstractIndexType<ForwardIndexConfig, Forw
                 V1Constants.Indexes.RAW_MV_FORWARD_INDEX_FILE_EXTENSION);
         // TODO: Start with a smaller capacity on 
FixedByteMVForwardIndexReaderWriter and let it expand
         return new FixedByteMVMutableForwardIndex(MAX_MULTI_VALUES_PER_ROW, 
context.getAvgNumMultiValues(),
-            context.getCapacity(), storedType.size(), 
context.getMemoryManager(), allocationContext, false,
-            storedType);
+            context.getCapacity(), storedType.size(), 
context.getMemoryManager(), allocationContext, false, storedType);
       }
     } else {
       if (isSingleValue) {
diff --git 
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/IndexLoadingConfig.java
 
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/IndexLoadingConfig.java
index bb4e0543fc..c24c286000 100644
--- 
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/IndexLoadingConfig.java
+++ 
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/IndexLoadingConfig.java
@@ -46,7 +46,6 @@ import 
org.apache.pinot.spi.config.instance.InstanceDataManagerConfig;
 import org.apache.pinot.spi.config.table.BloomFilterConfig;
 import org.apache.pinot.spi.config.table.FSTType;
 import org.apache.pinot.spi.config.table.FieldConfig;
-import org.apache.pinot.spi.config.table.FieldConfig.CompressionCodec;
 import org.apache.pinot.spi.config.table.IndexConfig;
 import org.apache.pinot.spi.config.table.IndexingConfig;
 import org.apache.pinot.spi.config.table.JsonIndexConfig;
@@ -90,7 +89,6 @@ public class IndexLoadingConfig {
   private boolean _enableDynamicStarTreeCreation;
   private List<StarTreeIndexConfig> _starTreeIndexConfigs;
   private boolean _enableDefaultStarTree;
-  private final Map<String, CompressionCodec> _compressionConfigs = new 
HashMap<>();
   private Map<String, FieldIndexConfigs> _indexConfigsByColName = new 
HashMap<>();
 
   private SegmentVersion _segmentVersion;
@@ -214,10 +212,8 @@ public class IndexLoadingConfig {
       }
     }
 
-    extractCompressionConfigs(tableConfig);
     extractTextIndexColumnsFromTableConfig(tableConfig);
     extractFSTIndexColumnsFromTableConfig(tableConfig);
-    extractForwardIndexDisabledColumnsFromTableConfig(tableConfig);
 
     Map<String, String> noDictionaryConfig = 
indexingConfig.getNoDictionaryConfig();
     if (noDictionaryConfig != null) {
@@ -336,26 +332,6 @@ public class IndexLoadingConfig {
     return schema;
   }
 
-  /**
-   * Extracts compressionType for each column. Populates a map containing 
column name as key and compression type as
-   * value. This map will only contain the compressionType overrides, and it 
does not correspond to the default value
-   * of compressionType (derived using 
SegmentColumnarIndexCreator.getColumnCompressionType())  used for a column.
-   * Note that only RAW forward index columns will be populated in this map.
-   * @param tableConfig table config
-   */
-  private void extractCompressionConfigs(TableConfig tableConfig) {
-    List<FieldConfig> fieldConfigList = tableConfig.getFieldConfigList();
-    if (fieldConfigList == null) {
-      return;
-    }
-
-    for (FieldConfig fieldConfig : fieldConfigList) {
-      if (fieldConfig.getCompressionCodec() != null) {
-        _compressionConfigs.put(fieldConfig.getName(), 
fieldConfig.getCompressionCodec());
-      }
-    }
-  }
-
   /**
    * Text index creation info for each column is specified
    * using {@link FieldConfig} model of indicating per column
@@ -416,31 +392,6 @@ public class IndexLoadingConfig {
     _segmentDirectoryLoader = 
instanceDataManagerConfig.getSegmentDirectoryLoader();
   }
 
-  /**
-   * Forward index disabled info for each column is specified
-   * using {@link FieldConfig} model of indicating per column
-   * encoding and indexing information. Since IndexLoadingConfig
-   * is created from TableConfig, we extract the no forward index info
-   * from fieldConfigList in TableConfig via the properties bag.
-   * @param tableConfig table config
-   */
-  private void extractForwardIndexDisabledColumnsFromTableConfig(TableConfig 
tableConfig) {
-    List<FieldConfig> fieldConfigList = tableConfig.getFieldConfigList();
-    if (fieldConfigList != null) {
-      for (FieldConfig fieldConfig : fieldConfigList) {
-        Map<String, String> fieldConfigProperties = 
fieldConfig.getProperties();
-        if (fieldConfigProperties != null) {
-          boolean forwardIndexDisabled = Boolean.parseBoolean(
-              
fieldConfigProperties.getOrDefault(FieldConfig.FORWARD_INDEX_DISABLED,
-                  FieldConfig.DEFAULT_FORWARD_INDEX_DISABLED));
-          if (forwardIndexDisabled) {
-            _forwardIndexDisabledColumns.add(fieldConfig.getName());
-          }
-        }
-      }
-    }
-  }
-
   public ReadMode getReadMode() {
     return _readMode;
   }
@@ -585,18 +536,6 @@ public class IndexLoadingConfig {
     return unmodifiable(_noDictionaryColumns);
   }
 
-  /**
-   * Populates a map containing column name as key and compression type as 
value. This map will only contain the
-   * compressionType overrides, and it does not correspond to the default 
value of compressionType (derived using
-   * SegmentColumnarIndexCreator.getColumnCompressionType())  used for a 
column. Note that only RAW forward index
-   * columns will be populated in this map.
-   *
-   * @return a map containing column name as key and compressionType as value.
-   */
-  public Map<String, CompressionCodec> getCompressionConfigs() {
-    return unmodifiable(_compressionConfigs);
-  }
-
   public Map<String, String> getNoDictionaryConfig() {
     return unmodifiable(_noDictionaryConfig);
   }
@@ -769,7 +708,6 @@ public class IndexLoadingConfig {
     _knownColumns.addAll(_rangeIndexColumns);
     _knownColumns.addAll(_noDictionaryColumns);
     _knownColumns.addAll(_textIndexColumns);
-    _knownColumns.addAll(_forwardIndexDisabledColumns);
     _knownColumns.addAll(_onHeapDictionaryColumns);
     _knownColumns.addAll(_varLengthDictionaryColumns);
     return _knownColumns;
diff --git 
a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/IndexLoadingConfigTest.java
 
b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/IndexLoadingConfigTest.java
index aeadd3621f..a717973a64 100644
--- 
a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/IndexLoadingConfigTest.java
+++ 
b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/IndexLoadingConfigTest.java
@@ -18,11 +18,14 @@
  */
 package org.apache.pinot.segment.local.segment.index.loader;
 
+import com.fasterxml.jackson.core.JsonProcessingException;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.List;
 import java.util.Map;
 import org.apache.pinot.segment.spi.index.FieldIndexConfigs;
+import org.apache.pinot.segment.spi.index.ForwardIndexConfig;
 import org.apache.pinot.segment.spi.index.StandardIndexes;
 import org.apache.pinot.spi.config.instance.InstanceDataManagerConfig;
 import org.apache.pinot.spi.config.table.FieldConfig;
@@ -38,9 +41,7 @@ import org.testng.annotations.Test;
 
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.*;
 
 
 public class IndexLoadingConfigTest {
@@ -57,6 +58,7 @@ public class IndexLoadingConfigTest {
             .addSingleValueDimension("col2", 
FieldSpec.DataType.STRING).build();
     // On the default tier, both are dict-encoded. col1 has inverted index as 
set in `tableIndexConfig` and col2 has
     // bloom filter as configured with `fieldConfigList`; and there is one ST 
index built with col1.
+    //@formatter:off
     String col2CfgStr = "{"
         + "  \"name\": \"col2\","
         + "  \"indexes\": {"
@@ -69,6 +71,7 @@ public class IndexLoadingConfigTest {
         + "  \"functionColumnPairs\": [\"MAX__col1\"],"
         + "  \"maxLeafRecords\": 10"
         + "}";
+    //@formatter:on
     StarTreeIndexConfig stIdxCfg = JsonUtils.stringToObject(stIdxCfgStr, 
StarTreeIndexConfig.class);
     TableConfig tableConfig = new 
TableConfigBuilder(TableType.OFFLINE).setTableName(TABLE_NAME)
         .setInvertedIndexColumns(Collections.singletonList("col1"))
@@ -100,6 +103,7 @@ public class IndexLoadingConfigTest {
     // On the default tier, both are dict-encoded. col1 has inverted index as 
set in `tableIndexConfig` and col2 has
     // bloom filter as configured with `fieldConfigList`; and there is one ST 
index built with col1.
     // On the coldTier, we overwrite col1 to use bloom filter only and col2 to 
use raw encoding w/o any index.
+    //@formatter:off
     String col1CfgStr = "{"
         + "  \"name\": \"col1\","
         + "  \"indexes\": {"
@@ -132,6 +136,7 @@ public class IndexLoadingConfigTest {
         + "  \"functionColumnPairs\": [\"MAX__col1\"],"
         + "  \"maxLeafRecords\": 10"
         + "}";
+    //@formatter:on
     StarTreeIndexConfig stIdxCfg = JsonUtils.stringToObject(stIdxCfgStr, 
StarTreeIndexConfig.class);
     TableConfig tableConfig = new 
TableConfigBuilder(TableType.OFFLINE).setTableName(TABLE_NAME)
         .setStarTreeIndexConfigs(Collections.singletonList(stIdxCfg))
@@ -151,4 +156,94 @@ public class IndexLoadingConfigTest {
     
assertFalse(fieldCfgs.getConfig(StandardIndexes.bloomFilter()).isEnabled());
     assertFalse(fieldCfgs.getConfig(StandardIndexes.dictionary()).isEnabled());
   }
+
+  @Test
+  public void testCalculateForwardIndexConfig()
+      throws JsonProcessingException {
+    // Check default settings
+    //@formatter:off
+    String col1CfgStr = "{"
+        + "  \"name\": \"col1\","
+        + "  \"encodingType\": \"RAW\","
+        + "  \"indexes\": {"
+        + "    \"forward\": {}"
+        + "  }"
+        + "}";
+    //@formatter:on
+    FieldConfig col1Cfg = JsonUtils.stringToObject(col1CfgStr, 
FieldConfig.class);
+    TableConfig tableConfig =
+        new 
TableConfigBuilder(TableType.OFFLINE).setTableName(TABLE_NAME).setFieldConfigList(List.of(col1Cfg)).build();
+    Schema schema =
+        new 
Schema.SchemaBuilder().setSchemaName(TABLE_NAME).addSingleValueDimension("col1",
 FieldSpec.DataType.INT)
+            .build();
+    IndexLoadingConfig indexLoadingConfig = new 
IndexLoadingConfig(tableConfig, schema);
+    FieldIndexConfigs indexConfigs = 
indexLoadingConfig.getFieldIndexConfig("col1");
+    assertNotNull(indexConfigs);
+    ForwardIndexConfig forwardIndexConfig = 
indexConfigs.getConfig(StandardIndexes.forward());
+    assertTrue(forwardIndexConfig.isEnabled());
+    assertNull(forwardIndexConfig.getCompressionCodec());
+    assertFalse(forwardIndexConfig.isDeriveNumDocsPerChunk());
+    assertEquals(forwardIndexConfig.getRawIndexWriterVersion(), 
ForwardIndexConfig.DEFAULT_RAW_WRITER_VERSION);
+    assertEquals(forwardIndexConfig.getTargetMaxChunkSize(), 
ForwardIndexConfig.DEFAULT_TARGET_MAX_CHUNK_SIZE);
+    assertEquals(forwardIndexConfig.getTargetDocsPerChunk(), 
ForwardIndexConfig.DEFAULT_TARGET_DOCS_PER_CHUNK);
+
+    // Check custom settings
+    //@formatter:off
+    col1CfgStr = "{"
+        + "  \"name\": \"col1\","
+        + "  \"encodingType\": \"RAW\","
+        + "  \"indexes\": {"
+        + "    \"forward\": {"
+        + "      \"compressionCodec\": \"SNAPPY\","
+        + "      \"deriveNumDocsPerChunk\": true,"
+        + "      \"rawIndexWriterVersion\": 4,"
+        + "      \"targetMaxChunkSize\": \"100K\","
+        + "      \"targetDocsPerChunk\": 100"
+        + "    }"
+        + "  }"
+        + "}";
+    //@formatter:on
+    col1Cfg = JsonUtils.stringToObject(col1CfgStr, FieldConfig.class);
+    tableConfig =
+        new 
TableConfigBuilder(TableType.OFFLINE).setTableName(TABLE_NAME).setFieldConfigList(List.of(col1Cfg)).build();
+    schema =
+        new 
Schema.SchemaBuilder().setSchemaName(TABLE_NAME).addSingleValueDimension("col1",
 FieldSpec.DataType.INT)
+            .build();
+    indexLoadingConfig = new IndexLoadingConfig(tableConfig, schema);
+    indexConfigs = indexLoadingConfig.getFieldIndexConfig("col1");
+    assertNotNull(indexConfigs);
+    forwardIndexConfig = indexConfigs.getConfig(StandardIndexes.forward());
+    assertTrue(forwardIndexConfig.isEnabled());
+    assertEquals(forwardIndexConfig.getCompressionCodec(), 
FieldConfig.CompressionCodec.SNAPPY);
+    assertTrue(forwardIndexConfig.isDeriveNumDocsPerChunk());
+    assertEquals(forwardIndexConfig.getRawIndexWriterVersion(), 4);
+    assertEquals(forwardIndexConfig.getTargetMaxChunkSize(), "100K");
+    assertEquals(forwardIndexConfig.getTargetDocsPerChunk(), 100);
+
+    // Check disabled settings
+    //@formatter:off
+    col1CfgStr = "{"
+        + "  \"name\": \"col1\","
+        + "  \"encodingType\": \"RAW\","
+        + "  \"indexes\": {"
+        + "    \"forward\": {"
+        + "      \"disabled\": true"
+        + "    }"
+        + "  }"
+        + "}";
+    //@formatter:on
+    col1Cfg = JsonUtils.stringToObject(col1CfgStr, FieldConfig.class);
+    tableConfig =
+        new 
TableConfigBuilder(TableType.OFFLINE).setTableName(TABLE_NAME).setFieldConfigList(List.of(col1Cfg)).build();
+    indexLoadingConfig = new IndexLoadingConfig(tableConfig, schema);
+    indexConfigs = indexLoadingConfig.getFieldIndexConfig("col1");
+    assertNotNull(indexConfigs);
+    forwardIndexConfig = indexConfigs.getConfig(StandardIndexes.forward());
+    assertFalse(forwardIndexConfig.isEnabled());
+    assertNull(forwardIndexConfig.getCompressionCodec());
+    assertFalse(forwardIndexConfig.isDeriveNumDocsPerChunk());
+    assertEquals(forwardIndexConfig.getRawIndexWriterVersion(), 
ForwardIndexConfig.DEFAULT_RAW_WRITER_VERSION);
+    assertEquals(forwardIndexConfig.getTargetMaxChunkSize(), 
ForwardIndexConfig.DEFAULT_TARGET_MAX_CHUNK_SIZE);
+    assertEquals(forwardIndexConfig.getTargetDocsPerChunk(), 
ForwardIndexConfig.DEFAULT_TARGET_DOCS_PER_CHUNK);
+  }
 }
diff --git 
a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/SegmentPreProcessorTest.java
 
b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/SegmentPreProcessorTest.java
index 1fc1ff3a42..5488b2cf27 100644
--- 
a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/SegmentPreProcessorTest.java
+++ 
b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/SegmentPreProcessorTest.java
@@ -775,17 +775,19 @@ public class SegmentPreProcessorTest {
         SegmentDirectory.Reader reader = segmentDirectory.createReader()) {
       if (indexType != StandardIndexes.forward() || !forwardIndexDisabled) {
         assertTrue(reader.hasIndexFor(column, indexType));
-      }
-      if (isSingleValued && isSorted && forwardIndexDisabled) {
-        // Disabling the forward index for sorted columns should be a no-op
-        assertTrue(reader.hasIndexFor(column, StandardIndexes.forward()));
-        assertFalse(reader.hasIndexFor(column, StandardIndexes.inverted()));
-      } else if (forwardIndexDisabled) {
-        if (segmentMetadata.getVersion() == SegmentVersion.v3 || 
isAutoGenerated) {
-          assertFalse(reader.hasIndexFor(column, StandardIndexes.forward()));
+      } else {
+        // Verify forward index when it is configured to be disabled
+        if (isSorted) {
+          // Disabling the forward index for sorted columns should be a no-op
+          assertTrue(reader.hasIndexFor(column, StandardIndexes.forward()));
+          assertFalse(reader.hasIndexFor(column, StandardIndexes.inverted()));
         } else {
           // Updating dictionary or forward index for existing columns not 
supported for v1 segments yet
-          assertTrue(reader.hasIndexFor(column, StandardIndexes.forward()));
+          if (segmentMetadata.getVersion() == SegmentVersion.v3) {
+            assertFalse(reader.hasIndexFor(column, StandardIndexes.forward()));
+          } else {
+            assertTrue(reader.hasIndexFor(column, StandardIndexes.forward()));
+          }
         }
       }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to