using System; using System.Collections; using BCG.Utilities; namespace BCG { public class DistinctRowEvaluator : GroupByEvaluator { private int myIdGenerator = 0; public DistinctRowEvaluator (string[] columnNames) : base (null, columnNames) {} public DistinctRowEvaluator(string colMapExpression, string[] columnNames) : base (colMapExpression, null, columnNames) {} public override IBlueRow evaluate (DataPacket packet) { myOutputTable = myOutputTable == null ? new GroupByOutputTable (packet.schema) : myOutputTable; string hashString = GroupByStream.getRepString (packet, myGroupByCols); if (packet.newRows.Count == 0) //if there are no rows for this group we remove the group from the output table myOutputTable.removeRow (hashString); else if (myOutputTable.getRow (hashString) == null) //a row is added for the first time (or first time after the removal of the group) myOutputTable.addRow ( BlueDataUtility.getNewReplacedRow ( BlueDataUtility.extractRow (packet.newRows, 0), myIdGenerator++, "id"), hashString); return myProject (myOutputTable.getRow (hashString)); } } }