@Override public ValueDouble asDouble() { return orig.asDouble(); }
/** * @param s1 * @param s2 * @return */ private int doubleCompare(ValueObject s1, ValueObject s2) { if (s1 == s2) { return 0; } if (s1 == null) { return 1; } if (s2 == null) { return -1; } return Double.compare(ValueUtil.asNumberOrParseDouble(s1).asDouble().getDouble(), ValueUtil.asNumberOrParseDouble(s2).asDouble().getDouble()); }
/** * @param s1 * @param s2 * @return */ private static int doubleCompare(ValueObject s1, ValueObject s2) { if (s1 == s2) { return 0; } if (s1 == null) { return 1; } if (s2 == null) { return -1; } return Double.compare(ValueUtil.asNumberOrParseDouble(s1).asDouble().getDouble(), ValueUtil.asNumberOrParseDouble(s2).asDouble().getDouble()); }
@Override public Numeric min(Numeric val) { if (val.asDouble().getDouble() < asDouble().getDouble()) { return val; } else { return this; } }
@Override public ValueDouble diff(Numeric val) { return sum(val).asDouble().diff(asDouble()); }
@Override public Numeric max(Numeric val) { if (val.asDouble().getDouble() > asDouble().getDouble()) { return val; } else { return this; } }
@Override public ValueDouble prod(Numeric val) { return sum(val).asDouble().prod(asDouble()); }
@Override public ValueDouble divide(Numeric val) { return sum(val).asDouble().divide(asDouble()); }
if (v1 == vector) { v1 = stack.pop(); double mult = v1.asDouble().getDouble(); while (!stack.isEmpty()) { mult *= stack.pop().asDouble().getDouble(); double mult = v1.asDouble().getDouble() * v2.asDouble().getDouble(); stack.push(ValueFactory.create(mult)); v1 = stack.pop(); v2 = stack.pop(); if (!diverr && v1.asDouble().getDouble() == 0d) { stack.push(ValueFactory.create(0)); } else { stack.push(ValueFactory.create(v2.asDouble().getDouble() / v1.asDouble().getDouble())); stack.push(ValueFactory.create(Math.log10(stack.pop().asDouble().getDouble()))); break; case OP_SQRT: stack.push(ValueFactory.create(Math.sqrt(stack.pop().asDouble().getDouble()))); break; case OP_VAL: break; case OP_TOFLOAT: stack.push(ValueUtil.asNumberOrParseDouble(stack.pop()).asDouble()); break; case OP_BITS_TOINT: long bits = Double.doubleToLongBits(stack.pop().asDouble().getDouble());
@Override public boolean updateChildData(DataTreeNodeUpdater state, DataTreeNode tn, DataSumFloat.Config conf) { if (keyAccess == null && conf.key != null) { keyAccess = state.getBundle().getFormat().getField(conf.key); } if (keyAccess != null) { ValueObject kv = state.getBundle().getValue(keyAccess); if (kv != null) { try { double value = ValueUtil.asNumberOrParseDouble(kv).asDouble().getDouble(); if (!Double.isNaN(value)) { sum += value; num++; } } catch (NumberFormatException ex) { if (conf.warnOnError) { System.out.println("uparseable " + kv + " in " + state.getBundle()); } } } else { sum += conf.defaultValue; } } else { num++; sum += conf.defaultValue; } return true; }
/** * updates the TDigest with value from the key field. Expectation is that the value * is a number. */ @Override public boolean updateChildData(DataTreeNodeUpdater state, DataTreeNode childNode, Config conf) { Bundle p = state.getBundle(); if (valueAccess == null) { valueAccess = p.getFormat().getField(conf.key); } Numeric o = ValueUtil.asNumberOrParseDouble(p.getValue(valueAccess)); if (o != null) { filter.add(o.asDouble().getDouble()); return true; } return false; }
@Override public Bundle rowOp(Bundle row) { if (binder == null) { binder = getSourceColumnBinder(row); rowFactory = row.createBundle(); } Numeric value = ValueUtil.asNumberOrParse(binder.getColumn(row, column)); long increment; if (frequency >= 0) { Numeric incNumeric = ValueUtil.asNumberOrParseLong(binder.getColumn(row, frequency), 10); increment = (incNumeric != null) ? incNumeric.asLong().asNative() : 1; } else { increment = 1; } if (mode == Mode.FLOAT) { float target = (float) value.asDouble().getDouble(); int position = Arrays.binarySearch(keys, target); if (position < 0) position = ~position - 1; counts[position] += increment; } else { int target = (int) value.asLong().getLong(); int position = Arrays.binarySearch(keys, target); if (position < 0) position = ~position - 1; counts[position] += increment; } return null; }
@Override public ValueObject filterValue(ValueObject value) { if (value == null) { return value; } try { Boolean res = false; if (rh != null) { long val = ValueUtil.asNumberOrParseLong(value, 10).asLong().getLong(); res = evalExpression(iop, val, rh); } else if (rhd != null) { double val = ValueUtil.asNumberOrParseDouble(value).asDouble().getDouble(); res = evalExpressionD(iop, val, rhd); } if (res) { return value; } else { return null; } } catch (Exception ex) { return value; } }