예제 #1
0
        protected TransformResults Transform(CancellationToken cancellationToken, DataSchema dataSchema, TransformResults input,
                                             TransformStack transformStack)
        {
            if (transformStack == null || transformStack.StackIndex >= transformStack.RowTransforms.Count)
            {
                return(input);
            }
            cancellationToken.ThrowIfCancellationRequested();
            if (transformStack.Predecessor != null)
            {
                input = Transform(cancellationToken, dataSchema, input, transformStack.Predecessor);
            }
            var filter = transformStack.CurrentTransform as RowFilter;

            if (filter != null)
            {
                var filteredRows = new PivotedRows(Filter(cancellationToken, dataSchema, filter, input.PivotedRows),
                                                   input.PivotedRows.ItemProperties);
                filteredRows = Sort(cancellationToken, dataSchema, filter, filteredRows);
                return(new TransformResults(input, filter, filteredRows));
            }
            var pivotSpec = transformStack.CurrentTransform as PivotSpec;

            if (pivotSpec != null)
            {
                var pivotedRows = GroupAndTotaler.GroupAndTotal(cancellationToken, dataSchema, pivotSpec, input.PivotedRows);
                return(new TransformResults(input, pivotSpec, pivotedRows));
            }
            return(input);
        }
예제 #2
0
        public static PivotedRows GroupAndTotal(CancellationToken cancellationToken, DataSchema dataSchema,
                                                PivotSpec pivotSpec, PivotedRows input)
        {
            if (pivotSpec.IsEmpty)
            {
                return(input);
            }
            var groupAndTotaller = new GroupAndTotaler(cancellationToken, dataSchema, pivotSpec, input.ItemProperties);
            var newProperties    = new List <DataPropertyDescriptor>();
            var newRows          = ImmutableList.ValueOf(groupAndTotaller.GroupAndTotal(input.RowItems, newProperties));

            return(new PivotedRows(newRows, newProperties));
        }