@Test public void bucket() { long now = clock.millis(); long b1 = testSubject.bucket(now); long b2 = testSubject.bucket(now + TimeUnit.SECONDS.toMillis(5)); assertEquals(b1+5, b2); }
long bucket(long timestamp) { return (long)Math.floor((double)timestamp/bucketMs); }
SlidingWindow { long bucket(long timestamp) { return (long)Math.floor((double)timestamp/bucketMs); } }
SlidingWindow { long bucket(long timestamp) { return (long)Math.floor((double)timestamp/bucketMs); } SlidingWindow(Supplier<T> createOperation, BinaryOperator<T> aggregateOperation, Clock clock);  SlidingWindow(int bucketSize, int history, TimeUnit timeUnit, Supplier<T> createOperation, BinaryOperator<T> aggregateOperation, Clock clock); }
SlidingWindow { long bucket(long timestamp) { return (long)Math.floor((double)timestamp/bucketMs); } SlidingWindow(Supplier<T> createOperation, BinaryOperator<T> aggregateOperation, Clock clock);  SlidingWindow(int bucketSize, int history, TimeUnit timeUnit, Supplier<T> createOperation, BinaryOperator<T> aggregateOperation, Clock clock); T current(); T aggregate(long time, TimeUnit timeUnit); }
SlidingWindow { long bucket(long timestamp) { return (long)Math.floor((double)timestamp/bucketMs); } SlidingWindow(Supplier<T> createOperation, BinaryOperator<T> aggregateOperation, Clock clock);  SlidingWindow(int bucketSize, int history, TimeUnit timeUnit, Supplier<T> createOperation, BinaryOperator<T> aggregateOperation, Clock clock); T current(); T aggregate(long time, TimeUnit timeUnit);  }