@Test public void testMax() { Assert.assertEquals(3L, BluefloodTimerRollup.max(longs)); Assert.assertEquals(3.0d, BluefloodTimerRollup.max(doubles)); Assert.assertEquals(3.0d, BluefloodTimerRollup.max(mixed)); Assert.assertEquals(3.0d, BluefloodTimerRollup.max(alsoMixed)); }
public static Number max(Collection<Number> numbers) { long longMax = numbers.iterator().next().longValue(); double doubleMax = numbers.iterator().next().doubleValue(); boolean useDouble = false; for (Number number : numbers) { if (useDouble || number instanceof Double || number instanceof Float) { if (!useDouble) { useDouble = true; doubleMax = Math.max(doubleMax, (double)longMax); } doubleMax = Math.max(doubleMax, number.doubleValue()); } else { longMax = Math.max(longMax, number.longValue()); } } if (useDouble) return doubleMax; else return longMax; }
BluefloodTimerRollup implements Rollup, IBaseRollup { public static Number max(Collection<Number> numbers) { long longMax = numbers.iterator().next().longValue(); double doubleMax = numbers.iterator().next().doubleValue(); boolean useDouble = false; for (Number number : numbers) { if (useDouble || number instanceof Double || number instanceof Float) { if (!useDouble) { useDouble = true; doubleMax = Math.max(doubleMax, (double)longMax); } doubleMax = Math.max(doubleMax, number.doubleValue()); } else { longMax = Math.max(longMax, number.longValue()); } } if (useDouble) return doubleMax; else return longMax; } }
BluefloodTimerRollup implements Rollup, IBaseRollup { public static Number max(Collection<Number> numbers) { long longMax = numbers.iterator().next().longValue(); double doubleMax = numbers.iterator().next().doubleValue(); boolean useDouble = false; for (Number number : numbers) { if (useDouble || number instanceof Double || number instanceof Float) { if (!useDouble) { useDouble = true; doubleMax = Math.max(doubleMax, (double)longMax); } doubleMax = Math.max(doubleMax, number.doubleValue()); } else { longMax = Math.max(longMax, number.longValue()); } } if (useDouble) return doubleMax; else return longMax; } BluefloodTimerRollup(); }
BluefloodTimerRollup implements Rollup, IBaseRollup { public static Number max(Collection<Number> numbers) { long longMax = numbers.iterator().next().longValue(); double doubleMax = numbers.iterator().next().doubleValue(); boolean useDouble = false; for (Number number : numbers) { if (useDouble || number instanceof Double || number instanceof Float) { if (!useDouble) { useDouble = true; doubleMax = Math.max(doubleMax, (double)longMax); } doubleMax = Math.max(doubleMax, number.doubleValue()); } else { longMax = Math.max(longMax, number.longValue()); } } if (useDouble) return doubleMax; else return longMax; } BluefloodTimerRollup(); BluefloodTimerRollup withSum(double sum); BluefloodTimerRollup withCount(long count); BluefloodTimerRollup withCountPS(double count_ps); BluefloodTimerRollup withSampleCount(int sampleCount); BluefloodTimerRollup withMinValue(MinValue min); BluefloodTimerRollup withMinValue(Number num); BluefloodTimerRollup withMaxValue(MaxValue max); BluefloodTimerRollup withMaxValue(Number num); BluefloodTimerRollup withAverage(Average average); BluefloodTimerRollup withAverage(Number average); BluefloodTimerRollup withVariance(Variance variance); BluefloodTimerRollup withVariance(Number variance); Average getAverage(); MaxValue getMaxValue(); MinValue getMinValue(); Variance getVariance(); void setPercentile(String label, Number mean); @Override Boolean hasData(); double getRate(); double getSum(); long getCount(); int getSampleCount(); String toString(); @Override RollupType getRollupType(); boolean equals(Object obj); static Number sum(Collection<Number> numbers); static Number avg(Collection<Number> numbers); static Number max(Collection<Number> numbers); static double calculatePerSecond(long countA, double countPerSecA, long countB, double countPerSecB); Map<String, Percentile> getPercentiles(); static BluefloodTimerRollup buildRollupFromTimerRollups(Points<BluefloodTimerRollup> input); }
BluefloodTimerRollup implements Rollup, IBaseRollup { public static Number max(Collection<Number> numbers) { long longMax = numbers.iterator().next().longValue(); double doubleMax = numbers.iterator().next().doubleValue(); boolean useDouble = false; for (Number number : numbers) { if (useDouble || number instanceof Double || number instanceof Float) { if (!useDouble) { useDouble = true; doubleMax = Math.max(doubleMax, (double)longMax); } doubleMax = Math.max(doubleMax, number.doubleValue()); } else { longMax = Math.max(longMax, number.longValue()); } } if (useDouble) return doubleMax; else return longMax; } BluefloodTimerRollup(); BluefloodTimerRollup withSum(double sum); BluefloodTimerRollup withCount(long count); BluefloodTimerRollup withCountPS(double count_ps); BluefloodTimerRollup withSampleCount(int sampleCount); BluefloodTimerRollup withMinValue(MinValue min); BluefloodTimerRollup withMinValue(Number num); BluefloodTimerRollup withMaxValue(MaxValue max); BluefloodTimerRollup withMaxValue(Number num); BluefloodTimerRollup withAverage(Average average); BluefloodTimerRollup withAverage(Number average); BluefloodTimerRollup withVariance(Variance variance); BluefloodTimerRollup withVariance(Number variance); Average getAverage(); MaxValue getMaxValue(); MinValue getMinValue(); Variance getVariance(); void setPercentile(String label, Number mean); @Override Boolean hasData(); double getRate(); double getSum(); long getCount(); int getSampleCount(); String toString(); @Override RollupType getRollupType(); boolean equals(Object obj); static Number sum(Collection<Number> numbers); static Number avg(Collection<Number> numbers); static Number max(Collection<Number> numbers); static double calculatePerSecond(long countA, double countPerSecA, long countB, double countPerSecB); Map<String, Percentile> getPercentiles(); static BluefloodTimerRollup buildRollupFromTimerRollups(Points<BluefloodTimerRollup> input);  }