Skip to content

Commit

Permalink
Refactor ForwardIndexHandlerTest and avoid using setters for IndexLoa…
Browse files Browse the repository at this point in the history
…dingConfig (#14124)
  • Loading branch information
Jackie-Jiang authored Oct 1, 2024
1 parent f64178c commit 50249f3
Show file tree
Hide file tree
Showing 2 changed files with 1,237 additions and 1,699 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@
import java.util.stream.Collectors;
import org.apache.pinot.segment.local.segment.index.AbstractSerdeIndexContract;
import org.apache.pinot.segment.spi.index.DictionaryIndexConfig;
import org.apache.pinot.segment.spi.index.FieldIndexConfigs;
import org.apache.pinot.segment.spi.index.StandardIndexes;
import org.apache.pinot.spi.config.table.FieldConfig;
import org.apache.pinot.spi.config.table.IndexConfig;
import org.apache.pinot.spi.config.table.Intern;
import org.apache.pinot.spi.config.table.JsonIndexConfig;
import org.apache.pinot.spi.data.DimensionFieldSpec;
import org.apache.pinot.spi.data.FieldSpec;
import org.apache.pinot.spi.data.MetricFieldSpec;
import org.apache.pinot.spi.utils.JsonUtils;
import org.testng.Assert;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -342,4 +348,29 @@ public void testStandardIndex() {
assertSame(StandardIndexes.dictionary(), StandardIndexes.dictionary(), "Standard index should use the same as "
+ "the DictionaryIndexType static instance");
}

@Test
public void testDictionaryOverride() {
MetricFieldSpec metric = new MetricFieldSpec("testCol", FieldSpec.DataType.DOUBLE);
FieldIndexConfigs fieldIndexConfigs = new FieldIndexConfigs.Builder().build();
// No need to disable dictionary
assertTrue(DictionaryIndexType.ignoreDictionaryOverride(false, true, 2, metric, fieldIndexConfigs, 5, 20));

// Set a higher noDictionarySizeRatioThreshold
assertFalse(DictionaryIndexType.ignoreDictionaryOverride(false, true, 5, metric, fieldIndexConfigs, 5, 20));

// optimizeDictionary and optimizeDictionaryForMetrics both turned on
assertFalse(DictionaryIndexType.ignoreDictionaryOverride(true, true, 5, metric, fieldIndexConfigs, 5, 20));

// Ignore for inverted index
IndexConfig indexConfig = new IndexConfig(false);
fieldIndexConfigs = new FieldIndexConfigs.Builder().add(StandardIndexes.inverted(), indexConfig).build();
assertTrue(DictionaryIndexType.ignoreDictionaryOverride(true, true, 5, metric, fieldIndexConfigs, 5, 20));

// Don't ignore for JSON index
DimensionFieldSpec dimension = new DimensionFieldSpec("testCol", FieldSpec.DataType.JSON, true);
JsonIndexConfig jsonIndexConfig = new JsonIndexConfig();
fieldIndexConfigs = new FieldIndexConfigs.Builder().add(StandardIndexes.json(), jsonIndexConfig).build();
assertFalse(DictionaryIndexType.ignoreDictionaryOverride(true, true, 5, dimension, fieldIndexConfigs, 5, 20));
}
}
Loading

0 comments on commit 50249f3

Please sign in to comment.