protected static Double doTupleWork(Tuple input, KnownOpProvider opProvider) throws ExecException { DataBag values = (DataBag)input.get(0); // if we were handed an empty bag, return NULL // this is in compliance with SQL standard if(values == null || values.size() == 0) { return null; } double sofar = AlgebraicDoubleMathBase.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; Double d = n.doubleValue(); sawNonNull = true; sofar = doWork(sofar, d, opProvider.getOp()); }catch(RuntimeException exp) { int errCode = 2103; throw new ExecException("Problem doing work on Doubles", errCode, PigException.BUG, exp); } } return sawNonNull ? sofar : null; }
protected static Float doTupleWork(Tuple input, KnownOpProvider opProvider) throws ExecException { DataBag values = (DataBag)input.get(0); // if we were handed an empty bag, return NULL // this is in compliance with SQL standard if(values == null || values.size() == 0) { return null; } Float sofar = AlgebraicFloatMathBase.getSeed(opProvider.getOp()); boolean sawNonNull = false; for (Iterator<Tuple> it = values.iterator(); it.hasNext();) { Tuple t = it.next(); try { Float d = (Float)(t.get(0)); if (d == null) continue; sawNonNull = true; sofar = doWork(sofar, d, opProvider.getOp()); }catch(RuntimeException exp) { int errCode = 2103; throw new ExecException("Problem doing work on Floats", errCode, PigException.BUG, exp); } } return sawNonNull ? sofar : null; }
protected static Long doTupleWork(Tuple input, KnownOpProvider opProvider) throws ExecException { DataBag values = (DataBag)input.get(0); // if we were handed an empty bag, return NULL // this is in compliance with SQL standard if(values == null || values.size() == 0) { return null; } Long sofar = AlgebraicLongMathBase.getSeed(opProvider.getOp()); boolean sawNonNull = false; for (Iterator<Tuple> it = values.iterator(); it.hasNext();) { Tuple t = it.next(); try { // Note: use Number.longValue() instead of casting to Long // to allow Integers, too. Number n = ((Number)(t.get(0))); if (n == null) continue; Long d = n.longValue(); sawNonNull = true; sofar = doWork(sofar, d, opProvider.getOp()); }catch(RuntimeException exp) { int errCode = 2103; throw new ExecException("Problem doing work on Longs", errCode, PigException.BUG, exp); } } return sawNonNull ? sofar : null; }
protected static BigDecimal doTupleWork(Tuple input, KnownOpProvider opProvider) throws ExecException { DataBag values = (DataBag)input.get(0); // if we were handed an empty bag, return NULL // this is in compliance with SQL standard 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; }
protected static BigInteger doTupleWork(Tuple input, KnownOpProvider opProvider) throws ExecException { DataBag values = (DataBag)input.get(0); // if we were handed an empty bag, return NULL // this is in compliance with SQL standard if(values == null || values.size() == 0) { return null; } BigInteger sofar = AlgebraicBigIntegerMathBase.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; BigInteger d = (BigInteger) n; sawNonNull = true; sofar = doWork(sofar, d, opProvider.getOp()); } catch(RuntimeException exp) { int errCode = 2103; throw new ExecException("Problem doing work on BigInteger", errCode, PigException.BUG, exp); } } return sawNonNull ? sofar : null; }
protected static Integer doTupleWork(Tuple input, KnownOpProvider opProvider) throws ExecException { DataBag values = (DataBag)input.get(0); // if we were handed an empty bag, return NULL // this is in compliance with SQL standard if(values == null || values.size() == 0) { return null; } int sofar = AlgebraicIntMathBase.getSeed(opProvider.getOp()); boolean sawNonNull = false; for (Iterator<Tuple> it = values.iterator(); it.hasNext();) { Tuple t = it.next(); try { Integer d = (Integer)(t.get(0)); if (d == null) continue; sawNonNull = true; sofar = doWork(sofar, d, opProvider.getOp()); }catch(RuntimeException exp) { int errCode = 2103; throw new ExecException("Problem doing work on Doubles", errCode, PigException.BUG, exp); } } return sawNonNull ? sofar : null; }
@Override public void accumulate(Tuple b) throws IOException { try { Long curVal = doTupleWork(b, opProvider); if (curVal == null) { return; } if (intermediateVal == null) { intermediateVal = getSeed(opProvider.getOp()); } intermediateVal = doWork(intermediateVal, curVal, opProvider.getOp()); } catch (ExecException ee) { throw ee; } catch (Exception e) { int errCode = 2106; throw new ExecException("Error executing function on Longs", errCode, PigException.BUG, e); } }
@Override public void accumulate(Tuple b) throws IOException { try { BigDecimal curVal = doTupleWork(b, opProvider); if (curVal == null) { return; } if (intermediateVal == null) { intermediateVal = getSeed(opProvider.getOp()); } intermediateVal = doWork(intermediateVal, curVal, opProvider.getOp()); } catch (ExecException ee) { throw ee; } catch (Exception e) { int errCode = 2106; throw new ExecException("Error executing function on BigDecimal", errCode, PigException.BUG, e); } }
@Override public void accumulate(Tuple b) throws IOException { try { Double curVal = doTupleWork(b, opProvider); if (curVal == null) { return; } if (intermediateVal == null) { intermediateVal = getSeed(opProvider.getOp()); } intermediateVal = doWork(intermediateVal, curVal, opProvider.getOp()); } catch (ExecException ee) { throw ee; } catch (Exception e) { int errCode = 2106; throw new ExecException("Error executing function on Doubles", errCode, PigException.BUG, e); } }
@Override public void accumulate(Tuple b) throws IOException { try { Float curVal = doTupleWork(b, opProvider); if (curVal == null) { return; } if (intermediateVal == null) { intermediateVal = getSeed(opProvider.getOp()); } intermediateVal = doWork(intermediateVal, curVal, opProvider.getOp()); } catch (ExecException ee) { throw ee; } catch (Exception e) { int errCode = 2106; throw new ExecException("Error executing function on Floats", errCode, PigException.BUG, e); } }
@Override public void accumulate(Tuple b) throws IOException { try { Integer curVal = doTupleWork(b, opProvider); if (curVal == null) { return; } if (intermediateVal == null) { intermediateVal = getSeed(opProvider.getOp()); } intermediateVal = doWork(intermediateVal, curVal, opProvider.getOp()); } catch (ExecException ee) { throw ee; } catch (Exception e) { int errCode = 2106; throw new ExecException("Error executing function on Doubles", errCode, PigException.BUG, e); } }
@Override public void accumulate(Tuple b) throws IOException { try { BigInteger curVal = doTupleWork(b, opProvider); if (curVal == null) { return; } if (intermediateVal == null) { intermediateVal = getSeed(opProvider.getOp()); } intermediateVal = doWork(intermediateVal, curVal, opProvider.getOp()); } catch (ExecException ee) { throw ee; } catch (Exception e) { int errCode = 2106; throw new ExecException("Error executing function on BigInteger", errCode, PigException.BUG, e); } }
@Override public void accumulate(Tuple b) throws IOException { try { Double curVal = doTupleWork(b, opProvider, DataType.BYTEARRAY); if (curVal == null) { return; } if (intermediateVal == null) { intermediateVal = getSeed(opProvider.getOp()); } intermediateVal = doWork(intermediateVal, curVal, opProvider.getOp()); } catch (ExecException ee) { throw ee; } catch (Exception e) { int errCode = 2106; throw new ExecException("Error executing function on Doubles", errCode, PigException.BUG, e); } }