Skip to content

Commit

Permalink
fix: fix index problem of metadata (#788)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsy1001de authored Jan 29, 2024
1 parent 634e4bc commit 52f68c8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public void doManage() {
}
response.setSuccess(false);
response.setMessage(t.getMessage());
result.setData(response);
JsonResult.fillFailResultTo(result, t.getMessage());
}
}
Expand Down Expand Up @@ -198,6 +199,7 @@ public void doManage() {
}
response.setSuccess(false);
response.setMessage(t.getMessage());
result.setData(response);
JsonResult.fillFailResultTo(result, t.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
*/
package io.holoinsight.server.meta.core.common;

import java.util.*;
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.google.common.collect.Maps;
import io.holoinsight.server.common.J;
import io.holoinsight.server.meta.common.model.QueryExample;
Expand All @@ -18,10 +11,20 @@
import io.holoinsight.server.meta.core.service.bitmap.condition.OrCondition;
import org.springframework.util.CollectionUtils;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static io.holoinsight.server.meta.common.util.ConstModel.default_app;
import static io.holoinsight.server.meta.common.util.ConstModel.default_hostname;
import static io.holoinsight.server.meta.common.util.ConstModel.default_ip;
import static io.holoinsight.server.meta.core.service.bitmap.BitmapDataCoreService.UK_FIELD;

/**
* @author jinyan.ljw
Expand All @@ -45,7 +48,7 @@ public static MetaCondition buildDimCondition(QueryExample queryExample,
andCondition.setAll(true);
} else {
filters.forEach((type, entries) -> {
type = type.contains(".") ? type.split("\\.")[0] : type;
// type = type.contains(".") ? type.split("\\.")[0] : type;
if (REGEX_FILTERS_KEY.equals(type)) {
entries.forEach((k, v) -> {
AndCondition andCondition = orCondition.and();
Expand Down Expand Up @@ -161,13 +164,15 @@ public static <R> List<R> filterData(Collection<Map<String, Object>> items,

private static Object getRealVal(String key, Map<String, Object> map) {
if (key.contains(".")) {
String[] eqItemKeys = key.split("\\.");
Object value0 = map.get(eqItemKeys[0]);
int doxIndex = key.indexOf('.');
String firstKey = key.substring(0, doxIndex);
String secondKey = key.substring(doxIndex + 1);
Object value0 = map.get(firstKey);
if (Objects.isNull(value0)) {
return null;
}
Map<String, Object> keyItem = (Map<String, Object>) value0;
return keyItem.get(eqItemKeys[1]);
return keyItem.get(secondKey);
} else {
return map.get(key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,26 @@ private String buildIndex(List<String> indexKeys, Map<String, Object> metaRows)
StringBuilder builder = new StringBuilder();
boolean containAllKeys = true;
for (String key : indexKeys) {
Object value = metaRows.get(key);
Object value;
// 支持两层 key 索引
if (key.contains(".")) {
int doxIndex = key.indexOf('.');
String firstKey = key.substring(0, doxIndex);
String secondKey = key.substring(doxIndex + 1);
Object o = metaRows.get(firstKey);
if (Objects.isNull(o)) {
value = null;
} else {
Map<String, Object> map = J.toMap(J.toJson(o));
if (null == map) {
value = null;
} else {
value = map.get(secondKey);
}
}
} else {
value = metaRows.get(key);
}
if (Objects.isNull(value)) {
containAllKeys = false;
builder.append(EMPTY_VALUE);
Expand Down

0 comments on commit 52f68c8

Please sign in to comment.