You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/04/27 10:35:23 UTC

[GitHub] [beam] mxm commented on a change in pull request #11530: [BEAM-9824] Do not ignore chained Reshuffles on flink batch runner.

mxm commented on a change in pull request #11530:
URL: https://github.com/apache/beam/pull/11530#discussion_r415698500



##########
File path: runners/flink/src/test/java/org/apache/beam/runners/flink/batch/ReshuffleTest.java
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.beam.runners.flink.batch;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.beam.runners.flink.FlinkPipelineOptions;
+import org.apache.beam.runners.flink.FlinkTestPipeline;
+import org.apache.beam.sdk.Pipeline;
+import org.apache.beam.sdk.testing.PAssert;
+import org.apache.beam.sdk.transforms.Create;
+import org.apache.beam.sdk.transforms.DoFn;
+import org.apache.beam.sdk.transforms.ParDo;
+import org.apache.beam.sdk.transforms.Reshuffle;
+import org.apache.beam.sdk.values.PCollection;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ReshuffleTest {
+
+  private static class WithBundleIdFn extends DoFn<String, String> {
+
+    private String uuid;
+
+    @StartBundle
+    public void startBundle() {
+      uuid = UUID.randomUUID().toString();
+    }
+
+    @ProcessElement
+    public void processElement(ProcessContext ctx) {
+      ctx.output(ctx.element() + "@" + uuid);
+    }
+  }
+
+  @Test
+  public void testMultipleReshufflesOnBatch() {

Review comment:
       Like `testEqualDistributionOnReshuffleAcrossMultipleStages` or something catchier ;)

##########
File path: runners/flink/src/test/java/org/apache/beam/runners/flink/batch/ReshuffleTest.java
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.beam.runners.flink.batch;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.beam.runners.flink.FlinkPipelineOptions;
+import org.apache.beam.runners.flink.FlinkTestPipeline;
+import org.apache.beam.sdk.Pipeline;
+import org.apache.beam.sdk.testing.PAssert;
+import org.apache.beam.sdk.transforms.Create;
+import org.apache.beam.sdk.transforms.DoFn;
+import org.apache.beam.sdk.transforms.ParDo;
+import org.apache.beam.sdk.transforms.Reshuffle;
+import org.apache.beam.sdk.values.PCollection;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ReshuffleTest {
+
+  private static class WithBundleIdFn extends DoFn<String, String> {
+
+    private String uuid;
+
+    @StartBundle
+    public void startBundle() {
+      uuid = UUID.randomUUID().toString();
+    }
+
+    @ProcessElement
+    public void processElement(ProcessContext ctx) {
+      ctx.output(ctx.element() + "@" + uuid);
+    }
+  }
+
+  @Test
+  public void testMultipleReshufflesOnBatch() {

Review comment:
       Maybe a add a sentence here what this tests?

##########
File path: runners/flink/src/main/java/org/apache/beam/runners/flink/FlinkBatchTransformTranslators.java
##########
@@ -330,7 +331,12 @@ public void translateNode(
               outputType,
               FlinkIdentityFunction.of(),
               getCurrentTransformName(context));
-      context.setOutputDataSet(context.getOutput(transform), retypedDataSet.rebalance());
+      final Configuration partitionOptions = new Configuration();
+      partitionOptions.setString(
+          Optimizer.HINT_SHIP_STRATEGY, Optimizer.HINT_SHIP_STRATEGY_REPARTITION);

Review comment:
       The docs say:
   
   ```java
   	/**
   	 * Value for the shipping strategy compiler hint that enforces a random repartition strategy.
   	 * 
   	 * @see #HINT_SHIP_STRATEGY
   	 * @see #HINT_SHIP_STRATEGY_FIRST_INPUT
   	 * @see #HINT_SHIP_STRATEGY_SECOND_INPUT
   	 */
   	public static final String HINT_SHIP_STRATEGY_REPARTITION= "SHIP_REPARTITION";
   ```
   
   The actual repartitioning is round-robin, no?




----------------------------------------------------------------
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