private static void WriteRowBufferEntry(PropertyListBuilder builder, string groupName, RowBufferEntry rowBufferColumn) { builder.Begin(groupName); builder.SetGroupValue(rowBufferColumn.Name); WriteRowBufferEntry(builder, rowBufferColumn); builder.End(); }
private static void AddDefinedValues(PropertyListBuilder builder, IEnumerable <UnitedValueDefinition> definedValues) { builder.Begin(Resources.ShowPlanGroupDefinedValues); foreach (UnitedValueDefinition definedValue in definedValues) { builder.Begin(definedValue.Target.Name); StringBuilder sb = new StringBuilder(); foreach (RowBufferEntry dependendValue in definedValue.DependendEntries) { builder.Begin(); builder.SetGroupValue(dependendValue.Name); WriteRowBufferEntry(builder, dependendValue); builder.End(); if (sb.Length > 0) { sb.Append("; "); } sb.Append(dependendValue.Name); } builder.SetGroupValue(sb.ToString()); builder.End(); } builder.End(); }
public override AlgebraNode VisitTopAlgebraNode(TopAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); propertyListBuilder.Write(Resources.ShowPlanKeyLimit, node.Limit.ToString(CultureInfo.InvariantCulture)); if (node.TieEntries == null) { propertyListBuilder.Write(Resources.ShowPlanKeyWithTies, Boolean.FalseString); } else { propertyListBuilder.Write(Resources.ShowPlanKeyWithTies, Boolean.TrueString); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupTieColumns, node.TieEntries); } IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Top, properties, inputElement); _currentElement = element; return(node); }
public override AlgebraNode VisitResultAlgebraNode(ResultAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); propertyListBuilder.Begin(Resources.ShowPlanGroupOutputList); for (int i = 0; i < node.OutputList.Length; i++) { propertyListBuilder.Begin(); propertyListBuilder.SetGroupValue(String.Format(CultureInfo.InvariantCulture, "{0} AS {1}", node.OutputList[i].Name, node.ColumnNames[i])); WriteRowBufferEntry(propertyListBuilder, node.OutputList[i]); propertyListBuilder.Write(Resources.ShowPlanKeyOutputName, node.ColumnNames[i]); propertyListBuilder.End(); } propertyListBuilder.End(); IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Select, properties, inputElement); _currentElement = element; return(node); }
public override AlgebraNode VisitHashMatchAlgebraNode(HashMatchAlgebraNode node) { ShowPlanElement buildElement = ConvertNode(node.Left); ShowPlanElement probeElement = ConvertNode(node.Right); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); WriteRowBufferEntry(propertyListBuilder, Resources.ShowPlanKeyHashKeysBuild, node.BuildKeyEntry); WriteRowBufferEntry(propertyListBuilder, Resources.ShowPlanKeyHashKeysProbe, node.ProbeEntry); propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, LogicalOperatorToString(node.Op)); if (node.ProbeResidual != null) { propertyListBuilder.Write(Resources.ShowPlanKeyProbeResidual, node.ProbeResidual.GenerateSource()); } IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.HashMatch, properties, buildElement, probeElement); _currentElement = element; return(node); }
private static void AddRowBufferEntries(PropertyListBuilder builder, string groupName, IEnumerable <RowBufferEntry> rowBufferColumns) { builder.Begin(groupName); foreach (RowBufferEntry rowBufferColumn in rowBufferColumns) { builder.Begin(); builder.SetGroupValue(rowBufferColumn.Name); WriteRowBufferEntry(builder, rowBufferColumn); builder.End(); } builder.End(); }
public override AlgebraNode VisitJoinAlgebraNode(JoinAlgebraNode node) { ShowPlanElement leftElement = ConvertNode(node.Left); ShowPlanElement rightElement = ConvertNode(node.Right); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, LogicalOperatorToString(node.Op)); AddStatistics(propertyListBuilder, node.StatisticsIterator); if (node.Predicate != null) { propertyListBuilder.Write(Resources.ShowPlanKeyPredicate, node.Predicate.GenerateSource()); } if (node.OuterReferences != null && node.OuterReferences.Length > 0) { AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOuterReferences, node.OuterReferences); } if (node.ProbeBufferEntry != null) { WriteRowBufferEntry(propertyListBuilder, Resources.ShowPlanKeyProbeColumn, node.ProbeBufferEntry); } if (node.PassthruPredicate != null) { propertyListBuilder.Write(Resources.ShowPlanKeyPassthru, node.PassthruPredicate.GenerateSource()); } // We give a warning if a join has no predicate and no outer reference. // In this case the join would simply multiply the other side. // However, we supppress the warning if any side is known at produce at // most one row. if (node.Predicate == null && (node.OuterReferences == null || node.OuterReferences.Length == 0) && !AstUtil.WillProduceAtMostOneRow(node.Left) && !AstUtil.WillProduceAtMostOneRow(node.Right)) { propertyListBuilder.Write(Resources.ShowPlanKeyWarning, Resources.ShowPlanWarningNoJoinPredicate); } IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.NestedLoops, properties, leftElement, rightElement); _currentElement = element; return(node); }
private static void AddStatistics(PropertyListBuilder builder, StatisticsIterator iterator) { if (iterator != null) { int openCount = iterator.OpenCount; int rowCount = iterator.RowCount; int avgRowCount = (openCount == 0) ? 0 : (int)Math.Round(rowCount / (double)openCount, 0); builder.Begin(Resources.ShowPlanGroupStatistics); builder.Write(Resources.ShowPlanKeyStatisticsOpenCount, openCount.ToString("N0", CultureInfo.InvariantCulture)); builder.Write(Resources.ShowPlanKeyStatisticsRowCount, rowCount.ToString("N0", CultureInfo.InvariantCulture)); builder.Write(Resources.ShowPlanKeyStatisticsAverageRowCount, avgRowCount.ToString("N0", CultureInfo.InvariantCulture)); builder.End(); } }
private static void WriteRowBufferEntry(PropertyListBuilder builder, RowBufferEntry rowBufferColumn) { string[] parts = rowBufferColumn.Name.Split('.'); if (parts.Length != 2) { builder.Write(Resources.ShowPlanKeyColumn, rowBufferColumn.Name); } else { builder.Write(Resources.ShowPlanKeyTable, parts[0]); builder.Write(Resources.ShowPlanKeyColumn, parts[1]); } builder.Write(Resources.ShowPlanKeyDataType, rowBufferColumn.DataType.Name); }
private static void AddDefinedValues(PropertyListBuilder builder, IEnumerable <ComputedValueDefinition> definedValues) { builder.Begin(Resources.ShowPlanGroupDefinedValues); foreach (ComputedValueDefinition definedValue in definedValues) { string sourceExpression = definedValue.Expression.GenerateSource(); builder.Begin(); builder.SetGroupValue(String.Format(CultureInfo.InvariantCulture, "{0} = {1}", definedValue.Target.Name, sourceExpression)); builder.Write(Resources.ShowPlanKeyTarget, definedValue.Target.Name); builder.Write(Resources.ShowPlanKeyDataType, definedValue.Target.DataType.Name); builder.Write(Resources.ShowPlanKeySource, sourceExpression); builder.End(); } builder.End(); }
public override AlgebraNode VisitTableAlgebraNode(TableAlgebraNode node) { PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); propertyListBuilder.Write(Resources.ShowPlanKeyTable, String.Format(CultureInfo.InvariantCulture, "{0} AS {1}", node.TableRefBinding.TableBinding.Name, node.TableRefBinding.Name)); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.TableScan, properties); _currentElement = element; return(node); }
public override AlgebraNode VisitNullScanAlgebraNode(NullScanAlgebraNode node) { PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); propertyListBuilder.Write(Resources.ShowPlanKeyEmpty, Boolean.TrueString); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.ConstantScan, properties); _currentElement = element; return(node); }
public override AlgebraNode VisitComputeScalarAlgebraNode(ComputeScalarAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); AddDefinedValues(propertyListBuilder, node.DefinedValues); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.ComputeScalar, properties, inputElement); _currentElement = element; return node; }
public override AlgebraNode VisitAssertAlgebraNode(AssertAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); propertyListBuilder.Write(Resources.ShowPlanKeyPredicate, node.Predicate.GenerateSource()); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Assert, properties, inputElement); _currentElement = element; return node; }
public override AstNode VisitTableSpoolRefAlgebraNode(StackedTableSpoolRefAlgebraNode node) { PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, Resources.ShowPlanLogicalOperatorLazySpool); propertyListBuilder.Write(Resources.ShowPlanKeyWithStack, Boolean.TrueString); IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.TableSpool, properties); _currentElement = element; return(node); }
public override AlgebraNode VisitComputeScalarAlgebraNode(ComputeScalarAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); AddDefinedValues(propertyListBuilder, node.DefinedValues); IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.ComputeScalar, properties, inputElement); _currentElement = element; return(node); }
public override AlgebraNode VisitAggregateAlgebraNode(AggregateAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); AddDefinedValues(propertyListBuilder, node.DefinedValues); if (node.Groups != null && node.Groups.Length > 0) AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupGroupBy, node.Groups); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.StreamAggregate, properties, inputElement); _currentElement = element; return node; }
public override AlgebraNode VisitAssertAlgebraNode(AssertAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); propertyListBuilder.Write(Resources.ShowPlanKeyPredicate, node.Predicate.GenerateSource()); IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Assert, properties, inputElement); _currentElement = element; return(node); }
public override AlgebraNode VisitIndexSpoolAlgebraNode(IndexSpoolAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, Resources.ShowPlanLogicalOperatorEagerSpool); propertyListBuilder.Write(Resources.ShowPlanKeyWithStack, Boolean.FalseString); WriteRowBufferEntry(propertyListBuilder, Resources.ShowPlanKeyIndex, node.IndexEntry); propertyListBuilder.Write(Resources.ShowPlanKeyProbe, node.ProbeExpression.GenerateSource()); IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.IndexSpool, properties, inputElement); _currentElement = element; return(node); }
public override AlgebraNode VisitSortAlgebraNode(SortAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); if (node.Distinct) { propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, Resources.ShowPlanLogicalOperatorDistinctSort); } else { propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, Resources.ShowPlanLogicalOperatorSort); } propertyListBuilder.Begin(Resources.ShowPlanGroupOrderBy); for (int i = 0; i < node.SortEntries.Length; i++) { string sortOrder = SortOrderToString(node.SortOrders[i]); propertyListBuilder.Begin(); propertyListBuilder.SetGroupValue(String.Format(CultureInfo.InvariantCulture, "{0} {1}", node.SortEntries[i].Name, sortOrder)); WriteRowBufferEntry(propertyListBuilder, node.SortEntries[i]); propertyListBuilder.Write(Resources.ShowPlanKeyOrder, sortOrder); propertyListBuilder.End(); } propertyListBuilder.End(); IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Sort, properties, inputElement); _currentElement = element; return(node); }
public override AlgebraNode VisitAggregateAlgebraNode(AggregateAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); AddDefinedValues(propertyListBuilder, node.DefinedValues); if (node.Groups != null && node.Groups.Length > 0) { AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupGroupBy, node.Groups); } IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.StreamAggregate, properties, inputElement); _currentElement = element; return(node); }
public override AlgebraNode VisitConcatAlgebraNode(ConcatAlgebraNode node) { List <ShowPlanElement> inputList = new List <ShowPlanElement>(); foreach (AlgebraNode inputNode in node.Inputs) { inputList.Add(ConvertNode(inputNode)); } PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); AddDefinedValues(propertyListBuilder, node.DefinedValues); IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Concatenation, properties, inputList.ToArray()); _currentElement = element; return(node); }
public override AlgebraNode VisitNullScanAlgebraNode(NullScanAlgebraNode node) { PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); propertyListBuilder.Write(Resources.ShowPlanKeyEmpty, Boolean.TrueString); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.ConstantScan, properties); _currentElement = element; return node; }
public override AlgebraNode VisitResultAlgebraNode(ResultAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); propertyListBuilder.Begin(Resources.ShowPlanGroupOutputList); for (int i = 0; i < node.OutputList.Length; i++) { propertyListBuilder.Begin(); propertyListBuilder.SetGroupValue(String.Format(CultureInfo.InvariantCulture, "{0} AS {1}", node.OutputList[i].Name, node.ColumnNames[i])); WriteRowBufferEntry(propertyListBuilder, node.OutputList[i]); propertyListBuilder.Write(Resources.ShowPlanKeyOutputName, node.ColumnNames[i]); propertyListBuilder.End(); } propertyListBuilder.End(); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Select, properties, inputElement); _currentElement = element; return node; }
private static void WriteRowBufferEntry(PropertyListBuilder builder, RowBufferEntry rowBufferColumn) { string[] parts = rowBufferColumn.Name.Split('.'); if (parts.Length != 2) { builder.Write(Resources.ShowPlanKeyColumn, rowBufferColumn.Name); } else { builder.Write(Resources.ShowPlanKeyTable, parts[0]); builder.Write(Resources.ShowPlanKeyColumn, parts[1]); } builder.Write(Resources.ShowPlanKeyDataType, rowBufferColumn.DataType.Name); }
public override AlgebraNode VisitSortAlgebraNode(SortAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); if (node.Distinct) propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, Resources.ShowPlanLogicalOperatorDistinctSort); else propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, Resources.ShowPlanLogicalOperatorSort); propertyListBuilder.Begin(Resources.ShowPlanGroupOrderBy); for (int i = 0; i < node.SortEntries.Length; i++) { string sortOrder = SortOrderToString(node.SortOrders[i]); propertyListBuilder.Begin(); propertyListBuilder.SetGroupValue(String.Format(CultureInfo.InvariantCulture, "{0} {1}", node.SortEntries[i].Name, sortOrder)); WriteRowBufferEntry(propertyListBuilder, node.SortEntries[i]); propertyListBuilder.Write(Resources.ShowPlanKeyOrder, sortOrder); propertyListBuilder.End(); } propertyListBuilder.End(); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Sort, properties, inputElement); _currentElement = element; return node; }
public override AlgebraNode VisitTopAlgebraNode(TopAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); propertyListBuilder.Write(Resources.ShowPlanKeyLimit, node.Limit.ToString(CultureInfo.InvariantCulture)); if (node.TieEntries == null) { propertyListBuilder.Write(Resources.ShowPlanKeyWithTies, Boolean.FalseString); } else { propertyListBuilder.Write(Resources.ShowPlanKeyWithTies, Boolean.TrueString); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupTieColumns, node.TieEntries); } IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Top, properties, inputElement); _currentElement = element; return node; }
public override AstNode VisitTableSpoolRefAlgebraNode(StackedTableSpoolRefAlgebraNode node) { PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, Resources.ShowPlanLogicalOperatorLazySpool); propertyListBuilder.Write(Resources.ShowPlanKeyWithStack, Boolean.TrueString); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.TableSpool, properties); _currentElement = element; return node; }
private static void AddDefinedValues(PropertyListBuilder builder, IEnumerable<AggregatedValueDefinition> definedValues) { builder.Begin(Resources.ShowPlanGroupDefinedValues); foreach (AggregatedValueDefinition definedValue in definedValues) { string source = String.Format(CultureInfo.InvariantCulture, "{0}({1})", definedValue.Aggregate.Name, definedValue.Argument.GenerateSource()); builder.Begin(); builder.SetGroupValue(String.Format(CultureInfo.InvariantCulture, "{0} = {1}", definedValue.Target.Name, source)); builder.Write(Resources.ShowPlanKeyTarget, definedValue.Target.Name); builder.Write(Resources.ShowPlanKeyDataType, definedValue.Target.DataType.Name); builder.Write(Resources.ShowPlanKeySource, source); builder.End(); } builder.End(); }
private static void AddDefinedValues(PropertyListBuilder builder, IEnumerable<UnitedValueDefinition> definedValues) { builder.Begin(Resources.ShowPlanGroupDefinedValues); foreach (UnitedValueDefinition definedValue in definedValues) { builder.Begin(definedValue.Target.Name); StringBuilder sb = new StringBuilder(); foreach (RowBufferEntry dependendValue in definedValue.DependendEntries) { builder.Begin(); builder.SetGroupValue(dependendValue.Name); WriteRowBufferEntry(builder, dependendValue); builder.End(); if (sb.Length > 0) sb.Append("; "); sb.Append(dependendValue.Name); } builder.SetGroupValue(sb.ToString()); builder.End(); } builder.End(); }
private static void AddRowBufferEntries(PropertyListBuilder builder, string groupName, IEnumerable<RowBufferEntry> rowBufferColumns) { builder.Begin(groupName); foreach (RowBufferEntry rowBufferColumn in rowBufferColumns) { builder.Begin(); builder.SetGroupValue(rowBufferColumn.Name); WriteRowBufferEntry(builder, rowBufferColumn); builder.End(); } builder.End(); }
private static void AddStatistics(PropertyListBuilder builder, StatisticsIterator iterator) { if (iterator != null) { int openCount = iterator.OpenCount; int rowCount = iterator.RowCount; int avgRowCount = (openCount == 0) ? 0 : (int) Math.Round(rowCount /(double)openCount, 0); builder.Begin(Resources.ShowPlanGroupStatistics); builder.Write(Resources.ShowPlanKeyStatisticsOpenCount, openCount.ToString("N0", CultureInfo.InvariantCulture)); builder.Write(Resources.ShowPlanKeyStatisticsRowCount, rowCount.ToString("N0", CultureInfo.InvariantCulture)); builder.Write(Resources.ShowPlanKeyStatisticsAverageRowCount, avgRowCount.ToString("N0", CultureInfo.InvariantCulture)); builder.End(); } }
private static void WriteRowBufferEntry(PropertyListBuilder builder, string groupName, RowBufferEntry rowBufferColumn) { builder.Begin(groupName); builder.SetGroupValue(rowBufferColumn.Name); WriteRowBufferEntry(builder, rowBufferColumn); builder.End(); }
public override AlgebraNode VisitJoinAlgebraNode(JoinAlgebraNode node) { ShowPlanElement leftElement = ConvertNode(node.Left); ShowPlanElement rightElement = ConvertNode(node.Right); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, LogicalOperatorToString(node.Op)); AddStatistics(propertyListBuilder, node.StatisticsIterator); if (node.Predicate != null) propertyListBuilder.Write(Resources.ShowPlanKeyPredicate, node.Predicate.GenerateSource()); if (node.OuterReferences != null && node.OuterReferences.Length > 0) AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOuterReferences, node.OuterReferences); if (node.ProbeBufferEntry != null) WriteRowBufferEntry(propertyListBuilder, Resources.ShowPlanKeyProbeColumn, node.ProbeBufferEntry); if (node.PassthruPredicate != null) propertyListBuilder.Write(Resources.ShowPlanKeyPassthru, node.PassthruPredicate.GenerateSource()); // We give a warning if a join has no predicate and no outer reference. // In this case the join would simply multiply the other side. // However, we supppress the warning if any side is known at produce at // most one row. if (node.Predicate == null && (node.OuterReferences == null || node.OuterReferences.Length == 0) && !AstUtil.WillProduceAtMostOneRow(node.Left) && !AstUtil.WillProduceAtMostOneRow(node.Right)) { propertyListBuilder.Write(Resources.ShowPlanKeyWarning, Resources.ShowPlanWarningNoJoinPredicate); } IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.NestedLoops, properties, leftElement, rightElement); _currentElement = element; return node; }
public override AlgebraNode VisitTableAlgebraNode(TableAlgebraNode node) { PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); propertyListBuilder.Write(Resources.ShowPlanKeyTable, String.Format(CultureInfo.InvariantCulture, "{0} AS {1}", node.TableRefBinding.TableBinding.Name, node.TableRefBinding.Name)); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.TableScan, properties); _currentElement = element; return node; }
public override AlgebraNode VisitConcatAlgebraNode(ConcatAlgebraNode node) { List<ShowPlanElement> inputList = new List<ShowPlanElement>(); foreach (AlgebraNode inputNode in node.Inputs) inputList.Add(ConvertNode(inputNode)); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); AddDefinedValues(propertyListBuilder, node.DefinedValues); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Concatenation, properties, inputList.ToArray()); _currentElement = element; return node; }
public override AlgebraNode VisitIndexSpoolAlgebraNode(IndexSpoolAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, Resources.ShowPlanLogicalOperatorEagerSpool); propertyListBuilder.Write(Resources.ShowPlanKeyWithStack, Boolean.FalseString); WriteRowBufferEntry(propertyListBuilder, Resources.ShowPlanKeyIndex, node.IndexEntry); propertyListBuilder.Write(Resources.ShowPlanKeyProbe, node.ProbeExpression.GenerateSource()); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.IndexSpool, properties, inputElement); _currentElement = element; return node; }
private void Initialize(bool isConfigured, EngineImportService engineImportService) { PropertyListBuilder propertyListBuilder = PropertyListBuilderFactory.CreateBuilder(_optionalLegacyDef); IList<InternalEventPropDescriptor> properties = propertyListBuilder.AssessProperties(_clazz); _propertyDescriptors = new EventPropertyDescriptor[properties.Count]; _propertyDescriptorMap = new Dictionary<string, EventPropertyDescriptor>(); _propertyNames = new string[properties.Count]; _simpleProperties = new Dictionary<string, SimplePropertyInfo>(); _mappedPropertyDescriptors = new Dictionary<string, InternalEventPropDescriptor>(); _indexedPropertyDescriptors = new Dictionary<string, InternalEventPropDescriptor>(); if (UsesSmartResolutionStyle) { _simpleSmartPropertyTable = new Dictionary<string, IList<SimplePropertyInfo>>(); _mappedSmartPropertyTable = new Dictionary<string, IList<SimplePropertyInfo>>(); _indexedSmartPropertyTable = new Dictionary<string, IList<SimplePropertyInfo>>(); } if ((_optionalLegacyDef == null) || (_optionalLegacyDef.CodeGeneration != CodeGenerationEnum.DISABLED)) { // get CGLib fast class using current thread class loader _fastClass = null; try { _fastClass = FastClass.Create(_clazz); } catch (Exception ex) { Log.Warn( ".initialize Unable to obtain CGLib fast class and/or method implementation for class " + _clazz.Name + ", error msg is " + ex.Message, ex); Log.Warn( ".initialize Not using the provided class loader, the error msg is: " + ex.Message, ex); _fastClass = null; } } int count = 0; foreach (InternalEventPropDescriptor desc in properties) { string propertyName = desc.PropertyName; Type underlyingType; Type componentType; bool isRequiresIndex; bool isRequiresMapkey; bool isIndexed; bool isMapped; bool isFragment; if (desc.PropertyType.Equals(EventPropertyType.SIMPLE)) { EventPropertyGetter getter; Type type; if (desc.ReadMethod != null) { getter = PropertyHelper.GetGetter(desc.PropertyName, desc.ReadMethod, _fastClass, _eventAdapterService); type = desc.ReadMethod.ReturnType; } else { if (desc.AccessorField == null) { // Ignore property continue; } getter = new ReflectionPropFieldGetter(desc.AccessorField, _eventAdapterService); type = desc.AccessorField.FieldType; } underlyingType = type; componentType = null; isRequiresIndex = false; isRequiresMapkey = false; isIndexed = false; isMapped = false; if (type.IsGenericDictionary()) { isMapped = true; // We do not yet allow to fragment maps entries. // Type genericType = TypeHelper.GetGenericReturnTypeMap(desc.ReadMethod, desc.AccessorField); isFragment = false; if (desc.ReadMethod != null) { componentType = TypeHelper.GetGenericReturnTypeMap(desc.ReadMethod, false); } else if (desc.AccessorField != null) { componentType = TypeHelper.GetGenericFieldTypeMap(desc.AccessorField, false); } else { componentType = typeof (object); } } else if (type.IsArray) { isIndexed = true; isFragment = TypeHelper.IsFragmentableType(type.GetElementType()); componentType = type.GetElementType(); } else if (type.IsImplementsInterface(typeof (IEnumerable))) { isIndexed = true; Type genericType = TypeHelper.GetGenericReturnType(desc.ReadMethod, desc.AccessorField, true); isFragment = genericType.IsFragmentableType(); if (genericType != null) { componentType = genericType; } else { componentType = typeof (Object); } } else { isMapped = false; isFragment = type.IsFragmentableType(); } _simpleProperties.Put(propertyName, new SimplePropertyInfo(type, getter, desc)); // Recognize that there may be properties with overlapping case-insentitive names if (UsesSmartResolutionStyle) { // Find the property in the smart property table string smartPropertyName = propertyName.ToLowerInvariant(); IList<SimplePropertyInfo> propertyInfoList = _simpleSmartPropertyTable.Get(smartPropertyName); if (propertyInfoList == null) { propertyInfoList = new List<SimplePropertyInfo>(); _simpleSmartPropertyTable.Put(smartPropertyName, propertyInfoList); } // Enter the property into the smart property list var propertyInfo = new SimplePropertyInfo(type, getter, desc); propertyInfoList.Add(propertyInfo); } } else if (desc.PropertyType.Equals(EventPropertyType.MAPPED)) { _mappedPropertyDescriptors.Put(propertyName, desc); underlyingType = desc.ReturnType; componentType = typeof (Object); isRequiresIndex = false; isRequiresMapkey = desc.ReadMethod.GetParameterTypes().Length > 0; isIndexed = false; isMapped = true; isFragment = false; // Recognize that there may be properties with overlapping case-insentitive names if (UsesSmartResolutionStyle) { // Find the property in the smart property table string smartPropertyName = propertyName.ToLowerInvariant(); IList<SimplePropertyInfo> propertyInfoList = _mappedSmartPropertyTable.Get(smartPropertyName); if (propertyInfoList == null) { propertyInfoList = new List<SimplePropertyInfo>(); _mappedSmartPropertyTable.Put(smartPropertyName, propertyInfoList); } // Enter the property into the smart property list var propertyInfo = new SimplePropertyInfo(desc.ReturnType, null, desc); propertyInfoList.Add(propertyInfo); } } else if (desc.PropertyType.Equals(EventPropertyType.INDEXED)) { _indexedPropertyDescriptors.Put(propertyName, desc); underlyingType = desc.ReturnType; componentType = null; isRequiresIndex = desc.ReadMethod.GetParameterTypes().Length > 0; isRequiresMapkey = false; isIndexed = true; isMapped = false; isFragment = desc.ReturnType.IsFragmentableType(); if (UsesSmartResolutionStyle) { // Find the property in the smart property table string smartPropertyName = propertyName.ToLowerInvariant(); IList<SimplePropertyInfo> propertyInfoList = _indexedSmartPropertyTable.Get(smartPropertyName); if (propertyInfoList == null) { propertyInfoList = new List<SimplePropertyInfo>(); _indexedSmartPropertyTable.Put(smartPropertyName, propertyInfoList); } // Enter the property into the smart property list var propertyInfo = new SimplePropertyInfo(desc.ReturnType, null, desc); propertyInfoList.Add(propertyInfo); } } else { continue; } _propertyNames[count] = desc.PropertyName; var descriptor = new EventPropertyDescriptor( desc.PropertyName, underlyingType, componentType, isRequiresIndex, isRequiresMapkey, isIndexed, isMapped, isFragment); _propertyDescriptors[count++] = descriptor; _propertyDescriptorMap.Put(descriptor.PropertyName, descriptor); } // Determine event type super types _superTypes = GetSuperTypes(_clazz, _eventAdapterService.BeanEventTypeFactory); if (_superTypes != null && _superTypes.Length == 0) { _superTypes = null; } if (_metadata != null && _metadata.TypeClass == TypeClass.NAMED_WINDOW) { _superTypes = null; } // Determine deep supertypes // Get super types (superclasses and interfaces), deep get of all in the tree var supers = new HashSet<Type>(); GetBase(_clazz, supers); RemoveLibInterfaces(supers); // Remove "java." super types // Cache the supertypes of this event type for later use _deepSuperTypes = new HashSet<EventType>(); foreach (Type superClass in supers) { EventType superType = _eventAdapterService.BeanEventTypeFactory.CreateBeanType( superClass.Name, superClass, false, false, isConfigured); _deepSuperTypes.Add(superType); } }
public override AlgebraNode VisitHashMatchAlgebraNode(HashMatchAlgebraNode node) { ShowPlanElement buildElement = ConvertNode(node.Left); ShowPlanElement probeElement = ConvertNode(node.Right); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); WriteRowBufferEntry(propertyListBuilder, Resources.ShowPlanKeyHashKeysBuild, node.BuildKeyEntry); WriteRowBufferEntry(propertyListBuilder, Resources.ShowPlanKeyHashKeysProbe, node.ProbeEntry); propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, LogicalOperatorToString(node.Op)); if (node.ProbeResidual != null) propertyListBuilder.Write(Resources.ShowPlanKeyProbeResidual, node.ProbeResidual.GenerateSource()); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.HashMatch, properties, buildElement, probeElement); _currentElement = element; return node; }