Exemplo n.º 1
0
        // effects: Align the fields of each cell in mapping using projectedSlotMap that has a mapping
        // for each member of this extent to the slot number of that member in the projected slots
        // example:
        //    input:  Proj[A,B,"5"] = Proj[F,"7",G]
        //            Proj[C,B]     = Proj[H,I]
        //   output:  m_projectedSlotMap: A -> 0, B -> 1, C -> 2
        //            Proj[A,B,null] = Proj[F,"7",null]
        //            Proj[null,B,C] = Proj[null,I,H]
        private static List <Cell> AlignFields(IEnumerable <Cell> cells, MemberProjectionIndex projectedSlotMap,
                                               ViewTarget viewTarget)
        {
            List <Cell> outputCells = new List <Cell>();

            // Determine the aligned field for each cell
            // The new cells have ProjectedSlotMap.Count number of fields
            foreach (Cell cell in cells)
            {
                // If isQueryView is true, we need to consider the C side of
                // the cells; otherwise, we look at the S side. Note that we
                // CANNOT use cell.LeftQuery since that is determined by
                // cell's isQueryView

                // The query for which we are constructing the extent
                CellQuery mainQuery  = cell.GetLeftQuery(viewTarget);
                CellQuery otherQuery = cell.GetRightQuery(viewTarget);

                CellQuery newMainQuery;
                CellQuery newOtherQuery;
                // Create both queries where the projected slot map is used
                // to determine the order of the fields of the mainquery (of
                // course, the otherQuery's fields are aligned automatically)
                mainQuery.CreateFieldAlignedCellQueries(otherQuery, projectedSlotMap,
                                                        out newMainQuery, out newOtherQuery);

                Cell outputCell = viewTarget == ViewTarget.QueryView ?
                                  Cell.CreateCS(newMainQuery, newOtherQuery, cell.CellLabel, cell.CellNumber) :
                                  Cell.CreateCS(newOtherQuery, newMainQuery, cell.CellLabel, cell.CellNumber);
                outputCells.Add(outputCell);
            }
            return(outputCells);
        }