37 lines
1.7 KiB
C#
37 lines
1.7 KiB
C#
using System;
|
|
|
|
using BCG.Utilities;
|
|
|
|
namespace BCG {
|
|
public class MinGroupByEvaluator : MaxGroupByEvaluator {
|
|
public MinGroupByEvaluator(string outputCol, string[] groupByCols)
|
|
: base(outputCol, groupByCols) { }
|
|
|
|
public MinGroupByEvaluator(string colMapEpression, string outputCol, string[] groupByCols) :
|
|
base(colMapEpression, outputCol, groupByCols) { }
|
|
|
|
public override IBlueRow evaluate(DataPacket dp) {
|
|
myOutputTable = myOutputTable == null ? new GroupByOutputTable(dp.schema) : myOutputTable;
|
|
string stringRep = BlueDataUtility.rowToString(GroupByStream.getRepRow(dp), myGroupByCols);
|
|
IBlueRow currMinRow = myOutputTable.getRow(stringRep);
|
|
IBlueRow minRow = BlueDataUtility.computeMinRow(dp.deletedRows, myOutputColumn);
|
|
if (minRow != null) {
|
|
// BlueEventLog.logAssert (currMinRow != null);
|
|
// BlueEventLog.logAssert (BlueDataUtility.compareRows (minRow, currMinRow, myOutputColumn) >= 0);
|
|
if (BlueDataUtility.compareRows(minRow, currMinRow, myOutputColumn) == 0) {
|
|
minRow = BlueDataUtility.computeMinRow(dp.newRows, myOutputColumn);
|
|
if (minRow == null)
|
|
myOutputTable.removeRow(stringRep);
|
|
else
|
|
myOutputTable.addRow(minRow, stringRep);
|
|
}
|
|
}
|
|
minRow = BlueDataUtility.computeMinRow(dp.addedRows, myOutputColumn);
|
|
if (minRow != null && (currMinRow == null || BlueDataUtility.compareRows(minRow, currMinRow, myOutputColumn) < 0))
|
|
myOutputTable.addRow(minRow, stringRep);
|
|
return myOutputTable.getRow(stringRep);
|
|
}
|
|
|
|
}
|
|
}
|