Exemplo n.º 1
0
        public IMatrixData ProcessData(IMatrixData[] inputData, Parameters parameters, ref IMatrixData[] supplTables,
                                       ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            IMatrixData mdata1 = inputData[0];
            IMatrixData mdata2 = inputData[1];

            ((int, int)first, (int, int)? second, bool outer, bool ignoreCase)matching =
                ParseMatchingColumns(parameters);
            (int[][] indexMap, int[] unmappedRightIndices) =
                GetIndexMap(mdata1, mdata2, matching.first, matching.second, matching.ignoreCase);
            IMatrixData result = (IMatrixData)mdata1.Clone();

            result.Origin = "Combination";
            if (matching.outer)
            {
                int[][] extendedIndexMap = new int[indexMap.Length + unmappedRightIndices.Length][];
                Array.Copy(indexMap, extendedIndexMap, indexMap.Length);
                for (int i = 0; i < unmappedRightIndices.Length; i++)
                {
                    int idx = indexMap.Length + i;
                    extendedIndexMap[idx] = new[] { unmappedRightIndices[i] };
                }
                result.AddEmptyRows(unmappedRightIndices.Length);
                UpdateIdColumns(result, mdata2, indexMap.Length, unmappedRightIndices, matching.first, matching.second);
                indexMap = extendedIndexMap;
            }
            bool addIndicator = parameters.GetParam <bool>("Add indicator").Value;

            if (addIndicator)
            {
                AddIndicator(result, mdata2, indexMap);
            }
            bool addRowIndex = parameters.GetParam <bool>("Add original row numbers").Value;

            if (addRowIndex)
            {
                result.AddMultiNumericColumn("Original row numbers", "",
                                             indexMap.Select(rows => rows.Select(Convert.ToDouble).ToArray()).ToArray());
            }
            ((int[] copy, int combine)main, int[] text, (int[] copy, int combine)numeric, int[] category) =
                ParseCopyParameters(parameters);
            SetAnnotationRows(result, mdata1, mdata2, main.copy);
            AddMainColumns(result, mdata2, indexMap, main.copy, GetAveraging(main.combine));
            AddAnnotationColumns(result, mdata2, indexMap, text, numeric, category);
            return(result);
        }