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)); }
private Node VisitNestOp(Node n) { NestBaseOp op = n.Op as NestBaseOp; SingleStreamNestOp singleStreamNestOp = op as SingleStreamNestOp; List <Node> args = this.ProcessChildren(n); Var discriminatorVar = (Var)null; if (singleStreamNestOp != null) { discriminatorVar = this.GetMappedVar(singleStreamNestOp.Discriminator); } List <CollectionInfo> collectionInfoList = new List <CollectionInfo>(); foreach (CollectionInfo collectionInfo1 in op.CollectionInfo) { ColumnMap columnMap = this.Copy(collectionInfo1.ColumnMap); Var computedVar = (Var)this.m_destCmd.CreateComputedVar(collectionInfo1.CollectionVar.Type); this.SetMappedVar(collectionInfo1.CollectionVar, computedVar); VarList flattenedElementVars = this.Copy(collectionInfo1.FlattenedElementVars); VarVec keys = this.Copy(collectionInfo1.Keys); List <SortKey> sortKeys = this.Copy(collectionInfo1.SortKeys); CollectionInfo collectionInfo2 = Command.CreateCollectionInfo(computedVar, columnMap, flattenedElementVars, keys, sortKeys, collectionInfo1.DiscriminatorValue); collectionInfoList.Add(collectionInfo2); } VarVec outputVars = this.Copy(op.Outputs); List <SortKey> prefixSortKeys = this.Copy(op.PrefixSortKeys); NestBaseOp nestBaseOp; if (singleStreamNestOp != null) { VarVec keys = this.Copy(singleStreamNestOp.Keys); List <SortKey> postfixSortKeys = this.Copy(singleStreamNestOp.PostfixSortKeys); nestBaseOp = (NestBaseOp)this.m_destCmd.CreateSingleStreamNestOp(keys, prefixSortKeys, postfixSortKeys, outputVars, collectionInfoList, discriminatorVar); } else { nestBaseOp = (NestBaseOp)this.m_destCmd.CreateMultiStreamNestOp(prefixSortKeys, outputVars, collectionInfoList); } return(this.m_destCmd.CreateNode((Op)nestBaseOp, args)); }