@Test public void testStartAndEndEqual() { final long time = 123987564019283L; final TemporalBinningStrategy binStrategy = new TemporalBinningStrategy(Unit.YEAR); final BinRange[] ranges = binStrategy.getNormalizedRanges(new NumericRange(time, time)); Assert.assertEquals(1, ranges.length); Assert.assertTrue(ranges[0].getNormalizedMin() == ranges[0].getNormalizedMax()); }
@Override public BinRange[] getNormalizedRanges(final NumericData range) { if ((range == null) || (range.getMax() < range.getMin())) { return new BinRange[] {}; } final Calendar startEpoch = Calendar.getInstance(TimeZone.getTimeZone(timezone)); final long binSizeMillis = getBinSizeMillis(); startEpoch.setTimeInMillis((long) range.getMin()); setToEpoch(startEpoch); final long startEpochMillis = startEpoch.getTimeInMillis(); long epochIterator = startEpochMillis; final List<BinRange> bins = new ArrayList<>(); boolean firstBin = ((long) range.getMin() != startEpochMillis); boolean lastBin = false; do { final Calendar nextEpochCal = Calendar.getInstance(TimeZone.getTimeZone(timezone)); nextEpochCal.setTimeInMillis(epochIterator + (long) (binSizeMillis * 1.5)); setToEpoch(nextEpochCal); final long nextEpoch = nextEpochCal.getTimeInMillis(); final long maxOfBin = nextEpoch - 1; final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(timezone)); cal.setTimeInMillis(epochIterator); long startMillis, endMillis; boolean fullExtent; if ((long) range.getMax() <= maxOfBin) { lastBin = true; endMillis = (long) range.getMax(); fullExtent = FloatCompareUtils.checkDoublesEqual(range.getMax(), maxOfBin); } else { endMillis = maxOfBin; fullExtent = !firstBin; } if (firstBin) { startMillis = (long) range.getMin(); firstBin = false; } else { startMillis = epochIterator; } bins.add( new BinRange( getBinId(cal), startMillis - epochIterator, endMillis - epochIterator, fullExtent)); epochIterator = nextEpoch; } while (!lastBin); return bins.toArray(new BinRange[bins.size()]); }
TemporalBinningStrategy implements BinningStrategy { @Override public BinRange[] getNormalizedRanges(final NumericData range) { if ((range == null) || (range.getMax() < range.getMin())) { return new BinRange[] {}; } final Calendar startEpoch = Calendar.getInstance(TimeZone.getTimeZone(timezone)); final long binSizeMillis = getBinSizeMillis(); startEpoch.setTimeInMillis((long) range.getMin()); setToEpoch(startEpoch); final long startEpochMillis = startEpoch.getTimeInMillis(); long epochIterator = startEpochMillis; final List<BinRange> bins = new ArrayList<>(); boolean firstBin = ((long) range.getMin() != startEpochMillis); boolean lastBin = false; do { final Calendar nextEpochCal = Calendar.getInstance(TimeZone.getTimeZone(timezone)); nextEpochCal.setTimeInMillis(epochIterator + (long) (binSizeMillis * 1.5)); setToEpoch(nextEpochCal); final long nextEpoch = nextEpochCal.getTimeInMillis(); final long maxOfBin = nextEpoch - 1; final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(timezone)); cal.setTimeInMillis(epochIterator); long startMillis, endMillis; boolean fullExtent; if ((long) range.getMax() <= maxOfBin) { lastBin = true; endMillis = (long) range.getMax(); fullExtent = FloatCompareUtils.checkDoublesEqual(range.getMax(), maxOfBin); } else { endMillis = maxOfBin; fullExtent = !firstBin; } if (firstBin) { startMillis = (long) range.getMin(); firstBin = false; } else { startMillis = epochIterator; } bins.add( new BinRange( getBinId(cal), startMillis - epochIterator, endMillis - epochIterator, fullExtent)); epochIterator = nextEpoch; } while (!lastBin); return bins.toArray(new BinRange[bins.size()]); } }
TemporalBinningStrategy implements BinningStrategy { @Override public BinRange[] getNormalizedRanges(final NumericData range) { if ((range == null) || (range.getMax() < range.getMin())) { return new BinRange[] {}; } final Calendar startEpoch = Calendar.getInstance(TimeZone.getTimeZone(timezone)); final long binSizeMillis = getBinSizeMillis(); startEpoch.setTimeInMillis((long) range.getMin()); setToEpoch(startEpoch); final long startEpochMillis = startEpoch.getTimeInMillis(); long epochIterator = startEpochMillis; final List<BinRange> bins = new ArrayList<>(); boolean firstBin = ((long) range.getMin() != startEpochMillis); boolean lastBin = false; do { final Calendar nextEpochCal = Calendar.getInstance(TimeZone.getTimeZone(timezone)); nextEpochCal.setTimeInMillis(epochIterator + (long) (binSizeMillis * 1.5)); setToEpoch(nextEpochCal); final long nextEpoch = nextEpochCal.getTimeInMillis(); final long maxOfBin = nextEpoch - 1; final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(timezone)); cal.setTimeInMillis(epochIterator); long startMillis, endMillis; boolean fullExtent; if ((long) range.getMax() <= maxOfBin) { lastBin = true; endMillis = (long) range.getMax(); fullExtent = FloatCompareUtils.checkDoublesEqual(range.getMax(), maxOfBin); } else { endMillis = maxOfBin; fullExtent = !firstBin; } if (firstBin) { startMillis = (long) range.getMin(); firstBin = false; } else { startMillis = epochIterator; } bins.add( new BinRange( getBinId(cal), startMillis - epochIterator, endMillis - epochIterator, fullExtent)); epochIterator = nextEpoch; } while (!lastBin); return bins.toArray(new BinRange[bins.size()]); } TemporalBinningStrategy();  TemporalBinningStrategy(final Unit unit);  TemporalBinningStrategy(final Unit unit, final String timezone); }
TemporalBinningStrategy implements BinningStrategy { @Override public BinRange[] getNormalizedRanges(final NumericData range) { if ((range == null) || (range.getMax() < range.getMin())) { return new BinRange[] {}; } final Calendar startEpoch = Calendar.getInstance(TimeZone.getTimeZone(timezone)); final long binSizeMillis = getBinSizeMillis(); startEpoch.setTimeInMillis((long) range.getMin()); setToEpoch(startEpoch); final long startEpochMillis = startEpoch.getTimeInMillis(); long epochIterator = startEpochMillis; final List<BinRange> bins = new ArrayList<>(); boolean firstBin = ((long) range.getMin() != startEpochMillis); boolean lastBin = false; do { final Calendar nextEpochCal = Calendar.getInstance(TimeZone.getTimeZone(timezone)); nextEpochCal.setTimeInMillis(epochIterator + (long) (binSizeMillis * 1.5)); setToEpoch(nextEpochCal); final long nextEpoch = nextEpochCal.getTimeInMillis(); final long maxOfBin = nextEpoch - 1; final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(timezone)); cal.setTimeInMillis(epochIterator); long startMillis, endMillis; boolean fullExtent; if ((long) range.getMax() <= maxOfBin) { lastBin = true; endMillis = (long) range.getMax(); fullExtent = FloatCompareUtils.checkDoublesEqual(range.getMax(), maxOfBin); } else { endMillis = maxOfBin; fullExtent = !firstBin; } if (firstBin) { startMillis = (long) range.getMin(); firstBin = false; } else { startMillis = epochIterator; } bins.add( new BinRange( getBinId(cal), startMillis - epochIterator, endMillis - epochIterator, fullExtent)); epochIterator = nextEpoch; } while (!lastBin); return bins.toArray(new BinRange[bins.size()]); } TemporalBinningStrategy();  TemporalBinningStrategy(final Unit unit);  TemporalBinningStrategy(final Unit unit, final String timezone); @Override double getBinMin(); @Override double getBinMax(); @Override BinValue getBinnedValue(final double value); @Override int getFixedBinIdSize(); @Override BinRange[] getNormalizedRanges(final NumericData range); @Override byte[] toBinary(); @Override void fromBinary(final byte[] bytes); @Override int hashCode(); @Override boolean equals(final Object obj); @Override NumericRange getDenormalizedRanges(final BinRange binnedRange); }
TemporalBinningStrategy implements BinningStrategy { @Override public BinRange[] getNormalizedRanges(final NumericData range) { if ((range == null) || (range.getMax() < range.getMin())) { return new BinRange[] {}; } final Calendar startEpoch = Calendar.getInstance(TimeZone.getTimeZone(timezone)); final long binSizeMillis = getBinSizeMillis(); startEpoch.setTimeInMillis((long) range.getMin()); setToEpoch(startEpoch); final long startEpochMillis = startEpoch.getTimeInMillis(); long epochIterator = startEpochMillis; final List<BinRange> bins = new ArrayList<>(); boolean firstBin = ((long) range.getMin() != startEpochMillis); boolean lastBin = false; do { final Calendar nextEpochCal = Calendar.getInstance(TimeZone.getTimeZone(timezone)); nextEpochCal.setTimeInMillis(epochIterator + (long) (binSizeMillis * 1.5)); setToEpoch(nextEpochCal); final long nextEpoch = nextEpochCal.getTimeInMillis(); final long maxOfBin = nextEpoch - 1; final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(timezone)); cal.setTimeInMillis(epochIterator); long startMillis, endMillis; boolean fullExtent; if ((long) range.getMax() <= maxOfBin) { lastBin = true; endMillis = (long) range.getMax(); fullExtent = FloatCompareUtils.checkDoublesEqual(range.getMax(), maxOfBin); } else { endMillis = maxOfBin; fullExtent = !firstBin; } if (firstBin) { startMillis = (long) range.getMin(); firstBin = false; } else { startMillis = epochIterator; } bins.add( new BinRange( getBinId(cal), startMillis - epochIterator, endMillis - epochIterator, fullExtent)); epochIterator = nextEpoch; } while (!lastBin); return bins.toArray(new BinRange[bins.size()]); } TemporalBinningStrategy();  TemporalBinningStrategy(final Unit unit);  TemporalBinningStrategy(final Unit unit, final String timezone); @Override double getBinMin(); @Override double getBinMax(); @Override BinValue getBinnedValue(final double value); @Override int getFixedBinIdSize(); @Override BinRange[] getNormalizedRanges(final NumericData range); @Override byte[] toBinary(); @Override void fromBinary(final byte[] bytes); @Override int hashCode(); @Override boolean equals(final Object obj); @Override NumericRange getDenormalizedRanges(final BinRange binnedRange);  }