mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-14 22:25:19 +00:00
(improvement)(Headless) Abstracted tags from dimensions and metrics. (#828)
This commit is contained in:
@@ -9,13 +9,11 @@ import java.util.Set;
|
||||
|
||||
@Data
|
||||
public class DataSetSchema {
|
||||
|
||||
private SchemaElement dataSet;
|
||||
private Set<SchemaElement> metrics = new HashSet<>();
|
||||
private Set<SchemaElement> dimensions = new HashSet<>();
|
||||
private Set<SchemaElement> dimensionValues = new HashSet<>();
|
||||
private Set<SchemaElement> tags = new HashSet<>();
|
||||
private Set<SchemaElement> tagValues = new HashSet<>();
|
||||
private Set<SchemaElement> dimensionValues = new HashSet<>();
|
||||
private SchemaElement entity = new SchemaElement();
|
||||
private QueryConfig queryConfig;
|
||||
private QueryType queryType;
|
||||
@@ -42,9 +40,6 @@ public class DataSetSchema {
|
||||
case TAG:
|
||||
element = tags.stream().filter(e -> e.getId() == elementID).findFirst();
|
||||
break;
|
||||
case TAG_VALUE:
|
||||
element = tagValues.stream().filter(e -> e.getId() == elementID).findFirst();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,7 @@ public enum SchemaElementType {
|
||||
DIMENSION,
|
||||
VALUE,
|
||||
ENTITY,
|
||||
TAG,
|
||||
TAG_VALUE,
|
||||
ID,
|
||||
DATE
|
||||
DATE,
|
||||
TAG
|
||||
}
|
||||
|
||||
@@ -44,9 +44,6 @@ public class SemanticSchema implements Serializable {
|
||||
case TAG:
|
||||
element = getElementsById(elementID, getTags());
|
||||
break;
|
||||
case TAG_VALUE:
|
||||
element = getElementsById(elementID, getTagValues());
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
@@ -85,28 +82,6 @@ public class SemanticSchema implements Serializable {
|
||||
return dimension.orElse(null);
|
||||
}
|
||||
|
||||
public List<SchemaElement> getTags() {
|
||||
List<SchemaElement> tags = new ArrayList<>();
|
||||
dataSetSchemaList.stream().forEach(d -> tags.addAll(d.getTags()));
|
||||
return tags;
|
||||
}
|
||||
|
||||
public List<SchemaElement> getTags(Long dataSetId) {
|
||||
List<SchemaElement> tags = getTags();
|
||||
return getElementsByDataSetId(dataSetId, tags);
|
||||
}
|
||||
|
||||
public List<SchemaElement> getTagValues() {
|
||||
List<SchemaElement> tags = new ArrayList<>();
|
||||
dataSetSchemaList.stream().forEach(d -> tags.addAll(d.getTagValues()));
|
||||
return tags;
|
||||
}
|
||||
|
||||
public List<SchemaElement> getTagValues(Long dataSetId) {
|
||||
List<SchemaElement> tags = getTagValues();
|
||||
return getElementsByDataSetId(dataSetId, tags);
|
||||
}
|
||||
|
||||
public List<SchemaElement> getMetrics() {
|
||||
List<SchemaElement> metrics = new ArrayList<>();
|
||||
dataSetSchemaList.stream().forEach(d -> metrics.addAll(d.getMetrics()));
|
||||
@@ -129,6 +104,20 @@ public class SemanticSchema implements Serializable {
|
||||
return getElementsByDataSetId(dataSetId, entities);
|
||||
}
|
||||
|
||||
public List<SchemaElement> getTags() {
|
||||
List<SchemaElement> tags = new ArrayList<>();
|
||||
dataSetSchemaList.stream().forEach(d -> tags.addAll(d.getTags()));
|
||||
return tags;
|
||||
}
|
||||
|
||||
public List<SchemaElement> getTags(Long dataSetId) {
|
||||
List<SchemaElement> tags = new ArrayList<>();
|
||||
dataSetSchemaList.stream().filter(schemaElement ->
|
||||
dataSetId.equals(schemaElement.getDataSet().getDataSet()))
|
||||
.forEach(d -> tags.addAll(d.getTags()));
|
||||
return tags;
|
||||
}
|
||||
|
||||
private List<SchemaElement> getElementsByDataSetId(Long dataSetId, List<SchemaElement> elements) {
|
||||
return elements.stream()
|
||||
.filter(schemaElement -> dataSetId.equals(schemaElement.getDataSet()))
|
||||
|
||||
@@ -11,7 +11,7 @@ import javax.validation.constraints.NotNull;
|
||||
@ToString
|
||||
public class ItemValueReq {
|
||||
|
||||
private SchemaElementType type = SchemaElementType.TAG;
|
||||
private SchemaElementType type;
|
||||
|
||||
@NotNull
|
||||
private Long itemId;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.tencent.supersonic.headless.api.pojo.response;
|
||||
|
||||
import static com.tencent.supersonic.common.pojo.Constants.DICT_VALUE;
|
||||
import static com.tencent.supersonic.common.pojo.Constants.UNDERLINE;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
|
||||
@@ -32,10 +31,8 @@ public class DictItemResp {
|
||||
@NotNull
|
||||
private StatusEnum status;
|
||||
|
||||
public String generateNature() {
|
||||
return UNDERLINE + modelId + UNDERLINE + itemId + UNDERLINE + type.name().toLowerCase().substring(0, 1)
|
||||
+ DICT_VALUE;
|
||||
|
||||
public String getNature() {
|
||||
return UNDERLINE + modelId + UNDERLINE + itemId;
|
||||
}
|
||||
|
||||
public String fetchDictFileName() {
|
||||
|
||||
@@ -27,4 +27,5 @@ public class MeasureResp {
|
||||
|
||||
private Long modelId;
|
||||
|
||||
private int isTag;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user