[
https://issues.apache.org/jira/browse/BEAM-7837?focusedWorklogId=285091&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-285091
]
ASF GitHub Bot logged work on BEAM-7837:
----------------------------------------
Author: ASF GitHub Bot
Created on: 30/Jul/19 16:45
Start Date: 30/Jul/19 16:45
Worklog Time Spent: 10m
Work Description: iemejia commented on pull request #9191: [BEAM-7837]
Add adapter class for API incompatible changes in Spark 3
URL: https://github.com/apache/beam/pull/9191#discussion_r308828139
##########
File path:
runners/spark/src/main/java/org/apache/beam/runners/spark/util/SparkCompat.java
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.spark.util;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import org.apache.beam.runners.spark.translation.SparkCombineFn;
+import org.apache.beam.sdk.annotations.Internal;
+import org.apache.beam.sdk.util.WindowedValue;
+import org.apache.beam.sdk.values.KV;
+import org.apache.spark.api.java.JavaPairRDD;
+import org.apache.spark.api.java.function.Function;
+import org.apache.spark.streaming.api.java.JavaDStream;
+import org.apache.spark.streaming.api.java.JavaStreamingContext;
+
+/** A set of functions to provide API compatibility between Spark 2 and Spark
3. */
+@Internal
+public class SparkCompat {
+ /**
+ * Union of dStreams in the given StreamingContext.
+ *
+ * <p>This is required because the API to join (union) DStreams is different
among Spark versions.
+ * See https://issues.apache.org/jira/browse/SPARK-25737
+ */
+ public static <T> JavaDStream<WindowedValue<T>> joinStreams(
+ JavaStreamingContext streamingContext,
List<JavaDStream<WindowedValue<T>>> dStreams) {
+ return streamingContext.union(dStreams.remove(0), dStreams);
+ }
+
+ /**
+ * Extracts the output for a given collection of WindowedAccumulators.
+ *
+ * <p>This is required because the API of JavaPairRDD.flatMapValues is
different among Spark *
Review comment:
Fixing it, thanks.
----------------------------------------------------------------
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:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 285091)
Time Spent: 2h (was: 1h 50m)
> Add an adapter class to support changes in Spark 3 API
> ------------------------------------------------------
>
> Key: BEAM-7837
> URL: https://issues.apache.org/jira/browse/BEAM-7837
> Project: Beam
> Issue Type: Sub-task
> Components: runner-spark
> Reporter: Ismaël Mejía
> Assignee: Ismaël Mejía
> Priority: Minor
> Time Spent: 2h
> Remaining Estimate: 0h
>
> As part of the API clean ups of Spark 3, there are some methods that do not
> work as before. For details.
> SPARK-19287 JavaPairRDD flatMapValues requires function returning Iterable,
> not Iterator
> SPARK-25737 Remove JavaSparkContextVarargsWorkaround and standardize union()
> methods
> If we want to support both Spark 2 and Spark 3 with the same runner code base
> we should probably create an adapter class for API incompatible code between
> Spark versions.
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)