@Test public void rollupInitialLongThenLesserDouble() { long value1 = 123L; IBaseRollup rollup1 = mock(IBaseRollup.class); doReturn(new MinValue(value1)).when(rollup1).getMinValue(); min.handleRollupMetric(rollup1); double value2 = 122.45d; IBaseRollup rollup2 = mock(IBaseRollup.class); doReturn(new MinValue(value2)).when(rollup2).getMinValue(); min.handleRollupMetric(rollup2); assertTrue(min.isFloatingPoint()); assertEquals(value2, min.toDouble(), 0.00001d); }
@Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } }
MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } }
MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson  MinValue(long value); @SuppressWarnings("unused") // used by Jackson  MinValue(double value); }
MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson  MinValue(long value); @SuppressWarnings("unused") // used by Jackson  MinValue(double value); @Override byte getStatType(); }
MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson  MinValue(long value); @SuppressWarnings("unused") // used by Jackson  MinValue(double value); @Override byte getStatType();  }