1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.DataImporter.Data;
|
---|
6 | using HeuristicLab.DataImporter.Data.CommandBase;
|
---|
7 | using HeuristicLab.DataImporter.Data.Model;
|
---|
8 | using HeuristicLab.DataImporter.Command.View;
|
---|
9 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
10 |
|
---|
11 | namespace HeuristicLab.DataImporter.Command {
|
---|
12 | [StorableClass]
|
---|
13 | [ViewableCommandInfoAttribute("Minimum", 1, ColumnGroupState.DoubleColumnSelected | ColumnGroupState.AnySelectedColumnNotSorted,
|
---|
14 | "Aggregation", Position = 3, OptionsView = typeof(AggregationCommandView))]
|
---|
15 | public class AggregateWithMinCommand : AggregateCommandBase {
|
---|
16 |
|
---|
17 | private AggregateWithMinCommand()
|
---|
18 | : base(null, string.Empty, null) {
|
---|
19 | }
|
---|
20 |
|
---|
21 | public AggregateWithMinCommand(DataSet dataSet, string columnGroupName, int[] affectedColumns)
|
---|
22 | : base(dataSet, columnGroupName, affectedColumns) {
|
---|
23 | }
|
---|
24 |
|
---|
25 | public override string Description {
|
---|
26 | get { return "Aggregate with min function"; }
|
---|
27 | }
|
---|
28 |
|
---|
29 | protected override IComparable AggregationFunction(ColumnBase col, int startIndex, int endIndex) {
|
---|
30 | IComparable minValue = null;
|
---|
31 | IComparable val;
|
---|
32 | for (int i = startIndex; i < endIndex; i++) {
|
---|
33 | val = col.GetValue(i);
|
---|
34 | if (val != null) {
|
---|
35 | if (minValue == null || val.CompareTo(minValue) < 0)
|
---|
36 | minValue = val;
|
---|
37 | }
|
---|
38 | }
|
---|
39 | return minValue;
|
---|
40 | }
|
---|
41 | }
|
---|
42 | }
|
---|