/// <summary> /// Get OptimizerPatterns annotation for the specified node. Lazily create if necessary. /// </summary> public static OptimizerPatterns Read(QilNode nd) { XmlILAnnotation ann = nd.Annotation as XmlILAnnotation; OptimizerPatterns optPatt = (ann != null) ? ann.Patterns : null; if (optPatt == null) { if (!nd.XmlType.MaybeMany) { // Expressions with ZeroOrOne cardinality should always report IsDocOrderDistinct and NoContainedNodes if (s_zeroOrOneDefault == null) { optPatt = new OptimizerPatterns(); optPatt.AddPattern(OptimizerPatternName.IsDocOrderDistinct); optPatt.AddPattern(OptimizerPatternName.SameDepth); optPatt._isReadOnly = true; s_zeroOrOneDefault = optPatt; } else { optPatt = s_zeroOrOneDefault; } } else if (nd.XmlType.IsDod) { if (s_dodDefault == null) { optPatt = new OptimizerPatterns(); optPatt.AddPattern(OptimizerPatternName.IsDocOrderDistinct); optPatt._isReadOnly = true; s_dodDefault = optPatt; } else { optPatt = s_dodDefault; } } else { if (s_maybeManyDefault == null) { optPatt = new OptimizerPatterns(); optPatt._isReadOnly = true; s_maybeManyDefault = optPatt; } else { optPatt = s_maybeManyDefault; } } } return(optPatt); }
/// <summary> /// Get OptimizerPatterns annotation for the specified node. Lazily create if necessary. /// </summary> public static OptimizerPatterns Read(QilNode nd) { XmlILAnnotation ann = nd.Annotation as XmlILAnnotation; OptimizerPatterns optPatt = (ann != null) ? ann.Patterns : null; if (optPatt == null) { if (!nd.XmlType.MaybeMany) { // Expressions with ZeroOrOne cardinality should always report IsDocOrderDistinct and NoContainedNodes if (s_zeroOrOneDefault == null) { optPatt = new OptimizerPatterns(); optPatt.AddPattern(OptimizerPatternName.IsDocOrderDistinct); optPatt.AddPattern(OptimizerPatternName.SameDepth); optPatt._isReadOnly = true; s_zeroOrOneDefault = optPatt; } else { optPatt = s_zeroOrOneDefault; } } else if (nd.XmlType.IsDod) { if (s_dodDefault == null) { optPatt = new OptimizerPatterns(); optPatt.AddPattern(OptimizerPatternName.IsDocOrderDistinct); optPatt._isReadOnly = true; s_dodDefault = optPatt; } else { optPatt = s_dodDefault; } } else { if (s_maybeManyDefault == null) { optPatt = new OptimizerPatterns(); optPatt._isReadOnly = true; s_maybeManyDefault = optPatt; } else { optPatt = s_maybeManyDefault; } } } return optPatt; }
/// <summary> /// Create and initialize OptimizerPatterns annotation for the specified node. /// </summary> public static OptimizerPatterns Write(QilNode nd) { XmlILAnnotation ann = XmlILAnnotation.Write(nd); OptimizerPatterns optPatt = ann.Patterns; if (optPatt == null || optPatt._isReadOnly) { optPatt = new OptimizerPatterns(); ann.Patterns = optPatt; if (!nd.XmlType.MaybeMany) { optPatt.AddPattern(OptimizerPatternName.IsDocOrderDistinct); optPatt.AddPattern(OptimizerPatternName.SameDepth); } else if (nd.XmlType.IsDod) { optPatt.AddPattern(OptimizerPatternName.IsDocOrderDistinct); } } return(optPatt); }
/// <summary> /// Create and initialize OptimizerPatterns annotation for the specified node. /// </summary> public static void Inherit(QilNode ndSrc, QilNode ndDst, OptimizerPatternName pattern) { OptimizerPatterns annSrc = OptimizerPatterns.Read(ndSrc); if (annSrc.MatchesPattern(pattern)) { OptimizerPatterns annDst = OptimizerPatterns.Write(ndDst); annDst.AddPattern(pattern); // Inherit pattern arguments switch (pattern) { case OptimizerPatternName.Step: annDst.AddArgument(OptimizerPatternArgument.StepNode, annSrc.GetArgument(OptimizerPatternArgument.StepNode)); annDst.AddArgument(OptimizerPatternArgument.StepInput, annSrc.GetArgument(OptimizerPatternArgument.StepInput)); break; case OptimizerPatternName.FilterElements: annDst.AddArgument(OptimizerPatternArgument.ElementQName, annSrc.GetArgument(OptimizerPatternArgument.ElementQName)); break; case OptimizerPatternName.FilterContentKind: annDst.AddArgument(OptimizerPatternArgument.KindTestType, annSrc.GetArgument(OptimizerPatternArgument.KindTestType)); break; case OptimizerPatternName.EqualityIndex: annDst.AddArgument(OptimizerPatternArgument.IndexedNodes, annSrc.GetArgument(OptimizerPatternArgument.IndexedNodes)); annDst.AddArgument(OptimizerPatternArgument.KeyExpression, annSrc.GetArgument(OptimizerPatternArgument.KeyExpression)); break; case OptimizerPatternName.DodReverse: case OptimizerPatternName.JoinAndDod: annDst.AddArgument(OptimizerPatternArgument.DodStep, annSrc.GetArgument(OptimizerPatternArgument.DodStep)); break; case OptimizerPatternName.MaxPosition: annDst.AddArgument(OptimizerPatternArgument.MaxPosition, annSrc.GetArgument(OptimizerPatternArgument.MaxPosition)); break; case OptimizerPatternName.SingleTextRtf: annDst.AddArgument(OptimizerPatternArgument.RtfText, annSrc.GetArgument(OptimizerPatternArgument.RtfText)); break; } } }
/// <summary> /// Create and initialize OptimizerPatterns annotation for the specified node. /// </summary> public static OptimizerPatterns Write(QilNode nd) { XmlILAnnotation ann = XmlILAnnotation.Write(nd); OptimizerPatterns optPatt = ann.Patterns; if (optPatt == null || optPatt.isReadOnly) { optPatt = new OptimizerPatterns(); ann.Patterns = optPatt; if (!nd.XmlType.MaybeMany) { optPatt.AddPattern(OptimizerPatternName.IsDocOrderDistinct); optPatt.AddPattern(OptimizerPatternName.SameDepth); } else if (nd.XmlType.IsDod) { optPatt.AddPattern(OptimizerPatternName.IsDocOrderDistinct); } } return optPatt; }