@Test public void rollupInitialLongThenGreaterLong() { long value1 = 123L; IBaseRollup rollup1 = mock(IBaseRollup.class); doReturn(new MaxValue(value1)).when(rollup1).getMaxValue(); max.handleRollupMetric(rollup1); long value2 = 124L; IBaseRollup rollup2 = mock(IBaseRollup.class); doReturn(new MaxValue(value2)).when(rollup2).getMaxValue(); max.handleRollupMetric(rollup2); assertFalse(max.isFloatingPoint()); assertEquals(value2, max.toLong()); }
@Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.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.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } }
MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.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.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } }
MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.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.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson  MaxValue(long value); @SuppressWarnings("unused") // used by Jackson  MaxValue(double value); }
MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.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.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson  MaxValue(long value); @SuppressWarnings("unused") // used by Jackson  MaxValue(double value); @Override byte getStatType(); }
MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.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.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson  MaxValue(long value); @SuppressWarnings("unused") // used by Jackson  MaxValue(double value); @Override byte getStatType();  }