/** Method used to bin a raw date in milliseconds to a binned value of the Binning Strategy. */ @Override public BinValue getBinnedValue(final double value) { final long millisFromOrigin = (long) value - ORIGIN_MILLIS; if (millisFromOrigin < 0) { final int binId = (int) (((millisFromOrigin - BIN_SIZE_MILLIS) + 1) / BIN_SIZE_MILLIS); final long startOfEpochFromOrigin = binId * BIN_SIZE_MILLIS; final ByteBuffer buf = ByteBuffer.allocate(4); buf.putInt(binId); return new BinValue(buf.array(), millisFromOrigin - startOfEpochFromOrigin); } else { final int binId = (int) (millisFromOrigin / BIN_SIZE_MILLIS); final ByteBuffer buf = ByteBuffer.allocate(4); buf.putInt(binId); return new BinValue(buf.array(), millisFromOrigin % BIN_SIZE_MILLIS); } }
return new BinRange[] { new BinRange( value.getBinId(), value.getNormalizedValue(), value.getNormalizedValue(), false)};
@Override public BinValue getBinnedValue(double value) { double bin = Math.floor((value - halfInterval) / interval); return new BinValue(intToBinary((int) bin), (value - interval * bin)); }
/** Method used to bin a raw date in milliseconds to a binned value of the Binning Strategy. */ @Override public BinValue getBinnedValue(final double value) { // convert to a calendar and subtract the epoch for the bin final Calendar epochCal = Calendar.getInstance(TimeZone.getTimeZone(timezone)); epochCal.setTimeInMillis((long) value); setToEpoch(epochCal); // use the value to get the bin ID (although the epoch should work fine // too) final Calendar valueCal = Calendar.getInstance(TimeZone.getTimeZone(timezone)); valueCal.setTimeInMillis((long) value); return new BinValue( getBinId(valueCal), valueCal.getTimeInMillis() - epochCal.getTimeInMillis()); }