Beispiel #1
0
        private Node VisitNestOp(Node n)
        {
            var op    = n.Op as NestBaseOp;
            var ssnOp = op as SingleStreamNestOp;

            Debug.Assert(op != null);

            // Visit the Node's children and map their Vars
            var newChildren = ProcessChildren(n);

            Var newDiscriminator = null;

            if (ssnOp != null)
            {
                newDiscriminator = GetMappedVar(ssnOp.Discriminator);
            }
            var newCollectionInfoList = new List <CollectionInfo>();

            foreach (var ci in op.CollectionInfo)
            {
                var newColumnMap = Copy(ci.ColumnMap);

                Var newCollectionVar = m_destCmd.CreateComputedVar(ci.CollectionVar.Type);
                SetMappedVar(ci.CollectionVar, newCollectionVar);

                var newFlattendElementVars = Copy(ci.FlattenedElementVars);
                var newKeys           = Copy(ci.Keys);
                var newSortKeys       = Copy(ci.SortKeys);
                var newCollectionInfo = Command.CreateCollectionInfo(
                    newCollectionVar, newColumnMap, newFlattendElementVars, newKeys, newSortKeys, ci.DiscriminatorValue);
                newCollectionInfoList.Add(newCollectionInfo);
            }

            var newOutputs = Copy(op.Outputs);

            NestBaseOp newOp             = null;
            var        newPrefixSortKeys = Copy(op.PrefixSortKeys);

            if (ssnOp != null)
            {
                var newKeys = Copy(ssnOp.Keys);
                // Copy the SortOp's SortKeys
                var newPostfixSortKeys = Copy(ssnOp.PostfixSortKeys);
                newOp = m_destCmd.CreateSingleStreamNestOp(
                    newKeys, newPrefixSortKeys, newPostfixSortKeys, newOutputs, newCollectionInfoList, newDiscriminator);
            }
            else
            {
                newOp = m_destCmd.CreateMultiStreamNestOp(newPrefixSortKeys, newOutputs, newCollectionInfoList);
            }

            return(m_destCmd.CreateNode(newOp, newChildren));
        }