@Test public void snapMillisOnOtherReturnsSnappedValue() { Assert.assertEquals(0L, Granularity.MIN_5.snapMillis(1234L)); Assert.assertEquals(0L, Granularity.MIN_5.snapMillis(1000L)); Assert.assertEquals(0L, Granularity.MIN_5.snapMillis(0L)); Assert.assertEquals(0L, Granularity.MIN_5.snapMillis(299999L)); Assert.assertEquals(300000L, Granularity.MIN_5.snapMillis(300000L)); Assert.assertEquals(300000L, Granularity.MIN_5.snapMillis(300001L)); Assert.assertEquals(1200000L, Granularity.MIN_5.snapMillis(1234567L)); Assert.assertEquals(0L, Granularity.MIN_20.snapMillis(1234L)); Assert.assertEquals(0L, Granularity.MIN_20.snapMillis(1000L)); Assert.assertEquals(0L, Granularity.MIN_20.snapMillis(0L)); Assert.assertEquals(0L, Granularity.MIN_20.snapMillis(1199999L)); Assert.assertEquals(1200000L, Granularity.MIN_20.snapMillis(1200000)); Assert.assertEquals(1200000L, Granularity.MIN_20.snapMillis(1200001L)); Assert.assertEquals(1200000L, Granularity.MIN_20.snapMillis(1234567L)); Assert.assertEquals(0L, Granularity.MIN_60.snapMillis(1234L)); Assert.assertEquals(0L, Granularity.MIN_60.snapMillis(1000L)); Assert.assertEquals(0L, Granularity.MIN_60.snapMillis(0L)); Assert.assertEquals(0L, Granularity.MIN_60.snapMillis(3599999L)); Assert.assertEquals(3600000L, Granularity.MIN_60.snapMillis(3600000L)); Assert.assertEquals(3600000L, Granularity.MIN_60.snapMillis(3600001L)); Assert.assertEquals(122400000L, Granularity.MIN_60.snapMillis(123456789L)); Assert.assertEquals(0L, Granularity.MIN_240.snapMillis(1234L)); Assert.assertEquals(0L, Granularity.MIN_240.snapMillis(1000L)); Assert.assertEquals(0L, Granularity.MIN_240.snapMillis(0L)); Assert.assertEquals(0L, Granularity.MIN_240.snapMillis(14399999L)); Assert.assertEquals(14400000L, Granularity.MIN_240.snapMillis(14400000L)); Assert.assertEquals(14400000L, Granularity.MIN_240.snapMillis(14400001L)); Assert.assertEquals(115200000L, Granularity.MIN_240.snapMillis(123456789L)); Assert.assertEquals(0L, Granularity.MIN_1440.snapMillis(1234L)); Assert.assertEquals(0L, Granularity.MIN_1440.snapMillis(1000L)); Assert.assertEquals(0L, Granularity.MIN_1440.snapMillis(0L)); Assert.assertEquals(0L, Granularity.MIN_1440.snapMillis(86399999L)); Assert.assertEquals(86400000L, Granularity.MIN_1440.snapMillis(86400000L)); Assert.assertEquals(86400000L, Granularity.MIN_1440.snapMillis(86400001L)); Assert.assertEquals(86400000L, Granularity.MIN_1440.snapMillis(123456789L)); }
public long snapMillis(long millis) { if (this == FULL) return millis; else return (millis / milliseconds) * milliseconds; }
Granularity { public long snapMillis(long millis) { if (this == FULL) return millis; else return (millis / milliseconds) * milliseconds; } }
Granularity { public long snapMillis(long millis) { if (this == FULL) return millis; else return (millis / milliseconds) * milliseconds; } private  Granularity(String cf, int milliseconds, int numSlots, String shortName); }
Granularity { public long snapMillis(long millis) { if (this == FULL) return millis; else return (millis / milliseconds) * milliseconds; } 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 long snapMillis(long millis) { if (this == FULL) return millis; else return (millis / milliseconds) * milliseconds; } 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; }