@Test public void deriveRange240MinuteSecondSlot() { Granularity gran = Granularity.MIN_240; Range range; range = gran.deriveRange(1, 0); Assert.assertEquals(-1195200000, range.getStart()); Assert.assertEquals(-1180800001, range.getStop()); range = gran.deriveRange(1, 1); Assert.assertEquals(-1195200000, range.getStart()); Assert.assertEquals(-1180800001, range.getStop()); range = gran.deriveRange(1, 14399999); Assert.assertEquals(-1195200000, range.getStart()); Assert.assertEquals(-1180800001, range.getStop()); range = gran.deriveRange(1, 14400000); Assert.assertEquals(14400000, range.getStart()); Assert.assertEquals(28799999, range.getStop()); range = gran.deriveRange(1, 14400001); Assert.assertEquals(14400000, range.getStart()); Assert.assertEquals(28799999, range.getStop()); range = gran.deriveRange(1, 28799999); Assert.assertEquals(14400000, range.getStart()); Assert.assertEquals(28799999, range.getStop()); range = gran.deriveRange(1, 28800000); Assert.assertEquals(14400000, range.getStart()); Assert.assertEquals(28799999, range.getStop()); range = gran.deriveRange(1, 28800001); Assert.assertEquals(14400000, range.getStart()); Assert.assertEquals(28799999, range.getStop()); }
public Range deriveRange(int slot, long referenceMillis) { referenceMillis = snapMillis(referenceMillis); int refSlot = slot(referenceMillis); int slotDiff = slot > refSlot ? (numSlots() - slot + refSlot) : (refSlot - slot); long rangeStart = referenceMillis - slotDiff * milliseconds(); return new Range(rangeStart, rangeStart + milliseconds() - 1); }
Granularity { public Range deriveRange(int slot, long referenceMillis) { referenceMillis = snapMillis(referenceMillis); int refSlot = slot(referenceMillis); int slotDiff = slot > refSlot ? (numSlots() - slot + refSlot) : (refSlot - slot); long rangeStart = referenceMillis - slotDiff * milliseconds(); return new Range(rangeStart, rangeStart + milliseconds() - 1); } }
Granularity { public Range deriveRange(int slot, long referenceMillis) { referenceMillis = snapMillis(referenceMillis); int refSlot = slot(referenceMillis); int slotDiff = slot > refSlot ? (numSlots() - slot + refSlot) : (refSlot - slot); long rangeStart = referenceMillis - slotDiff * milliseconds(); return new Range(rangeStart, rangeStart + milliseconds() - 1); } private  Granularity(String cf, int milliseconds, int numSlots, String shortName); }
Granularity { public Range deriveRange(int slot, long referenceMillis) { referenceMillis = snapMillis(referenceMillis); int refSlot = slot(referenceMillis); int slotDiff = slot > refSlot ? (numSlots() - slot + refSlot) : (refSlot - slot); long rangeStart = referenceMillis - slotDiff * milliseconds(); return new Range(rangeStart, rangeStart + milliseconds() - 1); } private  Granularity(String cf, int milliseconds, int numSlots, String shortName); String name(); String shortName(); int milliseconds(); int numSlots(); Granularity coarser(); Granularity finer(); boolean isCoarser(Granularity other); long snapMillis(long millis); int slot(long millis); int slotFromFinerSlot(int finerSlot); Range deriveRange(int slot, long referenceMillis); static Granularity granularityFromPointsInInterval(String tenantid, long from, long to, int points); static Granularity granularityFromPointsInInterval(String tenantid, long from, long to, int points, String algorithm, long assumedIntervalMillis); static Granularity granularityFromPointsInInterval(String tenantid, long from, long to, int points, String algorithm, long assumedIntervalMillis, Clock ttlComparisonClock); @Override int hashCode(); @Override boolean equals(Object obj); static Granularity[] granularities(); static Granularity[] rollupGranularities(); static Granularity fromString(String s); static Granularity getRollupGranularity(String s); @Override String toString(); }
Granularity { public Range deriveRange(int slot, long referenceMillis) { referenceMillis = snapMillis(referenceMillis); int refSlot = slot(referenceMillis); int slotDiff = slot > refSlot ? (numSlots() - slot + refSlot) : (refSlot - slot); long rangeStart = referenceMillis - slotDiff * milliseconds(); return new Range(rangeStart, rangeStart + milliseconds() - 1); } private  Granularity(String cf, int milliseconds, int numSlots, String shortName); String name(); String shortName(); int milliseconds(); int numSlots(); Granularity coarser(); Granularity finer(); boolean isCoarser(Granularity other); long snapMillis(long millis); int slot(long millis); int slotFromFinerSlot(int finerSlot); Range deriveRange(int slot, long referenceMillis); static Granularity granularityFromPointsInInterval(String tenantid, long from, long to, int points); static Granularity granularityFromPointsInInterval(String tenantid, long from, long to, int points, String algorithm, long assumedIntervalMillis); static Granularity granularityFromPointsInInterval(String tenantid, long from, long to, int points, String algorithm, long assumedIntervalMillis, Clock ttlComparisonClock); @Override int hashCode(); @Override boolean equals(Object obj); static Granularity[] granularities(); static Granularity[] rollupGranularities(); static Granularity fromString(String s); static Granularity getRollupGranularity(String s); @Override String toString(); static final int MILLISECONDS_IN_SLOT; static final Granularity FULL; static final Granularity MIN_5; static final Granularity MIN_20; static final Granularity MIN_60; static final Granularity MIN_240; static final Granularity MIN_1440; static final Granularity LAST; static final int MAX_NUM_SLOTS; }