WencongLiu commented on code in PR #24398: URL: https://github.com/apache/flink/pull/24398#discussion_r1519071465
########## flink-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/PartitionWindowedStream.java: ########## @@ -0,0 +1,219 @@ +/* + * 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.streaming.api.datastream; + +import org.apache.flink.annotation.PublicEvolving; +import org.apache.flink.api.common.functions.AggregateFunction; +import org.apache.flink.api.common.functions.MapPartitionFunction; +import org.apache.flink.api.common.functions.ReduceFunction; +import org.apache.flink.api.common.operators.Order; +import org.apache.flink.api.common.typeinfo.TypeInformation; +import org.apache.flink.api.java.functions.KeySelector; +import org.apache.flink.api.java.tuple.Tuple; +import org.apache.flink.api.java.typeutils.PojoTypeInfo; +import org.apache.flink.api.java.typeutils.TypeExtractor; +import org.apache.flink.core.memory.ManagedMemoryUseCase; +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; +import org.apache.flink.streaming.api.operators.MapPartitionOperator; +import org.apache.flink.streaming.api.operators.PartitionAggregateOperator; +import org.apache.flink.streaming.api.operators.PartitionReduceOperator; +import org.apache.flink.streaming.api.operators.sortpartition.SortPartitionOperator; +import org.apache.flink.streaming.runtime.partitioner.ForwardPartitioner; + +import static org.apache.flink.streaming.api.operators.sortpartition.SortPartitionOperator.DEFAULT_SORTPARTITION_MANAGE_MEMORY_WEIGHT; + +/** + * {@link PartitionWindowedStream} represents a data stream that collects records of each partition + * into a separate full window. Each partition contains all records of a subtask. The window + * emission will be triggered at the end of input. + * + * @param <T> The type of the elements in this stream. + */ +@PublicEvolving +public class PartitionWindowedStream<T> { + + private final StreamExecutionEnvironment environment; + + private final DataStream<T> input; + + public PartitionWindowedStream(StreamExecutionEnvironment environment, DataStream<T> input) { + this.environment = environment; + this.input = input; + } + + /** + * Process the records of the window by {@link MapPartitionFunction}. + * + * @param mapPartitionFunction The map partition function. + * @param <R> The type of map partition result. + * @return The data stream with map partition result. + */ + public <R> SingleOutputStreamOperator<R> mapPartition( + MapPartitionFunction<T, R> mapPartitionFunction) { + if (mapPartitionFunction == null) { + throw new NullPointerException("The map partition function must not be null."); + } Review Comment: Good point. I've added `checkNotNull` in the similar positions. -- 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. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org