@Override public Entry<String, Long> next() { Entry<String, ValueObject> input = iterator.next(); return new SimpleEntry<>(input.getKey(), input.getValue().asLong().getLong()); }
@Override public void setValues(ValueMap map) { targetEpoch = map.get("targetEpoch").asLong().asNative(); numObservations = map.get("numObservations").asLong().asNative().intValue(); doubleToLongBits = map.get("doubleToLongBits").asLong().asNative().intValue() == 1; raw = map.get("raw").asLong().asNative().intValue() == 1; percentile = map.get("percentile").asDouble().asNative(); sigma = map.get("sigma").asDouble().asNative(); minMeasurement = map.get("minMeasurement").asLong().asNative().intValue(); mode = map.get("mode").asString().asNative(); long minEpoch = map.get("minEpoch").asLong().asNative(); ValueArray reservoirValueObject = map.get("reservoir").asArray(); int size = reservoirValueObject.size(); int[] reservoir = new int[size]; for (int i = 0; i < size; i++) { reservoir[i] = reservoirValueObject.get(i).asLong().asNative().intValue(); } this.heldObject = new DataReservoir(minEpoch, reservoir); }
@Override public ValueDouble asDouble() throws ValueTranslationException { return ValueFactory.create(toLong()).asDouble(); }
@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 Numeric diff(Numeric val) { return sum(val).asLong().diff(asLong()); }
@Override public Numeric prod(Numeric val) { return sum(val).asLong().prod(asLong()); }
@Override public Numeric divide(Numeric val) { return sum(val).asLong().divide(asLong()); }
private long toLong() { return asLong().getLong(); }
@Test public void getInt() throws Exception { ValueObject value = applyFilter("{key: a}"); assertEquals(value.asLong().asNative().longValue(), 1); }
@Override public Long get(Object key) { String stringKey = (String) key; ValueObject val = data.get(stringKey); if (val == null) { return null; } else { return val.asLong().getLong(); } }
weight = weightAccess.getValue(state.getBundle()).asLong().asNative().intValue();
@Override public Numeric min(Numeric val) { if (val.asLong().getLong() < toLong()) { return val; } else { return this; } }
@Test public void getField() throws Exception { ValueObject value = applyFilter("{key.field: somekey}"); assertEquals(value.asLong().asNative().longValue(), 2); }
private long getBitValue(ValueObject value) { long ret = ValueUtil.asNumberOrParseLong(value, radix).asLong().getLong(); if (filterMask != 0 && (ret & filterMask) == filterMask) { return 0; } if (matchMask != 0 && (ret & matchMask) != matchMask) { return ret; } return ret; }
@Test public void defaultValue() throws Exception { ValueObject value = applyFilter("{key: e, defaultValue: 5}"); assertEquals(value.asLong().asNative().longValue(), 5); }
@Override public Numeric max(Numeric val) { if (val.asLong().getLong() > toLong()) { return val; } else { return this; } }
@Test public void defaultField() throws Exception { ValueObject value = applyFilter("{key: e, defaultValue.field: somevalue}"); assertEquals(value.asLong().asNative().longValue(), 10); }