Removing circular references from Plan Comparison (#1498)

This commit is contained in:
Aasim Khan
2022-05-18 00:13:26 -07:00
committed by GitHub
parent 91db096b09
commit e7c7489b21
3 changed files with 6 additions and 12 deletions

View File

@@ -34,7 +34,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.Contracts
/// <summary> /// <summary>
/// List of matching nodes for the ExecutionGraphComparisonResult. /// List of matching nodes for the ExecutionGraphComparisonResult.
/// </summary> /// </summary>
public List<ExecutionGraphComparisonResult> MatchingNodes { get; set; } = new List<ExecutionGraphComparisonResult>(); public List<int> MatchingNodesId { get; set; } = new List<int>();
/// <summary> /// <summary>
/// The parent of the ExecutionGraphComparisonResult. /// The parent of the ExecutionGraphComparisonResult.
/// </summary> /// </summary>

View File

@@ -197,12 +197,10 @@ GO
{ {
var curNode = queue.Dequeue(); var curNode = queue.Dequeue();
for (int index = 0; index < curNode.MatchingNodes.Count; ++index) for (int index = 0; index < curNode.MatchingNodesId.Count; ++index)
{ {
var matchingId = curNode.MatchingNodes[index].BaseNode.ID; var matchingId = curNode.MatchingNodesId[index];
var matchingNode = srcGraphLookupTable[matchingId]; curNode.MatchingNodesId[index] = matchingId;
curNode.MatchingNodes[index] = matchingNode;
} }
foreach (var child in curNode.Children) foreach (var child in curNode.Children)

View File

@@ -99,12 +99,9 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan.Comparison
curNodeDTO.BaseNode = ExecutionPlanGraphUtils.ConvertShowPlanTreeToExecutionPlanTree(curNode.BaseNode); curNodeDTO.BaseNode = ExecutionPlanGraphUtils.ConvertShowPlanTreeToExecutionPlanTree(curNode.BaseNode);
curNodeDTO.GroupIndex = curNode.GroupIndex; curNodeDTO.GroupIndex = curNode.GroupIndex;
curNodeDTO.HasMatch = curNode.HasMatch; curNodeDTO.HasMatch = curNode.HasMatch;
curNodeDTO.MatchingNodes = curNode.MatchingNodes.Select(matchingNode => curNodeDTO.MatchingNodesId = curNode.MatchingNodes.Select(matchingNode =>
{ {
var skeletonNodeDTO = new Contracts.ExecutionGraphComparisonResult(); return matchingNode.BaseNode.ID;
skeletonNodeDTO.BaseNode = ExecutionPlanGraphUtils.ConvertShowPlanTreeToExecutionPlanTree(matchingNode.BaseNode);
return skeletonNodeDTO;
}).ToList(); }).ToList();
foreach (var child in curNode.Children) foreach (var child in curNode.Children)
@@ -112,7 +109,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan.Comparison
queue.Enqueue(child); queue.Enqueue(child);
var childDTO = new Contracts.ExecutionGraphComparisonResult(); var childDTO = new Contracts.ExecutionGraphComparisonResult();
childDTO.ParentNode = curNodeDTO;
curNodeDTO.Children.Add(childDTO); curNodeDTO.Children.Add(childDTO);
dtoQueue.Enqueue(childDTO); dtoQueue.Enqueue(childDTO);
} }