You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/10/19 16:23:06 UTC

[GitHub] [flink] wuchong commented on a change in pull request #13650: [FLINK-19605][table-runtime-blink] Implement cumulative windowing for window aggregate operator

wuchong commented on a change in pull request #13650:
URL: https://github.com/apache/flink/pull/13650#discussion_r507885546



##########
File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/operators/window/assigners/CumulativeWindowAssigner.java
##########
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.runtime.operators.window.assigners;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.runtime.operators.window.TimeWindow;
+import org.apache.flink.util.IterableIterator;
+
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * A {@link WindowAssigner} that windows elements into cumulative windows based on the timestamp of the
+ * elements. Windows are overlap.
+ */
+public class CumulativeWindowAssigner extends PanedWindowAssigner<TimeWindow> implements InternalTimeWindowAssigner {
+
+	private static final long serialVersionUID = 4895551155814656518L;
+
+	private final long size;
+
+	private final long step;
+
+	private final long offset;
+
+	private final long paneSize;
+
+	private final boolean isEventTime;
+
+	protected CumulativeWindowAssigner(long size, long step, long offset, boolean isEventTime) {
+		if (size <= 0 || step <= 0) {
+			throw new IllegalArgumentException(
+				"CumulativeWindowAssigner parameters must satisfy step > 0 and size > 0");
+		}
+		if (size % step != 0) {
+			throw new IllegalArgumentException(
+				"CumulativeWindowAssigner requires size must be an integral multiple of step.");
+		}
+
+		this.size = size;
+		this.step = step;

Review comment:
       Yes. We can support `2 days` max size. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org