use of org.apache.flink.table.runtime.operators.window.CountWindow in project flink by apache.
the class CountTumblingWindowAssigner method assignWindows.
@Override
public Collection<CountWindow> assignWindows(RowData element, long timestamp) throws IOException {
Long countValue = count.value();
long currentCount = countValue == null ? 0L : countValue;
long id = currentCount / size;
count.update(currentCount + 1);
return Collections.singleton(new CountWindow(id));
}
use of org.apache.flink.table.runtime.operators.window.CountWindow in project flink by apache.
the class CountSlidingWindowAssigner method assignWindows.
@Override
public Collection<CountWindow> assignWindows(RowData element, long timestamp) throws IOException {
Long countValue = count.value();
long currentCount = countValue == null ? 0L : countValue;
count.update(currentCount + 1);
long lastId = currentCount / windowSlide;
long lastStart = lastId * windowSlide;
long lastEnd = lastStart + windowSize - 1;
List<CountWindow> windows = new ArrayList<>();
while (lastId >= 0 && lastStart <= currentCount && currentCount <= lastEnd) {
if (lastStart <= currentCount && currentCount <= lastEnd) {
windows.add(new CountWindow(lastId));
}
lastId--;
lastStart -= windowSlide;
lastEnd -= windowSlide;
}
return windows;
}
Aggregations