mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 11:07:06 +00:00
(fix)(headless) preserve model join order by using LinkedHashSet in probeRelatedModels (#2299)
This commit is contained in:
@@ -88,7 +88,7 @@ public class SqlBuilder {
|
|||||||
GraphPath<String, DefaultEdge> selectedGraphPath = null;
|
GraphPath<String, DefaultEdge> selectedGraphPath = null;
|
||||||
for (String fromModel : queryModels) {
|
for (String fromModel : queryModels) {
|
||||||
for (String toModel : queryModels) {
|
for (String toModel : queryModels) {
|
||||||
if (fromModel != toModel) {
|
if (!fromModel.equals(toModel)) {
|
||||||
GraphPath<String, DefaultEdge> path = dijkstraAlg.getPath(fromModel, toModel);
|
GraphPath<String, DefaultEdge> path = dijkstraAlg.getPath(fromModel, toModel);
|
||||||
if (isGraphPathContainsAll(path, queryModels)) {
|
if (isGraphPathContainsAll(path, queryModels)) {
|
||||||
selectedGraphPath = path;
|
selectedGraphPath = path;
|
||||||
@@ -100,13 +100,13 @@ public class SqlBuilder {
|
|||||||
if (selectedGraphPath == null) {
|
if (selectedGraphPath == null) {
|
||||||
return dataModels;
|
return dataModels;
|
||||||
}
|
}
|
||||||
Set<String> modelNames = Sets.newHashSet();
|
Set<String> modelNames = Sets.newLinkedHashSet();
|
||||||
for (DefaultEdge edge : selectedGraphPath.getEdgeList()) {
|
for (DefaultEdge edge : selectedGraphPath.getEdgeList()) {
|
||||||
modelNames.add(selectedGraphPath.getGraph().getEdgeSource(edge));
|
modelNames.add(selectedGraphPath.getGraph().getEdgeSource(edge));
|
||||||
modelNames.add(selectedGraphPath.getGraph().getEdgeTarget(edge));
|
modelNames.add(selectedGraphPath.getGraph().getEdgeTarget(edge));
|
||||||
}
|
}
|
||||||
return modelNames.stream().map(m -> ontology.getModelMap().get(m))
|
return modelNames.stream().map(m -> ontology.getModelMap().get(m))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isGraphPathContainsAll(GraphPath<String, DefaultEdge> graphPath,
|
private boolean isGraphPathContainsAll(GraphPath<String, DefaultEdge> graphPath,
|
||||||
|
|||||||
Reference in New Issue
Block a user