示例#1
0
 internal void InitFrom(KeyVec left, KeyVec right)
 {
     if (left.m_noKeys ||
         right.m_noKeys)
     {
         m_noKeys = true;
     }
     else
     {
         m_noKeys = false;
         m_keys.InitFrom(left.m_keys);
         m_keys.Or(right.m_keys);
     }
 }
        protected override NodeInfo VisitSetOp(SetOp op, Node n)
        {
            ExtendedNodeInfo extendedNodeInfo1 = this.InitExtendedNodeInfo(n);

            extendedNodeInfo1.Definitions.InitFrom(op.Outputs);
            extendedNodeInfo1.LocalDefinitions.InitFrom(op.Outputs);
            ExtendedNodeInfo extendedNodeInfo2 = this.GetExtendedNodeInfo(n.Child0);
            ExtendedNodeInfo extendedNodeInfo3 = this.GetExtendedNodeInfo(n.Child1);
            RowCount         rowCount          = RowCount.Zero;

            extendedNodeInfo1.ExternalReferences.Or(extendedNodeInfo2.ExternalReferences);
            extendedNodeInfo1.ExternalReferences.Or(extendedNodeInfo3.ExternalReferences);
            if (op.OpType == OpType.UnionAll)
            {
                rowCount = extendedNodeInfo2.MinRows > extendedNodeInfo3.MinRows ? extendedNodeInfo2.MinRows : extendedNodeInfo3.MinRows;
            }
            if (op.OpType == OpType.Intersect || op.OpType == OpType.Except)
            {
                extendedNodeInfo1.Keys.InitFrom((IEnumerable <Var>)op.Outputs);
            }
            else
            {
                UnionAllOp unionAllOp = (UnionAllOp)op;
                if (unionAllOp.BranchDiscriminator == null)
                {
                    extendedNodeInfo1.Keys.NoKeys = true;
                }
                else
                {
                    VarVec varVec = this.m_command.CreateVarVec();
                    for (int index = 0; index < n.Children.Count; ++index)
                    {
                        ExtendedNodeInfo extendedNodeInfo4 = n.Children[index].GetExtendedNodeInfo(this.m_command);
                        if (!extendedNodeInfo4.Keys.NoKeys && !extendedNodeInfo4.Keys.KeyVars.IsEmpty)
                        {
                            VarVec other = extendedNodeInfo4.Keys.KeyVars.Remap((Dictionary <Var, Var>)unionAllOp.VarMap[index].GetReverseMap());
                            varVec.Or(other);
                        }
                        else
                        {
                            varVec.Clear();
                            break;
                        }
                    }
                    if (varVec.IsEmpty)
                    {
                        extendedNodeInfo1.Keys.NoKeys = true;
                    }
                    else
                    {
                        extendedNodeInfo1.Keys.InitFrom((IEnumerable <Var>)varVec);
                    }
                }
            }
            VarVec other1 = extendedNodeInfo2.NonNullableDefinitions.Remap((Dictionary <Var, Var>)op.VarMap[0].GetReverseMap());

            extendedNodeInfo1.NonNullableDefinitions.InitFrom(other1);
            if (op.OpType != OpType.Except)
            {
                VarVec other2 = extendedNodeInfo3.NonNullableDefinitions.Remap((Dictionary <Var, Var>)op.VarMap[1].GetReverseMap());
                if (op.OpType == OpType.Intersect)
                {
                    extendedNodeInfo1.NonNullableDefinitions.Or(other2);
                }
                else
                {
                    extendedNodeInfo1.NonNullableDefinitions.And(other2);
                }
            }
            extendedNodeInfo1.NonNullableDefinitions.And(op.Outputs);
            extendedNodeInfo1.MinRows = rowCount;
            return((NodeInfo)extendedNodeInfo1);
        }