Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
41 changes: 27 additions & 14 deletions fe/fe-core/src/main/java/org/apache/doris/analysis/IndexDef.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,17 @@ public class IndexDef {
private boolean isBuildDeferred = false;
private PartitionNames partitionNames;
private List<Integer> columnUniqueIds = Lists.newArrayList();
private static final int MIN_NGRAM_SIZE = 1;
private static final int MAX_NGRAM_SIZE = 255;
private static final int MIN_BF_SIZE = 64;
private static final int MAX_BF_SIZE = 65535;

public static final String NGRAM_SIZE_KEY = "gram_size";
public static final String NGRAM_BF_SIZE_KEY = "bf_size";
public static final String DEFAULT_NGRAM_SIZE = "2";
public static final String DEFAULT_NGRAM_BF_SIZE = "256";


public IndexDef(String indexName, boolean ifNotExists, List<String> columns, IndexType indexType,
Map<String, String> properties, String comment) {
this.indexName = indexName;
Expand Down Expand Up @@ -238,8 +243,8 @@ public void checkColumn(Column column, KeysType keysType, boolean enableUniqueKe
throw new AnalysisException("index should only be used in columns of DUP_KEYS/UNIQUE_KEYS table"
+ " or key columns of AGG_KEYS table. invalid index: " + indexName);
} else if (keysType == KeysType.UNIQUE_KEYS && !enableUniqueKeyMergeOnWrite
&& indexType == IndexType.INVERTED && properties != null
&& properties.containsKey(InvertedIndexUtil.INVERTED_INDEX_PARSER_KEY)) {
&& indexType == IndexType.INVERTED && properties != null
&& properties.containsKey(InvertedIndexUtil.INVERTED_INDEX_PARSER_KEY)) {
throw new AnalysisException("INVERTED index with parser can NOT be used in value columns of"
+ " UNIQUE_KEYS table with merge_on_write disable. invalid index: " + indexName);
}
Expand All @@ -256,21 +261,29 @@ public void checkColumn(Column column, KeysType keysType, boolean enableUniqueKe
if (properties.size() != 2) {
throw new AnalysisException("ngram_bf index should have gram_size and bf_size properties");
}
try {
int ngramSize = Integer.parseInt(properties.get(NGRAM_SIZE_KEY));
int bfSize = Integer.parseInt(properties.get(NGRAM_BF_SIZE_KEY));
if (ngramSize > 256 || ngramSize < 1) {
throw new AnalysisException("gram_size should be integer and less than 256");
}
if (bfSize > 65535 || bfSize < 64) {
throw new AnalysisException("bf_size should be integer and between 64 and 65535");
}
} catch (NumberFormatException e) {
throw new AnalysisException("invalid ngram properties:" + e.getMessage(), e);
}

parseAndValidateProperty(properties, NGRAM_SIZE_KEY, MIN_NGRAM_SIZE, MAX_NGRAM_SIZE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to modify IndexDefinition.java

parseAndValidateProperty(properties, NGRAM_BF_SIZE_KEY, MIN_BF_SIZE, MAX_BF_SIZE);
}
} else {
throw new AnalysisException("Unsupported index type: " + indexType);
}
}

private void parseAndValidateProperty(Map<String, String> properties, String key, int minValue, int maxValue)
throws AnalysisException {
String valueStr = properties.get(key);
if (valueStr == null) {
throw new AnalysisException("Property '" + key + "' is missing.");
}
try {
int value = Integer.parseInt(valueStr);
if (value < minValue || value > maxValue) {
throw new AnalysisException("'" + key + "' should be an integer between "
+ minValue + " and " + maxValue + ".");
}
} catch (NumberFormatException e) {
throw new AnalysisException("Invalid value for '" + key + "': " + valueStr, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,9 @@ public static Set<String> analyzeBloomFilterColumns(Map<String, String> properti
}

String[] bfColumnArr = bfColumnsStr.split(COMMA_SEPARATOR);
if (bfColumnArr.length == 0) {
return bfColumns;
}
Set<String> bfColumnSet = Sets.newTreeSet(String.CASE_INSENSITIVE_ORDER);
for (String bfColumn : bfColumnArr) {
bfColumn = bfColumn.trim();
Expand Down
Loading
Loading