public async Task <IEnumerable <OperationTraceRecord> > GetEffectiveOperationTraceRecordsAsync(PrimaryMoveAnalysisEvent analysisEvent)
        {
            var records = await this.queryStoreReader.ReadTraceRecordsAsync(
                analysisEvent.GetDuration(),
                ReadFilter.CreateReadFilter(
                    new[]
            {
                typeof(OperationTraceRecord),
                typeof(OperationIgnoredTraceRecord)
            }
                    ),
                this.cancellationToken).ConfigureAwait(false);

            HashSet <Guid> ignoredDecisions = new HashSet <Guid>();
            Dictionary <Guid, OperationTraceRecord> decisionOperationMap      = new Dictionary <Guid, OperationTraceRecord>();
            List <OperationTraceRecord>             effectiveOperationRecords = new List <OperationTraceRecord>();

            foreach (var r in records)
            {
                OperationTraceRecord operation = r as OperationTraceRecord;
                if (operation == null)
                {
                    OperationIgnoredTraceRecord ignored = r as OperationIgnoredTraceRecord;

                    if (ignored != null && ignored.FailoverUnitId == analysisEvent.TriggerReconfigurationCompletedTraceRecord.PartitionId)
                    {
                        ignoredDecisions.Add(ignored.DecisionId);
                        if (decisionOperationMap.ContainsKey(ignored.DecisionId))
                        {
                            effectiveOperationRecords.Remove(decisionOperationMap[ignored.DecisionId]);
                        }
                    }
                }
                else if (this.MatchPartitionSourceAndDestination(operation, analysisEvent) && !ignoredDecisions.Contains(operation.DecisionId))
                {
                    effectiveOperationRecords.Add(operation);
                    decisionOperationMap[operation.DecisionId] = operation;
                }
            }

            var effectiveOperationRecordsMatchingSourceTarget = effectiveOperationRecords.Where(r => r.SourceNode.StartsWith(analysisEvent.PreviousNode) && r.TargetNode.StartsWith(analysisEvent.CurrentNode));

            return(effectiveOperationRecords);
        }
 private bool MatchPartitionSourceAndDestination(OperationTraceRecord operation, PrimaryMoveAnalysisEvent analysisEvent)
 {
     return(operation.PartitionId == analysisEvent.TriggerReconfigurationCompletedTraceRecord.PartitionId && operation.SourceNode.Equals(analysisEvent.PreviousPrimaryContext.NodeId, StringComparison.OrdinalIgnoreCase) && operation.TargetNode.Equals(analysisEvent.CurrentPrimaryContext.NodeId, StringComparison.OrdinalIgnoreCase));
 }