dawidwys commented on a change in pull request #13521:
URL: https://github.com/apache/flink/pull/13521#discussion_r500107718



##########
File path: 
flink-tests/src/test/java/org/apache/flink/test/streaming/runtime/SortingBoundedInputITCase.java
##########
@@ -0,0 +1,194 @@
+/*
+ * 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.test.streaming.runtime;
+
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo;
+import org.apache.flink.api.common.typeutils.base.LongSerializer;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.api.java.typeutils.TupleTypeInfo;
+import org.apache.flink.core.execution.JobClient;
+import org.apache.flink.core.memory.ManagedMemoryUseCase;
+import org.apache.flink.streaming.api.datastream.DataStreamSource;
+import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.streaming.api.graph.StreamGraph;
+import org.apache.flink.streaming.api.operators.AbstractStreamOperator;
+import org.apache.flink.streaming.api.operators.BoundedOneInput;
+import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
+import org.apache.flink.streaming.api.operators.collect.CollectResultIterator;
+import org.apache.flink.streaming.api.operators.collect.CollectSinkOperator;
+import 
org.apache.flink.streaming.api.operators.collect.CollectSinkOperatorFactory;
+import org.apache.flink.streaming.api.operators.collect.CollectStreamSink;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.util.CollectionUtil;
+import org.apache.flink.util.SplittableIterator;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Objects;
+import java.util.Random;
+import java.util.Set;
+import java.util.UUID;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+/**
+ * An end to end test for sorted inputs for a keyed operator with bounded 
inputs.
+ */
+public class SortingBoundedInputITCase {
+       @Test
+       public void testOneInputOperator() throws Exception {
+               long numberOfRecords = 1_000_000;
+               StreamExecutionEnvironment env = 
StreamExecutionEnvironment.getExecutionEnvironment();
+               DataStreamSource<Tuple2<Integer, byte[]>> elements = 
env.fromParallelCollection(
+                       new InputGenerator(numberOfRecords),
+                       new TupleTypeInfo<>(BasicTypeInfo.INT_TYPE_INFO, 
PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO)
+               );
+
+               SingleOutputStreamOperator<Long> counts = elements
+                       .keyBy(element -> element.f0)
+                       .transform(
+                               "Asserting operator",
+                               BasicTypeInfo.LONG_TYPE_INFO,
+                               new AssertingOperator()
+                       );
+
+               // TODO we should replace this block with 
DataStreamUtils#collect once
+               // we have the automatic runtime mode determination in place.
+               CollectResultIterator<Long> collectedCounts = applyCollect(env, 
counts);

Review comment:
       I tried doing it and in the end we should use it, as I wrote in the 
TODO. The problem is we do not expose a user facing way to enable the sorting. 
Therefore I adjust the generated StreamGraph, before submission. All the 
methods in `DataStreamUtils#collect()` directly execute the graph and I can not 
inject the additional properties. The code here is mostly copied over from 
`DataStream#collect` and I just postpone the submission.
   
   Once we expose the setting to users I want to change these tests to use 
`DataStreamUtils`.




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to