You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2022/04/12 02:39:40 UTC
[skywalking] branch master updated: Add ModelColumn#shouldIndex method (#8853)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new 2b386ce02b Add ModelColumn#shouldIndex method (#8853)
2b386ce02b is described below
commit 2b386ce02bfd68319d75c4aa7b5559055337497c
Author: 吴晟 Wu Sheng <wu...@foxmail.com>
AuthorDate: Tue Apr 12 10:39:25 2022 +0800
Add ModelColumn#shouldIndex method (#8853)
---
.../skywalking/oap/server/core/storage/annotation/Column.java | 10 ++++------
.../skywalking/oap/server/core/storage/model/ModelColumn.java | 7 +++++++
.../server/storage/plugin/jdbc/mysql/MySQLTableInstaller.java | 2 +-
3 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/annotation/Column.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/annotation/Column.java
index 44d2305024..ac150b9b59 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/annotation/Column.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/annotation/Column.java
@@ -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;
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/ModelColumn.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/ModelColumn.java
index b5dbfbe739..6110254568 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/ModelColumn.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/ModelColumn.java
@@ -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;
+ }
}
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLTableInstaller.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLTableInstaller.java
index cd4b4da0d7..f37c7a7e8b 100644
--- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLTableInstaller.java
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLTableInstaller.java
@@ -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++) {