@Override public float getFloat() { return delegate.getFloat(); }
@Override public float getFloat() { return delegate.getFloat(); }
/** * The default implementation casts {@link Aggregator#getFloat()} to double. * This default method is added to enable smooth backward compatibility, please re-implement it if your aggregators * work with numeric double columns. */ default double getDouble() { return (double) getFloat(); }
@Override public float getFloat() { if (isNullResult) { throw new IllegalStateException("Cannot return float for Null Value"); } return delegate.getFloat(); }
@Override public float getMetricFloatValue(int rowOffset, int aggOffset) { return concurrentGet(rowOffset)[aggOffset].getFloat(); }
out.writeByte(NullHandling.IS_NOT_NULL_BYTE); if ("float".equals(t)) { out.writeFloat(agg.getFloat()); } else if ("long".equals(t)) { WritableUtils.writeVLong(out, agg.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 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 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 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 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 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, 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); }
@Override public float getFloat() { return delegate.getFloat(); }
@Override public float getMetricFloatValue(int rowOffset, int aggOffset) { return concurrentGet(rowOffset)[aggOffset].getFloat(); }