mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-04-19 04:44:19 +08:00
Support limit (#1688)
This commit is contained in:
@@ -9,4 +9,6 @@ public class MetricTypeDefaultConfig {
|
||||
|
||||
private TimeDefaultConfig timeDefaultConfig =
|
||||
new TimeDefaultConfig(7, Constants.DAY, TimeMode.RECENT);
|
||||
|
||||
private Long limit;
|
||||
}
|
||||
|
||||
@@ -14,14 +14,19 @@ import lombok.Data;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.tencent.supersonic.common.pojo.Constants.DEFAULT_DETAIL_LIMIT;
|
||||
import static com.tencent.supersonic.common.pojo.Constants.DEFAULT_METRIC_LIMIT;
|
||||
|
||||
@Data
|
||||
public class SemanticParseInfo {
|
||||
|
||||
private Integer id;
|
||||
private String queryMode = "PLAIN_TEXT";
|
||||
private SchemaElement dataSet;
|
||||
private QueryConfig queryConfig;
|
||||
private Set<SchemaElement> metrics = Sets.newTreeSet(new SchemaNameLengthComparator());
|
||||
private Set<SchemaElement> dimensions = Sets.newTreeSet(new SchemaNameLengthComparator());
|
||||
private SchemaElement entity;
|
||||
@@ -68,4 +73,24 @@ public class SemanticParseInfo {
|
||||
}
|
||||
return dataSet.getDataSetId();
|
||||
}
|
||||
|
||||
public Long getDetailLimit() {
|
||||
Long limit = DEFAULT_DETAIL_LIMIT;
|
||||
if (Objects.nonNull(queryConfig)
|
||||
&& Objects.nonNull(queryConfig.getTagTypeDefaultConfig())
|
||||
&& Objects.nonNull(queryConfig.getTagTypeDefaultConfig().getLimit())) {
|
||||
limit = queryConfig.getTagTypeDefaultConfig().getLimit();
|
||||
}
|
||||
return limit;
|
||||
}
|
||||
|
||||
public Long getMetricLimit() {
|
||||
Long limit = DEFAULT_METRIC_LIMIT;
|
||||
if (Objects.nonNull(queryConfig)
|
||||
&& Objects.nonNull(queryConfig.getMetricTypeDefaultConfig())
|
||||
&& Objects.nonNull(queryConfig.getMetricTypeDefaultConfig().getLimit())) {
|
||||
limit = queryConfig.getMetricTypeDefaultConfig().getLimit();
|
||||
}
|
||||
return limit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -151,6 +152,20 @@ public class SemanticSchema implements Serializable {
|
||||
return getElementsById(dataSetId, dataSets).orElse(null);
|
||||
}
|
||||
|
||||
public QueryConfig getQueryConfig(Long dataSetId) {
|
||||
DataSetSchema first =
|
||||
dataSetSchemaList.stream()
|
||||
.filter(
|
||||
dataSetSchema ->
|
||||
dataSetId.equals(dataSetSchema.getDataSet().getDataSetId()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (Objects.nonNull(first)) {
|
||||
return first.getQueryConfig();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<SchemaElement> getDataSets() {
|
||||
List<SchemaElement> dataSets = new ArrayList<>();
|
||||
dataSetSchemaList.stream().forEach(d -> dataSets.add(d.getDataSet()));
|
||||
|
||||
@@ -9,4 +9,6 @@ public class TagTypeDefaultConfig {
|
||||
|
||||
// default time to filter tag selection results
|
||||
private TimeDefaultConfig timeDefaultConfig = new TimeDefaultConfig();
|
||||
|
||||
private Long limit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user