@Override public Object get() { return delegate.get(); }
@Test public void testLongMaxAggregator() { Aggregator agg = longMaxAggFactory.factorize(colSelectorFactory); aggregate(selector, agg); aggregate(selector, agg); aggregate(selector, agg); aggregate(selector, agg); Assert.assertEquals(values[2], ((Long) agg.get()).longValue()); Assert.assertEquals(values[2], agg.getLong()); Assert.assertEquals((float) values[2], agg.getFloat(), 0.0001); }
@Test public void testDoubleLastAggregator() { Aggregator agg = doubleLastAggFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, Double> result = (Pair<Long, Double>) agg.get(); Assert.assertEquals(times[0], result.lhs.longValue()); Assert.assertEquals(doubles[0], result.rhs, 0.0001); Assert.assertEquals((long) doubles[0], agg.getLong()); Assert.assertEquals(doubles[0], agg.getDouble(), 0.0001); }
@Test public void testLongMinAggregator() { Aggregator agg = longMinAggFactory.factorize(colSelectorFactory); aggregate(selector, agg); aggregate(selector, agg); aggregate(selector, agg); aggregate(selector, agg); Assert.assertEquals(values[2], ((Long) agg.get()).longValue()); Assert.assertEquals(values[2], agg.getLong()); Assert.assertEquals((float) values[2], agg.getFloat(), 0.0001); }
@Test public void testDoubleFirstAggregator() { Aggregator agg = doubleFirstAggFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, Double> result = (Pair<Long, Double>) agg.get(); Assert.assertEquals(times[1], result.lhs.longValue()); Assert.assertEquals(doubleValues[1], result.rhs, 0.0001); Assert.assertEquals((long) doubleValues[1], agg.getLong()); Assert.assertEquals(doubleValues[1], agg.getDouble(), 0.0001); }
@Override protected Object getAggVal(Aggregator agg, int rowOffset, int aggPosition) { return agg.get(); }
@Test public void testDoubleMinAggregator() { Aggregator agg = doubleMinAggFactory.factorize(colSelectorFactory); aggregate(selector, agg); aggregate(selector, agg); aggregate(selector, agg); aggregate(selector, agg); Assert.assertEquals(values[2], ((Double) agg.get()).doubleValue(), 0.0001); Assert.assertEquals((long) values[2], agg.getLong()); Assert.assertEquals(values[2], agg.getFloat(), 0.0001); }
public TimeseriesResultBuilder addMetric(String name, Aggregator aggregator) { metricValues.put(name, aggregator.get()); return this; }
@Test public void testDoubleMaxAggregator() { Aggregator agg = doubleMaxAggFactory.factorize(colSelectorFactory); aggregate(selector, agg); aggregate(selector, agg); aggregate(selector, agg); aggregate(selector, agg); Assert.assertEquals(values[2], ((Double) agg.get()).doubleValue(), 0.0001); Assert.assertEquals((long) values[2], agg.getLong()); Assert.assertEquals(values[2], agg.getFloat(), 0.0001); }
@Override @Nullable public Object get() { if (isNullResult) { return null; } return delegate.get(); }
@Test public void testLongFirstAggregator() { Aggregator agg = longFirstAggFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, Long> result = (Pair<Long, Long>) agg.get(); Assert.assertEquals(times[3], result.lhs.longValue()); Assert.assertEquals(longValues[3], result.rhs.longValue()); Assert.assertEquals(longValues[3], agg.getLong()); Assert.assertEquals(longValues[3], agg.getFloat(), 0.0001); }
@Nullable @Override public Object get() { return delegate.get(); }
@Test public void testDoubleLastAggregator() { Aggregator agg = floatLastAggregatorFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, Float> result = (Pair<Long, Float>) agg.get(); Assert.assertEquals(times[0], result.lhs.longValue()); Assert.assertEquals(floats[0], result.rhs, 0.0001); Assert.assertEquals((long) floats[0], agg.getLong()); Assert.assertEquals(floats[0], agg.getFloat(), 0.0001); }
@Override public Object getMetricObjectValue(int rowOffset, int aggOffset) { return concurrentGet(rowOffset)[aggOffset].get(); }
@Test public void testDoubleFirstAggregator() { Aggregator agg = floatFirstAggregatorFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, Float> result = (Pair<Long, Float>) agg.get(); Assert.assertEquals(times[1], result.lhs.longValue()); Assert.assertEquals(floats[1], result.rhs, 0.0001); Assert.assertEquals((long) floats[1], agg.getLong()); Assert.assertEquals(floats[1], agg.getFloat(), 0.0001); }
@Test(expected = UnsupportedOperationException.class) public void testComputeWithoutFinalizing() { String aggName = "rows"; Aggregator agg = new CountAggregator(); agg.aggregate(); agg.aggregate(); agg.aggregate(); Map<String, Object> metricValues = new HashMap<>(); metricValues.put(aggName, agg.get()); FinalizingFieldAccessPostAggregator postAgg = new FinalizingFieldAccessPostAggregator("final_rows", aggName); Assert.assertEquals(new Long(3L), postAgg.compute(metricValues)); }
@Test public void testStringLastAggregator() { Aggregator agg = stringLastAggFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, String> result = (Pair<Long, String>) agg.get(); Assert.assertEquals(strings[0], result.rhs); }
@Test public void testStringLastAggregator() { Aggregator agg = stringLastAggFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, String> result = (Pair<Long, String>) agg.get(); Assert.assertEquals(strings[2], result.rhs); }
@Test public void testStringLastCombiningAggregator() { Aggregator agg = combiningAggFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, String> result = (Pair<Long, String>) agg.get(); Pair<Long, String> expected = pairs[2]; Assert.assertEquals(expected.lhs, result.lhs); Assert.assertEquals(expected.rhs, result.rhs); }
@Test public void testStringLastCombiningAggregator() { Aggregator agg = combiningAggFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, String> result = (Pair<Long, String>) agg.get(); Pair<Long, String> expected = pairs[3]; Assert.assertEquals(expected.lhs, result.lhs); Assert.assertEquals(expected.rhs, result.rhs); }