vvivekiyer commented on code in PR #12223: URL: https://github.com/apache/pinot/pull/12223#discussion_r1467056125
########## pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/index/DictionaryIndexConfig.java: ########## @@ -21,29 +21,46 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Preconditions; import java.util.Objects; import javax.annotation.Nullable; import org.apache.pinot.spi.config.table.IndexConfig; +import org.apache.pinot.spi.config.table.Intern; public class DictionaryIndexConfig extends IndexConfig { - public static final DictionaryIndexConfig DEFAULT = new DictionaryIndexConfig(false, false, false); - public static final DictionaryIndexConfig DISABLED = new DictionaryIndexConfig(true, false, false); + public static final DictionaryIndexConfig DEFAULT = new DictionaryIndexConfig(false, false, false, Intern.DISABLED); Review Comment: Ack. ########## pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/dictionary/DictionaryIndexType.java: ########## @@ -308,7 +321,20 @@ public static Dictionary read(PinotDataBuffer dataBuffer, ColumnMetadata metadat : new BigDecimalDictionary(dataBuffer, length, numBytesPerValue); case STRING: numBytesPerValue = metadata.getColumnMaxLength(); - return loadOnHeap ? new OnHeapStringDictionary(dataBuffer, length, numBytesPerValue) + + // If interning is enabled, get the required interners. + FALFInterner<String> strInterner = null; + FALFInterner<byte[]> byteInterner = null; + Intern internConfig = indexConfig.getIntern(); + if (internConfig != null && !internConfig.isDisabled()) { + Preconditions.checkState(loadOnHeap, "Interning is only supported for on-heap dictionaries."); + DictionaryInternerHolder internerHolder = DictionaryInternerHolder.getInstance(); + strInterner = internerHolder.getStrInterner(internIdentifierStr, internConfig.getCapacity()); + byteInterner = internerHolder.getByteInterner(internIdentifierStr, internConfig.getCapacity()); + LOGGER.info("Enabling interning for dictionary column: {}", columnName); + } + + return loadOnHeap ? new OnHeapStringDictionary(dataBuffer, length, numBytesPerValue, strInterner, byteInterner) Review Comment: Good point. Planned this change in my followup PR for leveraging interning with other onheap dictionaries. ########## pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/dictionary/DictionaryIndexType.java: ########## @@ -308,7 +321,20 @@ public static Dictionary read(PinotDataBuffer dataBuffer, ColumnMetadata metadat : new BigDecimalDictionary(dataBuffer, length, numBytesPerValue); case STRING: numBytesPerValue = metadata.getColumnMaxLength(); - return loadOnHeap ? new OnHeapStringDictionary(dataBuffer, length, numBytesPerValue) + + // If interning is enabled, get the required interners. + FALFInterner<String> strInterner = null; + FALFInterner<byte[]> byteInterner = null; + Intern internConfig = indexConfig.getIntern(); + if (internConfig != null && !internConfig.isDisabled()) { + Preconditions.checkState(loadOnHeap, "Interning is only supported for on-heap dictionaries."); Review Comment: I can add a validation in table config for this. Will do in followup PR. -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org