prerna.algorithm.impl.MinReactor Maven / Gradle / Ivy
package prerna.algorithm.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
import prerna.util.ArrayUtilityMethods;
public class MinReactor extends BaseReducerReactor {
public MinReactor() {
setMathRoutine("Min");
}
@Override
public Object reduce() {
double output = 0.0;
if(inputIterator.hasNext() && !errored) {
ArrayList row = (ArrayList)getNextValue();
if(row.get(0) instanceof Number) {
output = ((Number)row.get(0)).doubleValue();
}
while(inputIterator.hasNext()) {
ArrayList dec = (ArrayList)getNextValue();
if(dec.get(0) instanceof Number) {
double value = ((Number)dec.get(0)).doubleValue();
if(value < output) {
output = value;
}
}
}
}
System.out.println(output);
return output;
}
@Override
public HashMap,Object> reduceGroupBy(Vector groupBys, Vector processedColumns, String[] columnsArray, Iterator it) {
HashMap, Object> groupByHash = new HashMap,Object>();
while(it.hasNext()){
Object[] row = (Object[]) it.next();
HashMap