I need to find the MAX value for a fixed period (for example, the last 7 days). In theory, the best way to resolve this task is the sliding window.
I tried to do it with SlidingWindows, but I couldn't write the aggregation function. I don't understand how to get access to values inside the window.
input
.groupByKey()
.windowedBy(SlidingWindows.withTimeDifferenceAndGrace(Duration.ofDays(7), Duration.ZERO))
.reduce(Math::max) // I thinks this is mistake
I don't need a sliding window in my case. I need a hopping window:
input
.groupByKey()
.windowedBy(
TimeWindows.of(Duration.ofDays(1)).advanceBy(Duration.ofHours(1)))
.reduce(Math::max)
.suppress(Suppressed.untilWindowCloses(Suppressed.BufferConfig.unbounded()))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.