Search in sources :

Example 1 with CountWindow

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));
}
Also used : CountWindow(org.apache.flink.table.runtime.operators.window.CountWindow)

Example 2 with CountWindow

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;
}
Also used : CountWindow(org.apache.flink.table.runtime.operators.window.CountWindow) ArrayList(java.util.ArrayList)

Aggregations

CountWindow (org.apache.flink.table.runtime.operators.window.CountWindow)2 ArrayList (java.util.ArrayList)1