未验证 提交 2b386ce0 编写于 作者: wu-sheng's avatar wu-sheng 提交者: GitHub

Add ModelColumn#shouldIndex method (#8853)

上级 6d9decdd
......@@ -49,15 +49,13 @@ public @interface Column {
int defaultValue() default 0;
/**
* The column is just saved, never used in query.
* The column is just saved, never used as a query condition.
*/
boolean storageOnly() default false;
/**
* The column(field) is just indexed, never stored. Note: this feature only supported by elasticsearch and don't
* support mappings update due to ElasticSearch server's limitation.
*
* NOTICE, metrics should not use this, as the OAP core merges indices of metrics automatically.
* The column(field) is just indexed, never stored(not available in query projection).
* Note: this feature only supported by elasticsearch.
*/
boolean indexOnly() default false;
......@@ -66,7 +64,7 @@ public @interface Column {
* storage implementation.
*
* Notice, different lengths may cause different types. Such as, over 16383 would make the type in MySQL to be
* MEDIUMTEXT, due to database varchar max=16383
* MEDIUMTEXT, due to database varchar max=16383.
* @since 7.1.0
*/
int length() default 200;
......
......@@ -99,4 +99,11 @@ public class ModelColumn {
this.indexOnly = indexOnly;
this.banyanDBExtension = banyanDBExtension;
}
/**
* @return true means this column should be indexed, as it would be a query condition.
*/
public boolean shouldIndex() {
return !storageOnly;
}
}
......@@ -76,7 +76,7 @@ public class MySQLTableInstaller extends H2TableInstaller {
Model model) throws JDBCClientException {
int indexSeq = 0;
for (final ModelColumn modelColumn : model.getColumns()) {
if (!modelColumn.isStorageOnly() && modelColumn.getLength() < 256) {
if (modelColumn.shouldIndex() && modelColumn.getLength() < 256) {
final Class<?> type = modelColumn.getType();
if (List.class.isAssignableFrom(type)) {
for (int i = 0; i < maxSizeOfArrayColumn; i++) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册