mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-13 13:07:32 +00:00
[improvement][headless]Deprecate and remove entity-related abstraction and logic.#1876
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package com.tencent.supersonic.headless.api.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -9,7 +8,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -31,9 +29,6 @@ public class DataSetSchema implements Serializable {
|
||||
Optional<SchemaElement> element = Optional.empty();
|
||||
|
||||
switch (elementType) {
|
||||
case ENTITY:
|
||||
element = Optional.ofNullable(entity);
|
||||
break;
|
||||
case DATASET:
|
||||
element = Optional.of(dataSet);
|
||||
break;
|
||||
@@ -55,11 +50,7 @@ public class DataSetSchema implements Serializable {
|
||||
default:
|
||||
}
|
||||
|
||||
if (element.isPresent()) {
|
||||
return element.get();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return element.orElse(null);
|
||||
}
|
||||
|
||||
public Map<String, String> getBizNameToName() {
|
||||
@@ -70,7 +61,7 @@ public class DataSetSchema implements Serializable {
|
||||
SchemaElement::getName, (k1, k2) -> k1));
|
||||
}
|
||||
|
||||
public TimeDefaultConfig getTagTypeTimeDefaultConfig() {
|
||||
public TimeDefaultConfig getDetailTypeTimeDefaultConfig() {
|
||||
if (queryConfig == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -97,38 +88,6 @@ public class DataSetSchema implements Serializable {
|
||||
return queryConfig.getDetailTypeDefaultConfig();
|
||||
}
|
||||
|
||||
public List<SchemaElement> getTagDefaultDimensions() {
|
||||
DetailTypeDefaultConfig detailTypeDefaultConfig = getTagTypeDefaultConfig();
|
||||
if (Objects.isNull(detailTypeDefaultConfig)
|
||||
|| Objects.isNull(detailTypeDefaultConfig.getDefaultDisplayInfo())) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
if (CollectionUtils
|
||||
.isNotEmpty(detailTypeDefaultConfig.getDefaultDisplayInfo().getMetricIds())) {
|
||||
return detailTypeDefaultConfig.getDefaultDisplayInfo().getMetricIds().stream()
|
||||
.map(id -> {
|
||||
SchemaElement metric = getElement(SchemaElementType.METRIC, id);
|
||||
return metric;
|
||||
}).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<SchemaElement> getTagDefaultMetrics() {
|
||||
DetailTypeDefaultConfig detailTypeDefaultConfig = getTagTypeDefaultConfig();
|
||||
if (Objects.isNull(detailTypeDefaultConfig)
|
||||
|| Objects.isNull(detailTypeDefaultConfig.getDefaultDisplayInfo())) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
if (CollectionUtils
|
||||
.isNotEmpty(detailTypeDefaultConfig.getDefaultDisplayInfo().getDimensionIds())) {
|
||||
return detailTypeDefaultConfig.getDefaultDisplayInfo().getDimensionIds().stream()
|
||||
.map(id -> getElement(SchemaElementType.DIMENSION, id)).filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public boolean containsPartitionDimensions() {
|
||||
return dimensions.stream().anyMatch(SchemaElement::isPartitionTime);
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DefaultDisplayInfo implements Serializable {
|
||||
|
||||
// When displaying tag selection results, the information displayed by default
|
||||
private List<Long> dimensionIds = new ArrayList<>();
|
||||
|
||||
private List<Long> metricIds = new ArrayList<>();
|
||||
}
|
||||
@@ -8,8 +8,6 @@ import java.io.Serializable;
|
||||
@Data
|
||||
public class DetailTypeDefaultConfig implements Serializable {
|
||||
|
||||
private DefaultDisplayInfo defaultDisplayInfo;
|
||||
|
||||
// default time to filter tag selection results
|
||||
private TimeDefaultConfig timeDefaultConfig = new TimeDefaultConfig();
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Entity {
|
||||
|
||||
/** uniquely identifies an entity */
|
||||
private Long entityId;
|
||||
|
||||
/** entity name list */
|
||||
private List<String> names;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class EntityInfo implements Serializable {
|
||||
|
||||
private DataSetInfo dataSetInfo = new DataSetInfo();
|
||||
private List<DataInfo> dimensions = new ArrayList<>();
|
||||
private List<DataInfo> metrics = new ArrayList<>();
|
||||
private String entityId;
|
||||
}
|
||||
@@ -18,8 +18,6 @@ public class Identify {
|
||||
|
||||
private String bizName;
|
||||
|
||||
private List<String> entityNames;
|
||||
|
||||
private Integer isCreateDimension = 0;
|
||||
|
||||
public Identify(String name, String type, String bizName) {
|
||||
@@ -28,13 +26,6 @@ public class Identify {
|
||||
this.bizName = bizName;
|
||||
}
|
||||
|
||||
public Identify(String name, String type, String bizName, Integer isCreateDimension) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.bizName = bizName;
|
||||
this.isCreateDimension = isCreateDimension;
|
||||
}
|
||||
|
||||
public String getFieldName() {
|
||||
return bizName;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package com.tencent.supersonic.headless.api.pojo;
|
||||
|
||||
public enum SchemaElementType {
|
||||
DATASET, METRIC, DIMENSION, VALUE, ENTITY, ID, DATE, TAG, TERM
|
||||
DATASET, METRIC, DIMENSION, VALUE, ID, DATE, TAG, TERM
|
||||
}
|
||||
|
||||
@@ -27,15 +27,17 @@ public class SemanticParseInfo implements Serializable {
|
||||
|
||||
private Integer id;
|
||||
private String queryMode = "PLAIN_TEXT";
|
||||
private SchemaElement dataSet;
|
||||
private QueryConfig queryConfig;
|
||||
private QueryType queryType = QueryType.DETAIL;
|
||||
|
||||
private SchemaElement dataSet;
|
||||
private Set<SchemaElement> metrics = Sets.newTreeSet(new SchemaNameLengthComparator());
|
||||
private Set<SchemaElement> dimensions = Sets.newTreeSet(new SchemaNameLengthComparator());
|
||||
private SchemaElement entity;
|
||||
private AggregateTypeEnum aggType = AggregateTypeEnum.NONE;
|
||||
private FilterType filterType = FilterType.AND;
|
||||
private Set<QueryFilter> dimensionFilters = Sets.newHashSet();
|
||||
private Set<QueryFilter> metricFilters = Sets.newHashSet();
|
||||
|
||||
private AggregateTypeEnum aggType = AggregateTypeEnum.NONE;
|
||||
private FilterType filterType = FilterType.AND;
|
||||
private Set<Order> orders = Sets.newHashSet();
|
||||
private DateConf dateInfo;
|
||||
private long limit = DEFAULT_DETAIL_LIMIT;
|
||||
@@ -43,8 +45,6 @@ public class SemanticParseInfo implements Serializable {
|
||||
private List<SchemaElementMatch> elementMatches = Lists.newArrayList();
|
||||
private SqlInfo sqlInfo = new SqlInfo();
|
||||
private SqlEvaluation sqlEvaluation = new SqlEvaluation();
|
||||
private QueryType queryType = QueryType.ID;
|
||||
private EntityInfo entityInfo;
|
||||
private String textInfo;
|
||||
private Map<String, Object> properties = Maps.newHashMap();
|
||||
|
||||
|
||||
@@ -27,9 +27,6 @@ public class SemanticSchema implements Serializable {
|
||||
Optional<SchemaElement> element = Optional.empty();
|
||||
|
||||
switch (elementType) {
|
||||
case ENTITY:
|
||||
element = getElementsById(elementID, getEntities());
|
||||
break;
|
||||
case DATASET:
|
||||
element = getElementsById(elementID, getDataSets());
|
||||
break;
|
||||
@@ -97,17 +94,6 @@ public class SemanticSchema implements Serializable {
|
||||
return getElementsByDataSetId(dataSetId, metrics);
|
||||
}
|
||||
|
||||
public List<SchemaElement> getEntities() {
|
||||
List<SchemaElement> entities = new ArrayList<>();
|
||||
dataSetSchemaList.stream().forEach(d -> entities.add(d.getEntity()));
|
||||
return entities;
|
||||
}
|
||||
|
||||
public List<SchemaElement> getEntities(Long dataSetId) {
|
||||
List<SchemaElement> entities = getEntities();
|
||||
return getElementsByDataSetId(dataSetId, entities);
|
||||
}
|
||||
|
||||
public List<SchemaElement> getTags() {
|
||||
List<SchemaElement> tags = new ArrayList<>();
|
||||
dataSetSchemaList.stream().forEach(d -> tags.addAll(d.getTags()));
|
||||
|
||||
@@ -30,6 +30,6 @@ public class QueryDataSetReq {
|
||||
private List<Filter> metricFilters = new ArrayList<>();
|
||||
private DateConf dateInfo;
|
||||
private Long limit = 2000L;
|
||||
private QueryType queryType = QueryType.ID;
|
||||
private QueryType queryType = QueryType.DETAIL;
|
||||
private boolean innerLayerNative = false;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.tencent.supersonic.common.pojo.enums.QueryType;
|
||||
import com.tencent.supersonic.common.util.ContextUtils;
|
||||
import com.tencent.supersonic.common.util.DateModeUtils;
|
||||
import com.tencent.supersonic.common.util.SqlFilterUtils;
|
||||
import com.tencent.supersonic.headless.api.pojo.SchemaElement;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.jsqlparser.JSQLParserException;
|
||||
@@ -42,6 +43,7 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
public class QueryStructReq extends SemanticQueryReq {
|
||||
|
||||
private List<SchemaElement> dimensions = new ArrayList<>();
|
||||
private List<String> groups = new ArrayList<>();
|
||||
private List<Aggregator> aggregators = new ArrayList<>();
|
||||
private List<Order> orders = new ArrayList<>();
|
||||
@@ -49,7 +51,7 @@ public class QueryStructReq extends SemanticQueryReq {
|
||||
private List<Filter> metricFilters = new ArrayList<>();
|
||||
private DateConf dateInfo;
|
||||
private long limit = Constants.DEFAULT_DETAIL_LIMIT;
|
||||
private QueryType queryType = QueryType.ID;
|
||||
private QueryType queryType = QueryType.DETAIL;
|
||||
private boolean convertToSql = true;
|
||||
|
||||
public List<String> getGroups() {
|
||||
|
||||
@@ -19,19 +19,4 @@ public class DataSetSchemaResp extends DataSetResp {
|
||||
private List<ModelResp> modelResps = Lists.newArrayList();
|
||||
private List<TermResp> termResps = Lists.newArrayList();
|
||||
|
||||
public DimSchemaResp getPrimaryKey() {
|
||||
for (ModelResp modelResp : modelResps) {
|
||||
Identify identify = modelResp.getPrimaryIdentify();
|
||||
if (identify == null) {
|
||||
continue;
|
||||
}
|
||||
for (DimSchemaResp dimension : dimensions) {
|
||||
if (identify.getBizName().equals(dimension.getBizName())) {
|
||||
dimension.setEntityAlias(identify.getEntityNames());
|
||||
return dimension;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,21 +62,6 @@ public class ModelResp extends SchemaItem {
|
||||
return isOpen != null && isOpen == 1;
|
||||
}
|
||||
|
||||
public Identify getPrimaryIdentify() {
|
||||
if (modelDetail == null) {
|
||||
return null;
|
||||
}
|
||||
if (CollectionUtils.isEmpty(modelDetail.getIdentifiers())) {
|
||||
return null;
|
||||
}
|
||||
for (Identify identify : modelDetail.getIdentifiers()) {
|
||||
if (!CollectionUtils.isEmpty(identify.getEntityNames())) {
|
||||
return identify;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Dim> getTimeDimension() {
|
||||
if (modelDetail == null) {
|
||||
return Lists.newArrayList();
|
||||
|
||||
Reference in New Issue
Block a user