(improvement)(knowledge) ModelSchema add tag type element (#419)

Co-authored-by: jolunoluo
This commit is contained in:
LXW
2023-11-24 17:52:30 +08:00
committed by GitHub
parent aa433baa06
commit d79e30cd7a
3 changed files with 22 additions and 4 deletions

View File

@@ -13,6 +13,8 @@ public class ModelSchema {
private Set<SchemaElement> metrics = new HashSet<>(); private Set<SchemaElement> metrics = new HashSet<>();
private Set<SchemaElement> dimensions = new HashSet<>(); private Set<SchemaElement> dimensions = new HashSet<>();
private Set<SchemaElement> dimensionValues = new HashSet<>(); private Set<SchemaElement> dimensionValues = new HashSet<>();
private Set<SchemaElement> tags = new HashSet<>();
@Deprecated
private SchemaElement entity = new SchemaElement(); private SchemaElement entity = new SchemaElement();
public SchemaElement getElement(SchemaElementType elementType, long elementID) { public SchemaElement getElement(SchemaElementType elementType, long elementID) {

View File

@@ -7,5 +7,6 @@ public enum SchemaElementType {
VALUE, VALUE,
ENTITY, ENTITY,
ID, ID,
DATE DATE,
TAG
} }

View File

@@ -13,6 +13,9 @@ import com.tencent.supersonic.semantic.api.model.pojo.SchemaItem;
import com.tencent.supersonic.semantic.api.model.response.DimSchemaResp; import com.tencent.supersonic.semantic.api.model.response.DimSchemaResp;
import com.tencent.supersonic.semantic.api.model.response.MetricSchemaResp; import com.tencent.supersonic.semantic.api.model.response.MetricSchemaResp;
import com.tencent.supersonic.semantic.api.model.response.ModelSchemaResp; import com.tencent.supersonic.semantic.api.model.response.ModelSchemaResp;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
@@ -21,9 +24,6 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;
public class ModelSchemaBuilder { public class ModelSchemaBuilder {
@@ -62,6 +62,7 @@ public class ModelSchemaBuilder {
Set<SchemaElement> dimensions = new HashSet<>(); Set<SchemaElement> dimensions = new HashSet<>();
Set<SchemaElement> dimensionValues = new HashSet<>(); Set<SchemaElement> dimensionValues = new HashSet<>();
Set<SchemaElement> tags = new HashSet<>();
for (DimSchemaResp dim : resp.getDimensions()) { for (DimSchemaResp dim : resp.getDimensions()) {
List<String> alias = SchemaItem.getAliasList(dim.getAlias()); List<String> alias = SchemaItem.getAliasList(dim.getAlias());
@@ -105,9 +106,23 @@ public class ModelSchemaBuilder {
.alias(new ArrayList<>(Arrays.asList(dimValueAlias.toArray(new String[0])))) .alias(new ArrayList<>(Arrays.asList(dimValueAlias.toArray(new String[0]))))
.build(); .build();
dimensionValues.add(dimValueToAdd); dimensionValues.add(dimValueToAdd);
if (dim.getIsTag() == 1) {
SchemaElement tagToAdd = SchemaElement.builder()
.model(resp.getId())
.id(dim.getId())
.name(dim.getName())
.bizName(dim.getBizName())
.type(SchemaElementType.TAG)
.useCnt(dim.getUseCnt())
.alias(alias)
.schemaValueMaps(schemaValueMaps)
.build();
tags.add(tagToAdd);
}
} }
modelSchema.getDimensions().addAll(dimensions); modelSchema.getDimensions().addAll(dimensions);
modelSchema.getDimensionValues().addAll(dimensionValues); modelSchema.getDimensionValues().addAll(dimensionValues);
modelSchema.getTags().addAll(tags);
Entity entity = resp.getEntity(); Entity entity = resp.getEntity();
if (Objects.nonNull(entity)) { if (Objects.nonNull(entity)) {