[feature](index) Replace BITMAP INDEX with INVERTED INDEX (#30950)

This commit is contained in:
Kang
2024-02-08 22:33:13 +08:00
committed by yiguolei
parent eaaab33f0a
commit ce892d04e5
66 changed files with 102 additions and 562 deletions

View File

@ -55,7 +55,7 @@ public class IndexDef {
this.ifNotExists = ifNotExists;
this.columns = columns;
if (indexType == null) {
this.indexType = IndexType.BITMAP;
this.indexType = IndexType.INVERTED;
} else {
this.indexType = indexType;
}
@ -222,18 +222,14 @@ public class IndexDef {
|| colType.isFixedPointType() || colType.isStringType() || colType == PrimitiveType.BOOLEAN
|| colType.isVariantType())) {
throw new AnalysisException(colType + " is not supported in " + indexType.toString() + " index. "
+ "invalid column: " + indexColName);
} else if (indexType == IndexType.INVERTED
&& ((keysType == KeysType.AGG_KEYS && !column.isKey())
|| (keysType == KeysType.UNIQUE_KEYS && !enableUniqueKeyMergeOnWrite))) {
+ "invalid index: " + indexName);
}
if (!column.isKey()
&& ((keysType == KeysType.UNIQUE_KEYS && !enableUniqueKeyMergeOnWrite)
|| keysType == KeysType.AGG_KEYS)) {
throw new AnalysisException(indexType.toString()
+ " index only used in columns of DUP_KEYS table"
+ " or UNIQUE_KEYS table with merge_on_write enabled"
+ " or key columns of AGG_KEYS table. invalid column: " + indexColName);
} else if (keysType == KeysType.AGG_KEYS && !column.isKey() && indexType != IndexType.INVERTED) {
throw new AnalysisException(indexType.toString()
+ " index only used in columns of DUP_KEYS/UNIQUE_KEYS table or key columns of"
+ " AGG_KEYS table. invalid column: " + indexColName);
+ " index only used in columns of DUP_KEYS/UNIQUE_KEYS MOW table or key columns of all table."
+ " invalid index: " + indexName);
}
if (indexType == IndexType.INVERTED) {
@ -243,10 +239,6 @@ public class IndexDef {
&& colType != PrimitiveType.STRING) {
throw new AnalysisException(colType + " is not supported in ngram_bf index. "
+ "invalid column: " + indexColName);
} else if ((keysType == KeysType.AGG_KEYS && !column.isKey())) {
throw new AnalysisException(
"ngram_bf index only used in columns of DUP_KEYS/UNIQUE_KEYS table or key columns of"
+ " AGG_KEYS table. invalid column: " + indexColName);
}
if (properties.size() != 2) {
throw new AnalysisException("ngram_bf index should have gram_size and bf_size properties");

View File

@ -2527,6 +2527,10 @@ public class LogicalPlanBuilder extends DorisParserBaseVisitor<Object> {
Map<String, String> properties = visitPropertyItemList(ctx.properties);
String indexType = ctx.indexType != null ? ctx.indexType.getText().toUpperCase() : null;
String comment = ctx.comment != null ? ctx.comment.getText() : "";
// change BITMAP index to INVERTED index
if (indexType.equalsIgnoreCase("BITMAP")) {
indexType = "INVERTED";
}
return new IndexDefinition(indexName, indexCols, indexType, properties, comment);
}

View File

@ -58,7 +58,7 @@ public class IndexDefinition {
Map<String, String> properties, String comment) {
this.name = name;
this.cols = Utils.copyRequiredList(cols);
this.indexType = IndexType.BITMAP;
this.indexType = IndexType.INVERTED;
if (indexTypeName != null) {
switch (indexTypeName) {
case "BITMAP": {
@ -108,19 +108,14 @@ public class IndexDefinition {
|| colType.isBooleanType())) {
// TODO add colType.isVariantType() and colType.isAggState()
throw new AnalysisException(colType + " is not supported in " + indexType.toString()
+ " index. " + "invalid column: " + indexColName);
} else if (indexType == IndexType.INVERTED && ((keysType == KeysType.AGG_KEYS
&& !column.isKey())
|| (keysType == KeysType.UNIQUE_KEYS && !enableUniqueKeyMergeOnWrite))) {
+ " index. " + "invalid index: " + name);
}
if (!column.isKey()
&& ((keysType == KeysType.UNIQUE_KEYS && !enableUniqueKeyMergeOnWrite)
|| keysType == KeysType.AGG_KEYS)) {
throw new AnalysisException(indexType.toString()
+ " index only used in columns of DUP_KEYS table"
+ " or UNIQUE_KEYS table with merge_on_write enabled"
+ " or key columns of AGG_KEYS table. invalid column: " + indexColName);
} else if (keysType == KeysType.AGG_KEYS && !column.isKey()
&& indexType != IndexType.INVERTED) {
throw new AnalysisException(indexType.toString()
+ " index only used in columns of DUP_KEYS/UNIQUE_KEYS table or key columns of"
+ " AGG_KEYS table. invalid column: " + indexColName);
+ " index only used in columns of DUP_KEYS/UNIQUE_KEYS MOW table or key columns of all table."
+ " invalid index: " + name);
}
if (indexType == IndexType.INVERTED) {
@ -134,10 +129,6 @@ public class IndexDefinition {
if (!colType.isStringLikeType()) {
throw new AnalysisException(colType + " is not supported in ngram_bf index. "
+ "invalid column: " + indexColName);
} else if ((keysType == KeysType.AGG_KEYS && !column.isKey())) {
throw new AnalysisException(
"ngram_bf index only used in columns of DUP_KEYS/UNIQUE_KEYS table or key columns of"
+ " AGG_KEYS table. invalid column: " + indexColName);
}
if (properties.size() != 2) {
throw new AnalysisException(