@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); }
@Test public void getField() throws Exception { ValueObject value = applyFilter("{key.field: somekey}"); assertEquals(value.asLong().asNative().longValue(), 2); }
@Test public void defaultValue() throws Exception { ValueObject value = applyFilter("{key: e, defaultValue: 5}"); assertEquals(value.asLong().asNative().longValue(), 5); }
@Test public void defaultField() throws Exception { ValueObject value = applyFilter("{key: e, defaultValue.field: somevalue}"); assertEquals(value.asLong().asNative().longValue(), 10); }
@Test public void getInt() throws Exception { ValueObject value = applyFilter("{key: a}"); assertEquals(value.asLong().asNative().longValue(), 1); }
weight = weightAccess.getValue(state.getBundle()).asLong().asNative().intValue();
return value.asBytes().asNative(); case INT: return value.asLong().asNative().intValue(); case LONG: return value.asLong().getLong();
return value.asBytes().asNative(); case INT: return value.asLong().asNative().intValue(); case LONG: return value.asLong().getLong();
@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; }
/** * Verifies that require.value works on Long input. * * This is for bug fix commit: https://github.com/addthis/hydra/commit/60a1e46 */ @Test public void longInputStringValue() throws Exception { ValueFilterRequire filter = Configs.decodeObject(ValueFilterRequire.class, "value:[\"0\"]"); ValueObject result = filter.filter(ValueFactory.create(0)); assertNotNull(result); assertEquals(new Long(0), result.asLong().asNative()); } }
private void verifyOnePass() { bundle = source.next(); assertNotNull(bundle); assertEquals("a", getField("A").asString().asNative()); assertEquals(new Long(1), getField("B").asLong().asNative()); assertNotNull(bundle); bundle = source.next(); assertNotNull(bundle); assertEquals(Lists.newArrayList(new Long(1), new Long(2)), getField("C").asArray().asNative()); assertEquals(Lists.newArrayList("a", "b"), getField("D").asArray().asNative()); }
for (Bundle newBundle: newBundles) { assertEquals("lyrics", newBundle.getValue(newBundle.getFormat().getField("bar")).asString().asNative()); long baz = newBundle.getValue(newBundle.getFormat().getField("baz")).asLong().asNative(); final ValueObject preKey = newBundle.getValue(newBundle.getFormat().getField("key")); if (preKey == null) {