diff --git a/server/meta/meta-common/src/main/java/io/holoinsight/server/meta/common/util/ConstModel.java b/server/meta/meta-common/src/main/java/io/holoinsight/server/meta/common/util/ConstModel.java index 9a7450e76..cdbad3f58 100644 --- a/server/meta/meta-common/src/main/java/io/holoinsight/server/meta/common/util/ConstModel.java +++ b/server/meta/meta-common/src/main/java/io/holoinsight/server/meta/common/util/ConstModel.java @@ -10,7 +10,6 @@ */ public class ConstModel { - public static final String default_id = "_id"; public static final String default_pk = "_uk"; public static final String default_type = "_type"; public static final String default_ip = "ip"; @@ -20,11 +19,7 @@ public class ConstModel { public static final String default_modifier = "_modifier"; public static final String default_status = "_status"; public static final String default_modified = "_modified"; - public static final String default_basic = "_basic"; - public static final String default_annotation = "_annotation"; - public static final String default_label = "_label"; - public static final String READ_MYSQL_ENABLE = "readMysqlEnable"; - public static final String WRITE_MYSQL_ENABLE = "writeMysqlEnable"; + public static final String default_label = "labels"; public static final String META_CONFIG = "meta_config"; public static final String ANNOTATIONS = "annotations"; public static final String META_INDEX_CONFIG = "meta_index_config"; diff --git a/server/meta/meta-core/src/main/java/io/holoinsight/server/meta/core/service/bitmap/AbstractMetaData.java b/server/meta/meta-core/src/main/java/io/holoinsight/server/meta/core/service/bitmap/AbstractMetaData.java index d2ab05ac0..7a217b3aa 100644 --- a/server/meta/meta-core/src/main/java/io/holoinsight/server/meta/core/service/bitmap/AbstractMetaData.java +++ b/server/meta/meta-core/src/main/java/io/holoinsight/server/meta/core/service/bitmap/AbstractMetaData.java @@ -4,6 +4,7 @@ package io.holoinsight.server.meta.core.service.bitmap; +import io.holoinsight.server.meta.common.util.ConstModel; import io.holoinsight.server.meta.core.common.DimForkJoinPool; import lombok.Data; import lombok.extern.slf4j.Slf4j; @@ -269,12 +270,21 @@ protected void deleteOneRow(MetaDataRow deleteLog) { idRowsMap.remove(deleteLog.getId()); } + @SuppressWarnings("unchecked") private void fillColsMapWithLabels(Map colsMap, List rows) { DimForkJoinPool.get().submit(() -> rows.parallelStream().forEach(row -> { - Map labelMap = row.getValues(); - if (labelMap != null) { - labelMap - .forEach((k, v) -> colsMap.putIfAbsent(k, new MetaColData(this.tableName, k, this))); + Map jsonMap = row.getValues(); + if (jsonMap != null) { + jsonMap.forEach((k, v) -> colsMap.putIfAbsent(k, new MetaColData(this.tableName, k, this))); + if (jsonMap.containsKey(ConstModel.default_label) + && jsonMap.get(ConstModel.default_label) instanceof Map) { + Map lableMap = + (Map) jsonMap.get(ConstModel.default_label); + if (null != lableMap) { + lableMap.forEach((k, v) -> colsMap.putIfAbsent(ConstModel.default_label + "." + k, + new MetaColData(this.tableName, ConstModel.default_label + "." + k, this))); + } + } } })).join(); log.info("fill cols with labels, rows={}, cols={}", CollectionUtils.size(rows), diff --git a/server/meta/meta-core/src/main/java/io/holoinsight/server/meta/core/service/bitmap/MetaColData.java b/server/meta/meta-core/src/main/java/io/holoinsight/server/meta/core/service/bitmap/MetaColData.java index 8673221ee..6574e5fbc 100644 --- a/server/meta/meta-core/src/main/java/io/holoinsight/server/meta/core/service/bitmap/MetaColData.java +++ b/server/meta/meta-core/src/main/java/io/holoinsight/server/meta/core/service/bitmap/MetaColData.java @@ -5,6 +5,7 @@ package io.holoinsight.server.meta.core.service.bitmap; import com.googlecode.javaewah.EWAHCompressedBitmap; +import io.holoinsight.server.meta.common.util.ConstModel; import io.holoinsight.server.meta.core.common.DimForkJoinPool; import lombok.Getter; import lombok.Setter; @@ -58,21 +59,21 @@ public MetaColData(String tableName, String colName, Map fuzzyGetBitmap(String targetVal, boolean isReg * 懒加载 */ public void lazyLoad() { - if (loaded.get() == false) { + if (!loaded.get()) { synchronized (metaData) { - if (loaded.get() == false) { + if (!loaded.get()) { StopWatch stopWatch = StopWatch.createStarted(); log.info( "MetaColData lazy load start, table={}, col={}, size={}, logSize={}, valSize={}.", @@ -129,9 +130,19 @@ public void lazyLoad() { * * @param changeLogs */ + @SuppressWarnings("unchecked") public void appendLogs(List changeLogs) { changeLogs.forEach(changeLog -> { - Object changeColVal = changeLog.getValues().get(colName); + Object changeColVal = null; + if (colName.startsWith(ConstModel.default_label + ".")) { + Object labels = changeLog.getValues().get(ConstModel.default_label); + if (labels instanceof Map) { + String labelCol = colName.substring(ConstModel.default_label.length() + 1); + changeColVal = ((Map) labels).get(labelCol); + } + } else { + changeColVal = changeLog.getValues().get(colName); + } if (changeColVal == null) { changeColVal = "null"; }