public override void ParseProperties()

in src/Microsoft.SqlTools.ServiceLayer/ShowPlan/ShowPlanGraph/RelOpTypeParser.cs [207:676]


        public override void ParseProperties(object parsedItem, PropertyDescriptorCollection targetPropertyBag, NodeBuilderContext context)
        {
            base.ParseProperties(parsedItem, targetPropertyBag, context);

            RelOpType item = parsedItem as RelOpType;
            Debug.Assert(item != null);

            if (item.RunTimeInformation != null && item.RunTimeInformation.Length > 0)
            {
                RunTimeCounters actualRowCountCounter = new RunTimeCounters();
                RunTimeCounters actualRowsReadCountCounter = new RunTimeCounters();
                RunTimeCounters actualBatchCountCounter = new RunTimeCounters();
                RunTimeCounters actualRebindsCounter = new RunTimeCounters();
                RunTimeCounters actualRewindsCounter = new RunTimeCounters();
                RunTimeCounters actualExecutionsCounter = new RunTimeCounters();
                RunTimeCounters actualLocallyAggregatedRowsCountCounter = new RunTimeCounters();
                RunTimeCounters actualElapsedTimeCounter = new RunTimeCounters { DisplayTotalCounters = false };
                RunTimeCounters actualElapsedCPUTimeCounter = new RunTimeCounters();
                RunTimeCounters actualScansCounter = new RunTimeCounters();
                RunTimeCounters actualLogicalReadsCounter = new RunTimeCounters();
                RunTimeCounters actualPhysicalReadsCounter = new RunTimeCounters();
                RunTimeCounters actualPageServerReadsCounter = new RunTimeCounters();
                RunTimeCounters actualReadAheadsCounter = new RunTimeCounters();
                RunTimeCounters actualPageServerReadAheadsCounter = new RunTimeCounters();
                RunTimeCounters actualLobLogicalReadsCounter = new RunTimeCounters();
                RunTimeCounters actualLobPhysicalReadsCounter = new RunTimeCounters();
                RunTimeCounters actualLobPageServerReadsCounter = new RunTimeCounters();
                RunTimeCounters actualLobReadAheadsCounter = new RunTimeCounters();
                RunTimeCounters actualLobPageServerReadAheadsCounter = new RunTimeCounters();
                RunTimeCounters actualInputMemoryGrantCounter = new MemGrantRunTimeCounters();
                RunTimeCounters actualOutputMemoryGrantCounter = new MemGrantRunTimeCounters();
                RunTimeCounters actualUsedMemoryGrantCounter = new RunTimeCounters();

                RunTimeCounters hpcKernelElapsedUsCounter = new RunTimeCounters();
                RunTimeCounters hpcRowCountCounter = new RunTimeCounters();
                RunTimeCounters hpcHostToDeviceBytesCounter = new RunTimeCounters();
                RunTimeCounters hpcDeviceToHostBytesCounter = new RunTimeCounters();

                ExpandableObjectWrapper actualTimeStatsObjWrapper = new ExpandableObjectWrapper();
                ExpandableObjectWrapper actualIOStatsObjWrapper = new ExpandableObjectWrapper();
                ExpandableObjectWrapper actualMemoryGrantStatsObjWrapper = new ExpandableObjectWrapper();

                String actualExecutionModeValue = String.Empty;
                String actualJoinTypeValue = String.Empty;
                bool actualIsInterleavedExecuted = false;

                foreach (RunTimeInformationTypeRunTimeCountersPerThread counter in item.RunTimeInformation)
                {
                    if (counter.BrickIdSpecified)
                    {
                        actualRowCountCounter.AddCounter(counter.Thread, counter.BrickId, counter.ActualRows);
                        actualRebindsCounter.AddCounter(counter.Thread, counter.BrickId, counter.ActualRebinds);
                        actualRewindsCounter.AddCounter(counter.Thread, counter.BrickId, counter.ActualRewinds);
                        actualExecutionsCounter.AddCounter(counter.Thread, counter.BrickId, counter.ActualExecutions);
                        actualLocallyAggregatedRowsCountCounter.AddCounter(counter.Thread, counter.BrickId, counter.ActualLocallyAggregatedRows);

                        if (counter.ActualElapsedmsSpecified)
                        {
                            actualElapsedTimeCounter.AddCounter(counter.Thread, counter.BrickId, counter.ActualElapsedms);
                        }

                        if (counter.ActualCPUmsSpecified)
                        {
                            actualElapsedCPUTimeCounter.AddCounter(counter.Thread, counter.BrickId, counter.ActualCPUms);
                        }

                        if (counter.ActualScansSpecified)
                        {
                            actualScansCounter.AddCounter(counter.Thread, counter.BrickId, counter.ActualScans);
                        }

                        if (counter.ActualLogicalReadsSpecified)
                        {
                            actualLogicalReadsCounter.AddCounter(counter.Thread, counter.BrickId, counter.ActualLogicalReads);
                        }

                        if (counter.ActualPhysicalReadsSpecified)
                        {
                            actualPhysicalReadsCounter.AddCounter(counter.Thread, counter.BrickId, counter.ActualPhysicalReads);
                        }

                        if (counter.ActualPageServerReadsSpecified)
                        {
                            actualPageServerReadsCounter.AddCounter(counter.Thread, counter.BrickId, counter.ActualPageServerReads);
                        }

                        if (counter.ActualReadAheadsSpecified)
                        {
                            actualReadAheadsCounter.AddCounter(counter.Thread, counter.BrickId, counter.ActualReadAheads);
                        }

                        if (counter.ActualPageServerReadAheadsSpecified)
                        {
                            actualPageServerReadAheadsCounter.AddCounter(counter.Thread, counter.BrickId, counter.ActualPageServerReadAheads);
                        }

                        if (counter.ActualLobLogicalReadsSpecified)
                        {
                            actualLobLogicalReadsCounter.AddCounter(counter.Thread, counter.BrickId, counter.ActualLobLogicalReads);
                        }

                        if (counter.ActualLobPhysicalReadsSpecified)
                        {
                            actualLobPhysicalReadsCounter.AddCounter(counter.Thread, counter.BrickId, counter.ActualLobPhysicalReads);
                        }

                        if (counter.ActualLobPageServerReadsSpecified)
                        {
                            actualLobPageServerReadsCounter.AddCounter(counter.Thread, counter.BrickId, counter.ActualLobPageServerReads);
                        }

                        if (counter.ActualLobReadAheadsSpecified)
                        {
                            actualLobReadAheadsCounter.AddCounter(counter.Thread, counter.BrickId, counter.ActualLobReadAheads);
                        }

                        if (counter.ActualLobPageServerReadAheadsSpecified)
                        {
                            actualLobPageServerReadAheadsCounter.AddCounter(counter.Thread, counter.BrickId, counter.ActualLobPageServerReadAheads);
                        }

                        if (counter.ActualRowsReadSpecified)
                        {
                            actualRowsReadCountCounter.AddCounter(counter.Thread, counter.BrickId, counter.ActualRowsRead);
                        }

                        if (counter.BatchesSpecified)
                        {
                            actualBatchCountCounter.AddCounter(counter.Thread, counter.BrickId, counter.Batches);
                        }

                        if (counter.HpcRowCountSpecified)
                        {
                            hpcRowCountCounter.AddCounter(counter.Thread, counter.BrickId, counter.HpcRowCount);
                        }

                        if (counter.HpcKernelElapsedUsSpecified)
                        {
                            hpcKernelElapsedUsCounter.AddCounter(counter.Thread, counter.BrickId, counter.HpcKernelElapsedUs);
                        }

                        if (counter.HpcHostToDeviceBytesSpecified)
                        {
                            hpcHostToDeviceBytesCounter.AddCounter(counter.Thread, counter.BrickId, counter.HpcHostToDeviceBytes);
                        }

                        if (counter.HpcDeviceToHostBytesSpecified)
                        {
                            hpcDeviceToHostBytesCounter.AddCounter(counter.Thread, counter.BrickId, counter.HpcDeviceToHostBytes);
                        }

                        if (counter.InputMemoryGrantSpecified)
                        {
                            actualInputMemoryGrantCounter.AddCounter(counter.Thread, counter.BrickId, counter.InputMemoryGrant);
                        }

                        if (counter.OutputMemoryGrantSpecified)
                        {
                            actualOutputMemoryGrantCounter.AddCounter(counter.Thread, counter.BrickId, counter.OutputMemoryGrant);
                        }

                        if (counter.UsedMemoryGrantSpecified)
                        {
                            actualUsedMemoryGrantCounter.AddCounter(counter.Thread, counter.BrickId, counter.UsedMemoryGrant);
                        }
                    }
                    else
                    {
                        actualRowCountCounter.AddCounter(counter.Thread, counter.ActualRows);
                        actualRebindsCounter.AddCounter(counter.Thread, counter.ActualRebinds);
                        actualRewindsCounter.AddCounter(counter.Thread, counter.ActualRewinds);
                        actualExecutionsCounter.AddCounter(counter.Thread, counter.ActualExecutions);
                        actualLocallyAggregatedRowsCountCounter.AddCounter(counter.Thread, counter.ActualLocallyAggregatedRows);

                        if (counter.ActualElapsedmsSpecified)
                        {
                            actualElapsedTimeCounter.AddCounter(counter.Thread, counter.ActualElapsedms);
                        }

                        if (counter.ActualCPUmsSpecified)
                        {
                            actualElapsedCPUTimeCounter.AddCounter(counter.Thread, counter.ActualCPUms);
                        }

                        if (counter.ActualScansSpecified)
                        {
                            actualScansCounter.AddCounter(counter.Thread, counter.ActualScans);
                        }

                        if (counter.ActualLogicalReadsSpecified)
                        {
                            actualLogicalReadsCounter.AddCounter(counter.Thread, counter.ActualLogicalReads);
                        }

                        if (counter.ActualPhysicalReadsSpecified)
                        {
                            actualPhysicalReadsCounter.AddCounter(counter.Thread, counter.ActualPhysicalReads);
                        }

                        if (counter.ActualPageServerReadsSpecified)
                        {
                            actualPageServerReadsCounter.AddCounter(counter.Thread, counter.ActualPageServerReads);
                        }

                        if (counter.ActualReadAheadsSpecified)
                        {
                            actualReadAheadsCounter.AddCounter(counter.Thread, counter.ActualReadAheads);
                        }

                        if (counter.ActualPageServerReadAheadsSpecified)
                        {
                            actualPageServerReadAheadsCounter.AddCounter(counter.Thread, counter.ActualPageServerReadAheads);
                        }

                        if (counter.ActualLobLogicalReadsSpecified)
                        {
                            actualLobLogicalReadsCounter.AddCounter(counter.Thread, counter.ActualLobLogicalReads);
                        }

                        if (counter.ActualLobPhysicalReadsSpecified)
                        {
                            actualLobPhysicalReadsCounter.AddCounter(counter.Thread, counter.ActualLobPhysicalReads);
                        }

                        if (counter.ActualLobPageServerReadsSpecified)
                        {
                            actualLobPageServerReadsCounter.AddCounter(counter.Thread, counter.ActualLobPageServerReads);
                        }

                        if (counter.ActualLobReadAheadsSpecified)
                        {
                            actualLobReadAheadsCounter.AddCounter(counter.Thread, counter.ActualLobReadAheads);
                        }

                        if (counter.ActualLobPageServerReadAheadsSpecified)
                        {
                            actualLobPageServerReadAheadsCounter.AddCounter(counter.Thread, counter.ActualLobPageServerReadAheads);
                        }

                        if (counter.ActualRowsReadSpecified)
                        {
                            actualRowsReadCountCounter.AddCounter(counter.Thread, counter.ActualRowsRead);
                        }

                        if (counter.BatchesSpecified)
                        {
                            actualBatchCountCounter.AddCounter(counter.Thread, counter.Batches);
                        }

                        if (counter.HpcRowCountSpecified)
                        {
                            hpcRowCountCounter.AddCounter(counter.Thread, counter.HpcRowCount);
                        }

                        if (counter.HpcKernelElapsedUsSpecified)
                        {
                            hpcKernelElapsedUsCounter.AddCounter(counter.Thread, counter.HpcKernelElapsedUs);
                        }

                        if (counter.HpcHostToDeviceBytesSpecified)
                        {
                            hpcHostToDeviceBytesCounter.AddCounter(counter.Thread, counter.HpcHostToDeviceBytes);
                        }

                        if (counter.HpcDeviceToHostBytesSpecified)
                        {
                            hpcDeviceToHostBytesCounter.AddCounter(counter.Thread, counter.HpcDeviceToHostBytes);
                        }

                        if (counter.InputMemoryGrantSpecified)
                        {
                            actualInputMemoryGrantCounter.AddCounter(counter.Thread, counter.InputMemoryGrant);
                        }

                        if (counter.OutputMemoryGrantSpecified)
                        {
                            actualOutputMemoryGrantCounter.AddCounter(counter.Thread, counter.OutputMemoryGrant);
                        }

                        if (counter.UsedMemoryGrantSpecified)
                        {
                            actualUsedMemoryGrantCounter.AddCounter(counter.Thread, counter.UsedMemoryGrant);
                        }
                    }

                    if (counter.ActualExecutions > 0)
                    {
                        actualExecutionModeValue = Enum.GetName(typeof(ExecutionModeType), counter.ActualExecutionMode);
                    }

                    if (counter.ActualJoinTypeSpecified)
                    {
                        actualJoinTypeValue = Enum.GetName(typeof(PhysicalOpType), counter.ActualJoinType);
                    }

                    if (counter.IsInterleavedExecuted)
                    {
                        actualIsInterleavedExecuted = true;
                    }
                }

                if (actualIsInterleavedExecuted)
                {
                    targetPropertyBag.Add(PropertyFactory.CreateProperty("IsInterleavedExecuted", actualIsInterleavedExecuted));
                }

                // Create localizable properties and add them to the property bag
                targetPropertyBag.Add(PropertyFactory.CreateProperty("ActualRows", actualRowCountCounter));
                targetPropertyBag.Add(PropertyFactory.CreateProperty("ActualBatches", actualBatchCountCounter));
                targetPropertyBag.Add(PropertyFactory.CreateProperty("ActualRebinds", actualRebindsCounter));
                targetPropertyBag.Add(PropertyFactory.CreateProperty("ActualRewinds", actualRewindsCounter));
                targetPropertyBag.Add(PropertyFactory.CreateProperty("ActualExecutions", actualExecutionsCounter));

                if (actualRowsReadCountCounter.TotalCounters > 0)
                {
                    targetPropertyBag.Add(PropertyFactory.CreateProperty("ActualRowsRead", actualRowsReadCountCounter));
                }

                if (actualLocallyAggregatedRowsCountCounter.TotalCounters > 0)
                {
                    targetPropertyBag.Add(PropertyFactory.CreateProperty("ActualLocallyAggregatedRows", actualLocallyAggregatedRowsCountCounter));
                }

                if (hpcRowCountCounter.TotalCounters > 0)
                {
                    targetPropertyBag.Add(PropertyFactory.CreateProperty("HpcRowCount", hpcRowCountCounter));
                }

                if (hpcKernelElapsedUsCounter.TotalCounters > 0)
                {
                    targetPropertyBag.Add(PropertyFactory.CreateProperty("HpcKernelElapsedUs", hpcKernelElapsedUsCounter));
                }

                if (hpcHostToDeviceBytesCounter.TotalCounters > 0)
                {
                    targetPropertyBag.Add(PropertyFactory.CreateProperty("HpcHostToDeviceBytes", hpcHostToDeviceBytesCounter));
                }

                if (hpcDeviceToHostBytesCounter.TotalCounters > 0)
                {
                    targetPropertyBag.Add(PropertyFactory.CreateProperty("HpcDeviceToHostBytes", hpcDeviceToHostBytesCounter));
                }

                if (!String.IsNullOrEmpty(actualExecutionModeValue))
                {
                    targetPropertyBag.Add(PropertyFactory.CreateProperty("ActualExecutionMode", actualExecutionModeValue));
                }


                if (!String.IsNullOrEmpty(actualJoinTypeValue))
                {
                    targetPropertyBag.Add(PropertyFactory.CreateProperty("ActualJoinType", actualJoinTypeValue));
                }

                // Populate the "Actual Time Statistics" property if applicable
                // Nested properties include "Actual Elapsed Time" and "Actual Elapsed CPU Time"
                if (actualElapsedTimeCounter.NumOfCounters > 0)
                {
                    actualTimeStatsObjWrapper.Properties.Add(PropertyFactory.CreateProperty("ActualElapsedms", actualElapsedTimeCounter));
                }

                if (actualElapsedCPUTimeCounter.NumOfCounters > 0)
                {
                    actualTimeStatsObjWrapper.Properties.Add(PropertyFactory.CreateProperty("ActualCPUms", actualElapsedCPUTimeCounter));
                }

                if (actualTimeStatsObjWrapper.Properties.Count > 0)
                {
                    targetPropertyBag.Add(PropertyFactory.CreateProperty("ActualTimeStatistics", actualTimeStatsObjWrapper));
                }

                // Populate the "Actual IO Statistics" property if applicable
                // Nested properties include "Scan" and "Read" properties.
                if (actualScansCounter.NumOfCounters > 0)
                {
                    actualIOStatsObjWrapper.Properties.Add(PropertyFactory.CreateProperty("ActualScans", actualScansCounter));
                }

                if (actualLogicalReadsCounter.NumOfCounters > 0)
                {
                    actualIOStatsObjWrapper.Properties.Add(PropertyFactory.CreateProperty("ActualLogicalReads", actualLogicalReadsCounter));
                }

                if (actualPhysicalReadsCounter.NumOfCounters > 0)
                {
                    actualIOStatsObjWrapper.Properties.Add(PropertyFactory.CreateProperty("ActualPhysicalReads", actualPhysicalReadsCounter));
                }

                if (actualPageServerReadsCounter.NumOfCounters > 0)
                {
                    actualIOStatsObjWrapper.Properties.Add(PropertyFactory.CreateProperty("ActualPageServerReads", actualPageServerReadsCounter));
                }

                if (actualReadAheadsCounter.NumOfCounters > 0)
                {
                    actualIOStatsObjWrapper.Properties.Add(PropertyFactory.CreateProperty("ActualReadAheads", actualReadAheadsCounter));
                }

                if (actualPageServerReadAheadsCounter.NumOfCounters > 0)
                {
                    actualIOStatsObjWrapper.Properties.Add(PropertyFactory.CreateProperty("ActualPageServerReadAheads", actualPageServerReadAheadsCounter));
                }

                if (actualLobLogicalReadsCounter.NumOfCounters > 0)
                {
                    actualIOStatsObjWrapper.Properties.Add(PropertyFactory.CreateProperty("ActualLobLogicalReads", actualLobLogicalReadsCounter));
                }

                if (actualLobPhysicalReadsCounter.NumOfCounters > 0)
                {
                    actualIOStatsObjWrapper.Properties.Add(PropertyFactory.CreateProperty("ActualLobPhysicalReads", actualLobPhysicalReadsCounter));
                }

                if (actualLobPageServerReadsCounter.NumOfCounters > 0)
                {
                    actualIOStatsObjWrapper.Properties.Add(PropertyFactory.CreateProperty("ActualLobPageServerReads", actualLobPageServerReadsCounter));
                }

                if (actualLobReadAheadsCounter.NumOfCounters > 0)
                {
                    actualIOStatsObjWrapper.Properties.Add(PropertyFactory.CreateProperty("ActualLobReadAheads", actualLobReadAheadsCounter));
                }

                if (actualLobPageServerReadAheadsCounter.NumOfCounters > 0)
                {
                    actualIOStatsObjWrapper.Properties.Add(PropertyFactory.CreateProperty("ActualLobPageServerReadAheads", actualLobPageServerReadAheadsCounter));
                }

                if (actualIOStatsObjWrapper.Properties.Count > 0)
                {
                    targetPropertyBag.Add(PropertyFactory.CreateProperty("ActualIOStatistics", actualIOStatsObjWrapper));
                }

                // Populate ActualMemoryGrantStats
                if (actualInputMemoryGrantCounter.NumOfCounters > 0)
                {
                    actualMemoryGrantStatsObjWrapper.Properties.Add(PropertyFactory.CreateProperty("InputMemoryGrant", actualInputMemoryGrantCounter));
                }

                if (actualOutputMemoryGrantCounter.NumOfCounters > 0)
                {
                    actualMemoryGrantStatsObjWrapper.Properties.Add(PropertyFactory.CreateProperty("OutputMemoryGrant", actualOutputMemoryGrantCounter));
                }

                if (actualUsedMemoryGrantCounter.NumOfCounters > 0)
                {
                    actualMemoryGrantStatsObjWrapper.Properties.Add(PropertyFactory.CreateProperty("UsedMemoryGrant", actualUsedMemoryGrantCounter));
                }

                if (actualMemoryGrantStatsObjWrapper.Properties.Count > 0)
                {
                    targetPropertyBag.Add(PropertyFactory.CreateProperty("ActualMemoryGrantStats", actualMemoryGrantStatsObjWrapper));
                }
            }

            // Decompose RunTimePartitionSummary and add them individually.
            // Otherwise, the properties will show up as nested in the property window.
            if (item.RunTimePartitionSummary != null && item.RunTimePartitionSummary.PartitionsAccessed != null)
            {
                RunTimePartitionSummaryTypePartitionsAccessed partitions = item.RunTimePartitionSummary.PartitionsAccessed;

                // Create localizable properties and add them to the property bag
                targetPropertyBag.Add(PropertyFactory.CreateProperty("PartitionCount", partitions.PartitionCount));

                if (partitions.PartitionRange != null && partitions.PartitionRange.Length > 0)
                {
                    targetPropertyBag.Add(PropertyFactory.CreateProperty("PartitionsAccessed", GetPartitionRangeString(partitions.PartitionRange)));
                }
            }
        }