protected override void VisitSortOp(SortBaseOp op, Node n)
 {
     using (new Dump.AutoXml(this, "keys"))
     {
         foreach (SortKey key in op.Keys)
         {
             using (new Dump.AutoXml(this, "sortKey", new Dictionary <string, object>()
             {
                 {
                     "Var",
                     (object)key.Var
                 },
                 {
                     "Ascending",
                     (object)key.AscendingSort
                 },
                 {
                     "Collation",
                     (object)key.Collation
                 }
             }))
                 ;
         }
     }
     this.VisitChildren(n);
 }
Exemple #2
0
        protected override void VisitSortOp(SortBaseOp op, Node n)
        {
            using (new AutoXml(this, "keys"))
            {
                foreach (var sortKey in op.Keys)
                {
                    var attrs = new Dictionary <string, object>();
                    attrs.Add("Var", sortKey.Var);
                    attrs.Add("Ascending", sortKey.AscendingSort);
                    attrs.Add("Collation", sortKey.Collation);

                    using (new AutoXml(this, "sortKey", attrs))
                    {
                    }
                }
            }
            VisitChildren(n);
        }
Exemple #3
0
        /// <summary>
        ///     Computes a NodeInfo for a ConstrainedSortOp/SortOp.
        ///     Definitions = Definitions of the input Relop
        ///     LocalDefinitions = not allowed
        ///     Keys = Keys of the input Relop
        ///     External References = any external references from the input + any external
        ///     references from the keys
        ///     RowCount = Input's RowCount
        ///     NonNullabeDefinitions = NonNullabeDefinitions of the input RelOp
        ///     NonNullableInputDefinitions = NonNullabeDefinitions of the input RelOp
        /// </summary>
        /// <param name="op"> The SortOp </param>
        /// <param name="n"> corresponding Node </param>
        protected override NodeInfo VisitSortOp(SortBaseOp op, Node n)
        {
            var nodeInfo           = InitExtendedNodeInfo(n);
            var relOpChildNodeInfo = GetExtendedNodeInfo(n.Child0);

            // definitions are my child's definitions
            nodeInfo.Definitions.Or(relOpChildNodeInfo.Definitions);

            // My references are my child's external references + those made
            // by my sort keys
            nodeInfo.ExternalReferences.Or(relOpChildNodeInfo.ExternalReferences);
            nodeInfo.ExternalReferences.Minus(relOpChildNodeInfo.Definitions);

            // my keys are my child's keys
            nodeInfo.Keys.InitFrom(relOpChildNodeInfo.Keys);

            //Non-nullable definitions are same as the input
            nodeInfo.NonNullableDefinitions.InitFrom(relOpChildNodeInfo.NonNullableDefinitions);
            nodeInfo.NonNullableVisibleDefinitions.InitFrom(relOpChildNodeInfo.NonNullableDefinitions);

            //Row counts are same as the input
            nodeInfo.InitRowCountFrom(relOpChildNodeInfo);

            // For constrained sort, if the Limit value is Constant(1) and WithTies is false,
            // then MinRows and MaxRows can be adjusted to 0, 1.
            if (OpType.ConstrainedSort == op.OpType
                &&
                OpType.Constant == n.Child2.Op.OpType
                &&
                !((ConstrainedSortOp)op).WithTies)
            {
                var constOp = (ConstantBaseOp)n.Child2.Op;
                if (TypeHelpers.IsIntegerConstant(constOp.Type, constOp.Value, 1))
                {
                    nodeInfo.SetRowCount(RowCount.Zero, RowCount.One);
                }
            }

            return(nodeInfo);
        }
        protected override NodeInfo VisitSortOp(SortBaseOp op, Node n)
        {
            ExtendedNodeInfo extendedNodeInfo1 = this.InitExtendedNodeInfo(n);
            ExtendedNodeInfo extendedNodeInfo2 = this.GetExtendedNodeInfo(n.Child0);

            extendedNodeInfo1.Definitions.Or(extendedNodeInfo2.Definitions);
            extendedNodeInfo1.ExternalReferences.Or(extendedNodeInfo2.ExternalReferences);
            extendedNodeInfo1.ExternalReferences.Minus(extendedNodeInfo2.Definitions);
            extendedNodeInfo1.Keys.InitFrom(extendedNodeInfo2.Keys);
            extendedNodeInfo1.NonNullableDefinitions.InitFrom(extendedNodeInfo2.NonNullableDefinitions);
            extendedNodeInfo1.NonNullableVisibleDefinitions.InitFrom(extendedNodeInfo2.NonNullableDefinitions);
            extendedNodeInfo1.InitRowCountFrom(extendedNodeInfo2);
            if (OpType.ConstrainedSort == op.OpType && n.Child2.Op.OpType == OpType.Constant && !((ConstrainedSortOp)op).WithTies)
            {
                ConstantBaseOp op1 = (ConstantBaseOp)n.Child2.Op;
                if (TypeHelpers.IsIntegerConstant(op1.Type, op1.Value, 1L))
                {
                    extendedNodeInfo1.SetRowCount(RowCount.Zero, RowCount.One);
                }
            }
            return((NodeInfo)extendedNodeInfo1);
        }
 /// <summary>
 ///     Default handler for all SortOps
 /// </summary>
 /// <param name="op"> sort op </param>
 /// <param name="n"> </param>
 protected virtual void VisitSortOp(SortBaseOp op, Node n)
 {
     VisitRelOpDefault(op, n);
 }
 protected override void VisitSortOp(SortBaseOp op, Node n)
 {
     VisitRelOpDefault(op, n);
     AssertRelOpOrPhysicalOp(n.Child0.Op);
 }
        /// <summary>
        ///     SortOp handling 
        /// 
        ///     First, "request" that for any sort key that is a structured type, we 
        ///     need all its properties. Then process any local definitions, and 
        ///     finally the relop input
        /// </summary>
        /// <param name="op"> </param>
        /// <param name="n"> </param>
        protected override void VisitSortOp(SortBaseOp op, Node n)
        {
            // foreach sort key, every single bit of the Var is needed
            foreach (var sk in op.Keys)
            {
                if (TypeUtils.IsStructuredType(sk.Var.Type))
                {
                    AddPropertyRefs(sk.Var, PropertyRefList.All);
                }
            }

            // if the sort has any local definitions, process those first
            if (n.HasChild1)
            {
                VisitNode(n.Child1);
            }
            // then process the relop input
            VisitNode(n.Child0);
        }
 protected override void VisitSortOp(SortBaseOp op, Node n)
 {
     VisitRelOpDefault(op, n);
     Map(op.Keys);
 }
 protected virtual void VisitSortOp(SortBaseOp op, Node n)
 {
     this.VisitRelOpDefault((RelOp)op, n);
 }
Exemple #10
0
 protected override void VisitSortOp(SortBaseOp op, Node n)
 {
     VisitRelOpDefault(op, n);
     AssertRelOpOrPhysicalOp(n.Child0.Op);
 }
Exemple #11
0
 protected virtual void VisitSortOp(SortBaseOp op, Node n)
 {
     VisitRelOpDefault(op, n);
 }
Exemple #12
0
 // <summary>
 // A default processor for all SortOps.
 // Allows new visitors to just override this to handle ConstrainedSortOp/SortOp.
 // </summary>
 // <param name="op"> the SetOp </param>
 // <param name="n"> the node to process </param>
 // <returns> a potentially modified subtree </returns>
 protected virtual TResultType VisitSortOp(SortBaseOp op, Node n)
 {
     return(VisitRelOpDefault(op, n));
 }