protected static BigDecimal doTupleWork(Tuple input, KnownOpProvider opProvider) throws ExecException {
DataBag values = (DataBag)input.get(0);
if(values == null || values.size() == 0) {
return null;
}
BigDecimal sofar = AlgebraicBigDecimalMathBase.getSeed(opProvider.getOp());
boolean sawNonNull = false;
for (Iterator<Tuple> it = values.iterator(); it.hasNext();) {
Tuple t = it.next();
try {
Number n = (Number)(t.get(0));
if (n == null) continue;
BigDecimal d = (BigDecimal) n;
sawNonNull = true;
sofar = doWork(sofar, d, opProvider.getOp());
}catch(RuntimeException exp) {
int errCode = 2103;
throw new ExecException("Problem doing work on BigDecimal", errCode, PigException.BUG, exp);
}
}
return sawNonNull ? sofar : null;
}