@Override public long getLong() { return delegate.getLong(); }
@Override public long getLong() { return delegate.getLong(); }
@Override public long getLong() { if (isNullResult) { throw new IllegalStateException("Cannot return long for Null Value"); } return delegate.getLong(); }
@Override public long getMetricLongValue(int rowOffset, int aggOffset) { return concurrentGet(rowOffset)[aggOffset].getLong(); }
@Test public void testLongLastAggregator() { Aggregator agg = longLastAggFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, Long> result = (Pair<Long, Long>) agg.get(); Assert.assertEquals(times[2], result.lhs.longValue()); Assert.assertEquals(longValues[2], result.rhs.longValue()); Assert.assertEquals(longValues[2], agg.getLong()); Assert.assertEquals(longValues[2], agg.getFloat(), 1); }
@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); }
@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 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 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); }
@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); }
@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 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 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); }
@Test public void testLongFirstCombiningAggregator() { Aggregator agg = combiningAggFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, Long> result = (Pair<Long, Long>) agg.get(); Pair<Long, Long> expected = (Pair<Long, Long>) pairs[0]; Assert.assertEquals(expected.lhs, result.lhs); Assert.assertEquals(expected.rhs, result.rhs); Assert.assertEquals(expected.rhs.longValue(), agg.getLong()); Assert.assertEquals(expected.rhs, agg.getFloat(), 0.0001); }
@Test public void testDoubleFirstCombiningAggregator() { Aggregator agg = combiningAggFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, Double> result = (Pair<Long, Double>) agg.get(); Pair<Long, Double> expected = (Pair<Long, Double>) pairs[2]; Assert.assertEquals(expected.lhs, result.lhs); Assert.assertEquals(expected.rhs, result.rhs, 0.0001); Assert.assertEquals(expected.rhs.longValue(), agg.getLong()); Assert.assertEquals(expected.rhs, agg.getDouble(), 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); }
@Test public void testLongLastCombiningAggregator() { Aggregator agg = combiningAggFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, Long> result = (Pair<Long, Long>) agg.get(); Pair<Long, Long> expected = (Pair<Long, Long>) pairs[2]; Assert.assertEquals(expected.lhs, result.lhs); Assert.assertEquals(expected.rhs, result.rhs); Assert.assertEquals(expected.rhs.longValue(), agg.getLong()); Assert.assertEquals(expected.rhs, agg.getFloat(), 1); }
@Test public void testDoubleLastCombiningAggregator() { Aggregator agg = combiningAggFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, Double> result = (Pair<Long, Double>) agg.get(); Pair<Long, Double> expected = (Pair<Long, Double>) pairs[2]; Assert.assertEquals(expected.lhs, result.lhs); Assert.assertEquals(expected.rhs, result.rhs, 0.0001); Assert.assertEquals(expected.rhs.longValue(), agg.getLong()); Assert.assertEquals(expected.rhs, agg.getDouble(), 0.0001); }
@Test public void testDoubleLastCombiningAggregator() { Aggregator agg = combiningAggFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, Float> result = (Pair<Long, Float>) agg.get(); Pair<Long, Float> expected = (Pair<Long, Float>) pairs[2]; Assert.assertEquals(expected.lhs, result.lhs); Assert.assertEquals(expected.rhs, result.rhs, 0.0001); Assert.assertEquals(expected.rhs.longValue(), agg.getLong()); Assert.assertEquals(expected.rhs, agg.getFloat(), 0.0001); }
@Test public void testDoubleFirstCombiningAggregator() { Aggregator agg = combiningAggFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, Float> result = (Pair<Long, Float>) agg.get(); Pair<Long, Float> expected = (Pair<Long, Float>) pairs[2]; Assert.assertEquals(expected.lhs, result.lhs); Assert.assertEquals(expected.rhs, result.rhs, 0.0001); Assert.assertEquals(expected.rhs.longValue(), agg.getLong()); Assert.assertEquals(expected.rhs, agg.getFloat(), 0.0001); }