Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support creating dictionary at runtime for an existing column #9678

Merged
merged 5 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -416,15 +416,11 @@ void buildIndexCreationInfo()
String columnName = fieldSpec.getName();
DataType storedType = fieldSpec.getDataType().getStoredType();
ColumnStatistics columnProfile = _segmentStats.getColumnProfileFor(columnName);
boolean useVarLengthDictionary = varLengthDictionaryColumns.contains(columnName);
boolean useVarLengthDictionary =
varLengthDictionaryColumns.contains(columnName) || shouldUseVarLengthDictionary(storedType, columnProfile);
Object defaultNullValue = fieldSpec.getDefaultNullValue();
if (storedType == DataType.BYTES || storedType == DataType.BIG_DECIMAL) {
if (!columnProfile.isFixedLength()) {
useVarLengthDictionary = true;
}
if (storedType == DataType.BYTES) {
defaultNullValue = new ByteArray((byte[]) defaultNullValue);
}
if (storedType == DataType.BYTES) {
defaultNullValue = new ByteArray((byte[]) defaultNullValue);
}
boolean createDictionary = !rawIndexCreationColumns.contains(columnName)
&& !rawIndexCompressionTypeKeys.contains(columnName);
Expand All @@ -435,6 +431,19 @@ void buildIndexCreationInfo()
_segmentIndexCreationInfo.setTotalDocs(_totalDocs);
}

/**
* Uses the column properties like storedType and length of elements to determine if varLengthDictionary should be
* used.
*/
public static boolean shouldUseVarLengthDictionary(DataType columnStoredType, ColumnStatistics columnProfile) {
if (columnStoredType == DataType.BYTES || columnStoredType == DataType.BIG_DECIMAL) {
if (!columnProfile.isFixedLength()) {
return true;
}
}
return false;
}

/**
* Returns the name of the segment associated with this index creation driver.
*/
Expand Down
Loading