mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 12:07:42 +00:00
(improvement)(Headless) Add 'topFields' to the map interface and return dataSet and field names in Chinese. (#892)
This commit is contained in:
@@ -18,6 +18,7 @@ import java.util.List;
|
||||
public class SchemaElement implements Serializable {
|
||||
|
||||
private Long dataSet;
|
||||
private String dataSetName;
|
||||
private Long model;
|
||||
private Long id;
|
||||
private String name;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.tencent.supersonic.headless.api.pojo;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -30,4 +31,18 @@ public class SchemaMapInfo {
|
||||
public void setMatchedElements(Long dataSet, List<SchemaElementMatch> elementMatches) {
|
||||
dataSetElementMatches.put(dataSet, elementMatches);
|
||||
}
|
||||
|
||||
public Map<Long, String> generateDataSetMap() {
|
||||
Map<Long, String> dataSetIdToName = new HashMap<>();
|
||||
for (Map.Entry<Long, List<SchemaElementMatch>> entry : dataSetElementMatches.entrySet()) {
|
||||
List<SchemaElementMatch> values = entry.getValue();
|
||||
if (CollectionUtils.isNotEmpty(values)) {
|
||||
SchemaElementMatch schemaElementMatch = values.get(0);
|
||||
String dataSetName = schemaElementMatch.getElement().getDataSetName();
|
||||
dataSetIdToName.put(entry.getKey(), dataSetName);
|
||||
}
|
||||
}
|
||||
return dataSetIdToName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.tencent.supersonic.headless.api.pojo.response;
|
||||
|
||||
import com.tencent.supersonic.headless.api.pojo.SchemaElementMatch;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class MapInfoResp {
|
||||
|
||||
private String queryText;
|
||||
|
||||
private Map<String, List<SchemaElementMatch>> mapFields;
|
||||
|
||||
private Map<String, List<SchemaElementMatch>> topFields;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user