[jira] [Commented] (SPARK-1834) NoSuchMethodError when invoking JavaPairRDD.reduce() in Java
[ https://issues.apache.org/jira/browse/SPARK-1834?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14156464#comment-14156464 ] Alexis Seigneurin commented on SPARK-1834: -- Same issue here with Spark 1.1.0: reduce() is not implemented on JavaPairRDD. {code} Tuple2 r = sc.textFile(filename) .mapToPair(s -> new Tuple2(s[3], 1L)) .reduceByKey((x, y) -> x + y) .reduce((t1, t2) -> t1._2 > t2._2 ? t1 : t2); {code} Produces: {code} Exception in thread "main" java.lang.NoSuchMethodError: org.apache.spark.api.java.JavaPairRDD.reduce(Lorg/apache/spark/api/java/function/Function2;)Lscala/Tuple2; at fr.ippon.dojo.spark.AnalyseParisTrees.main(AnalyseParisTrees.java:33) {code} However, reduce() is implemented on JavaRDD. I have had to add an intermediate map() operation: {code} Tuple2 r = sc.textFile(filename) .mapToPair(s -> new Tuple2(s[3], 1L)) .reduceByKey((x, y) -> x + y) .map(t -> t) .reduce((t1, t2) -> t1._2 > t2._2 ? t1 : t2); {code} > NoSuchMethodError when invoking JavaPairRDD.reduce() in Java > > > Key: SPARK-1834 > URL: https://issues.apache.org/jira/browse/SPARK-1834 > Project: Spark > Issue Type: Bug > Components: Spark Core >Affects Versions: 0.9.1 > Environment: Redhat Linux, Java 7, Hadoop 2.2, Scala 2.10.4 >Reporter: John Snodgrass > > I get a java.lang.NoSuchMethod error when invoking JavaPairRDD.reduce(). Here > is the partial stack trace: > Exception in thread "main" java.lang.reflect.InvocationTargetException > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) > at > org.apache.spark.deploy.worker.DriverWrapper$.main(DriverWrapper.scala:39) > at > org.apache.spark.deploy.worker.DriverWrapper.main(DriverWrapper.scala) > Caused by: java.lang.NoSuchMethodError: > org.apache.spark.api.java.JavaPairRDD.reduce(Lorg/apache/spark/api/java/function/Function2;)Lscala/Tuple2; > at JavaPairRDDReduceTest.main(JavaPairRDDReduceTest.java:49)... > I'm using Spark 0.9.1. I checked to ensure that I'm compiling with the same > version of Spark as I am running on the cluster. The reduce() method works > fine with JavaRDD, just not with JavaPairRDD. Here is a code snippet that > exhibits the problem: > ArrayList array = new ArrayList<>(); > for (int i = 0; i < 10; ++i) { > array.add(i); > } > JavaRDD rdd = javaSparkContext.parallelize(array); > JavaPairRDD testRDD = rdd.map(new > PairFunction() { > @Override > public Tuple2 call(Integer t) throws Exception { > return new Tuple2<>("" + t, t); > } > }).cache(); > > testRDD.reduce(new Function2, Tuple2 Integer>, Tuple2>() { > @Override > public Tuple2 call(Tuple2 arg0, > Tuple2 arg1) throws Exception { > return new Tuple2<>(arg0._1 + arg1._1, arg0._2 * 10 + arg0._2); > } > }); -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (SPARK-1834) NoSuchMethodError when invoking JavaPairRDD.reduce() in Java
[ https://issues.apache.org/jira/browse/SPARK-1834?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14156477#comment-14156477 ] Sean Owen commented on SPARK-1834: -- Weird, I can reproduce this. I have a new test case for {{JavaAPISuite}} and am investigating. It compiles fine but fails at runtime. I sense Scala shenanigans. > NoSuchMethodError when invoking JavaPairRDD.reduce() in Java > > > Key: SPARK-1834 > URL: https://issues.apache.org/jira/browse/SPARK-1834 > Project: Spark > Issue Type: Bug > Components: Spark Core >Affects Versions: 0.9.1 > Environment: Redhat Linux, Java 7, Hadoop 2.2, Scala 2.10.4 >Reporter: John Snodgrass > > I get a java.lang.NoSuchMethod error when invoking JavaPairRDD.reduce(). Here > is the partial stack trace: > Exception in thread "main" java.lang.reflect.InvocationTargetException > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) > at > org.apache.spark.deploy.worker.DriverWrapper$.main(DriverWrapper.scala:39) > at > org.apache.spark.deploy.worker.DriverWrapper.main(DriverWrapper.scala) > Caused by: java.lang.NoSuchMethodError: > org.apache.spark.api.java.JavaPairRDD.reduce(Lorg/apache/spark/api/java/function/Function2;)Lscala/Tuple2; > at JavaPairRDDReduceTest.main(JavaPairRDDReduceTest.java:49)... > I'm using Spark 0.9.1. I checked to ensure that I'm compiling with the same > version of Spark as I am running on the cluster. The reduce() method works > fine with JavaRDD, just not with JavaPairRDD. Here is a code snippet that > exhibits the problem: > ArrayList array = new ArrayList<>(); > for (int i = 0; i < 10; ++i) { > array.add(i); > } > JavaRDD rdd = javaSparkContext.parallelize(array); > JavaPairRDD testRDD = rdd.map(new > PairFunction() { > @Override > public Tuple2 call(Integer t) throws Exception { > return new Tuple2<>("" + t, t); > } > }).cache(); > > testRDD.reduce(new Function2, Tuple2 Integer>, Tuple2>() { > @Override > public Tuple2 call(Tuple2 arg0, > Tuple2 arg1) throws Exception { > return new Tuple2<>(arg0._1 + arg1._1, arg0._2 * 10 + arg0._2); > } > }); -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (SPARK-1834) NoSuchMethodError when invoking JavaPairRDD.reduce() in Java
[ https://issues.apache.org/jira/browse/SPARK-1834?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14365438#comment-14365438 ] Josh Rosen commented on SPARK-1834: --- Note that SPARK-3266 has now been fixed for 1.3.1 / 1.4.0. > NoSuchMethodError when invoking JavaPairRDD.reduce() in Java > > > Key: SPARK-1834 > URL: https://issues.apache.org/jira/browse/SPARK-1834 > Project: Spark > Issue Type: Bug > Components: Spark Core >Affects Versions: 0.9.1 > Environment: Redhat Linux, Java 7, Hadoop 2.2, Scala 2.10.4 >Reporter: John Snodgrass > > I get a java.lang.NoSuchMethod error when invoking JavaPairRDD.reduce(). Here > is the partial stack trace: > Exception in thread "main" java.lang.reflect.InvocationTargetException > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) > at > org.apache.spark.deploy.worker.DriverWrapper$.main(DriverWrapper.scala:39) > at > org.apache.spark.deploy.worker.DriverWrapper.main(DriverWrapper.scala) > Caused by: java.lang.NoSuchMethodError: > org.apache.spark.api.java.JavaPairRDD.reduce(Lorg/apache/spark/api/java/function/Function2;)Lscala/Tuple2; > at JavaPairRDDReduceTest.main(JavaPairRDDReduceTest.java:49)... > I'm using Spark 0.9.1. I checked to ensure that I'm compiling with the same > version of Spark as I am running on the cluster. The reduce() method works > fine with JavaRDD, just not with JavaPairRDD. Here is a code snippet that > exhibits the problem: > ArrayList array = new ArrayList<>(); > for (int i = 0; i < 10; ++i) { > array.add(i); > } > JavaRDD rdd = javaSparkContext.parallelize(array); > JavaPairRDD testRDD = rdd.map(new > PairFunction() { > @Override > public Tuple2 call(Integer t) throws Exception { > return new Tuple2<>("" + t, t); > } > }).cache(); > > testRDD.reduce(new Function2, Tuple2 Integer>, Tuple2>() { > @Override > public Tuple2 call(Tuple2 arg0, > Tuple2 arg1) throws Exception { > return new Tuple2<>(arg0._1 + arg1._1, arg0._2 * 10 + arg0._2); > } > }); -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (SPARK-1834) NoSuchMethodError when invoking JavaPairRDD.reduce() in Java
[ https://issues.apache.org/jira/browse/SPARK-1834?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14085567#comment-14085567 ] Franklyn Dsouza commented on SPARK-1834: There is no reduce function in JavaPairRDD > NoSuchMethodError when invoking JavaPairRDD.reduce() in Java > > > Key: SPARK-1834 > URL: https://issues.apache.org/jira/browse/SPARK-1834 > Project: Spark > Issue Type: Bug > Components: Spark Core >Affects Versions: 0.9.1 > Environment: Redhat Linux, Java 7, Hadoop 2.2, Scala 2.10.4 >Reporter: John Snodgrass > > I get a java.lang.NoSuchMethod error when invoking JavaPairRDD.reduce(). Here > is the partial stack trace: > Exception in thread "main" java.lang.reflect.InvocationTargetException > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) > at > org.apache.spark.deploy.worker.DriverWrapper$.main(DriverWrapper.scala:39) > at > org.apache.spark.deploy.worker.DriverWrapper.main(DriverWrapper.scala) > Caused by: java.lang.NoSuchMethodError: > org.apache.spark.api.java.JavaPairRDD.reduce(Lorg/apache/spark/api/java/function/Function2;)Lscala/Tuple2; > at JavaPairRDDReduceTest.main(JavaPairRDDReduceTest.java:49)... > I'm using Spark 0.9.1. I checked to ensure that I'm compiling with the same > version of Spark as I am running on the cluster. The reduce() method works > fine with JavaRDD, just not with JavaPairRDD. Here is a code snippet that > exhibits the problem: > ArrayList array = new ArrayList<>(); > for (int i = 0; i < 10; ++i) { > array.add(i); > } > JavaRDD rdd = javaSparkContext.parallelize(array); > JavaPairRDD testRDD = rdd.map(new > PairFunction() { > @Override > public Tuple2 call(Integer t) throws Exception { > return new Tuple2<>("" + t, t); > } > }).cache(); > > testRDD.reduce(new Function2, Tuple2 Integer>, Tuple2>() { > @Override > public Tuple2 call(Tuple2 arg0, > Tuple2 arg1) throws Exception { > return new Tuple2<>(arg0._1 + arg1._1, arg0._2 * 10 + arg0._2); > } > }); -- This message was sent by Atlassian JIRA (v6.2#6252) - To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (SPARK-1834) NoSuchMethodError when invoking JavaPairRDD.reduce() in Java
[ https://issues.apache.org/jira/browse/SPARK-1834?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14086085#comment-14086085 ] Sean Owen commented on SPARK-1834: -- [~franklynDsouza] There is a reduce method available in JavaPairRDD, but it is defined in the superclass JavaRDDLike. [~jws] This method does exist. When you encounter NoSuchMethodError it's a sign that the compile and runtime versions don't match, but here this method should have been present for a long time in Spark. I don't know if this matters, but I see you use map to generate a JavaPairRDD when I thought you had to use mapToPair to get it using a PairFunction. > NoSuchMethodError when invoking JavaPairRDD.reduce() in Java > > > Key: SPARK-1834 > URL: https://issues.apache.org/jira/browse/SPARK-1834 > Project: Spark > Issue Type: Bug > Components: Spark Core >Affects Versions: 0.9.1 > Environment: Redhat Linux, Java 7, Hadoop 2.2, Scala 2.10.4 >Reporter: John Snodgrass > > I get a java.lang.NoSuchMethod error when invoking JavaPairRDD.reduce(). Here > is the partial stack trace: > Exception in thread "main" java.lang.reflect.InvocationTargetException > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) > at > org.apache.spark.deploy.worker.DriverWrapper$.main(DriverWrapper.scala:39) > at > org.apache.spark.deploy.worker.DriverWrapper.main(DriverWrapper.scala) > Caused by: java.lang.NoSuchMethodError: > org.apache.spark.api.java.JavaPairRDD.reduce(Lorg/apache/spark/api/java/function/Function2;)Lscala/Tuple2; > at JavaPairRDDReduceTest.main(JavaPairRDDReduceTest.java:49)... > I'm using Spark 0.9.1. I checked to ensure that I'm compiling with the same > version of Spark as I am running on the cluster. The reduce() method works > fine with JavaRDD, just not with JavaPairRDD. Here is a code snippet that > exhibits the problem: > ArrayList array = new ArrayList<>(); > for (int i = 0; i < 10; ++i) { > array.add(i); > } > JavaRDD rdd = javaSparkContext.parallelize(array); > JavaPairRDD testRDD = rdd.map(new > PairFunction() { > @Override > public Tuple2 call(Integer t) throws Exception { > return new Tuple2<>("" + t, t); > } > }).cache(); > > testRDD.reduce(new Function2, Tuple2 Integer>, Tuple2>() { > @Override > public Tuple2 call(Tuple2 arg0, > Tuple2 arg1) throws Exception { > return new Tuple2<>(arg0._1 + arg1._1, arg0._2 * 10 + arg0._2); > } > }); -- This message was sent by Atlassian JIRA (v6.2#6252) - To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (SPARK-1834) NoSuchMethodError when invoking JavaPairRDD.reduce() in Java
[ https://issues.apache.org/jira/browse/SPARK-1834?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14086643#comment-14086643 ] John Snodgrass commented on SPARK-1834: --- [~srowen] In version 0.9.1, the map method was overloaded: https://spark.apache.org/docs/0.9.1/api/core/index.html#org.apache.spark.api.java.JavaRDD It was broken out into several different methods, including mapToPair, in a later version of Spark. I think it was 1.0.0. I'm running 0.9.1. > NoSuchMethodError when invoking JavaPairRDD.reduce() in Java > > > Key: SPARK-1834 > URL: https://issues.apache.org/jira/browse/SPARK-1834 > Project: Spark > Issue Type: Bug > Components: Spark Core >Affects Versions: 0.9.1 > Environment: Redhat Linux, Java 7, Hadoop 2.2, Scala 2.10.4 >Reporter: John Snodgrass > > I get a java.lang.NoSuchMethod error when invoking JavaPairRDD.reduce(). Here > is the partial stack trace: > Exception in thread "main" java.lang.reflect.InvocationTargetException > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) > at > org.apache.spark.deploy.worker.DriverWrapper$.main(DriverWrapper.scala:39) > at > org.apache.spark.deploy.worker.DriverWrapper.main(DriverWrapper.scala) > Caused by: java.lang.NoSuchMethodError: > org.apache.spark.api.java.JavaPairRDD.reduce(Lorg/apache/spark/api/java/function/Function2;)Lscala/Tuple2; > at JavaPairRDDReduceTest.main(JavaPairRDDReduceTest.java:49)... > I'm using Spark 0.9.1. I checked to ensure that I'm compiling with the same > version of Spark as I am running on the cluster. The reduce() method works > fine with JavaRDD, just not with JavaPairRDD. Here is a code snippet that > exhibits the problem: > ArrayList array = new ArrayList<>(); > for (int i = 0; i < 10; ++i) { > array.add(i); > } > JavaRDD rdd = javaSparkContext.parallelize(array); > JavaPairRDD testRDD = rdd.map(new > PairFunction() { > @Override > public Tuple2 call(Integer t) throws Exception { > return new Tuple2<>("" + t, t); > } > }).cache(); > > testRDD.reduce(new Function2, Tuple2 Integer>, Tuple2>() { > @Override > public Tuple2 call(Tuple2 arg0, > Tuple2 arg1) throws Exception { > return new Tuple2<>(arg0._1 + arg1._1, arg0._2 * 10 + arg0._2); > } > }); -- This message was sent by Atlassian JIRA (v6.2#6252) - To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (SPARK-1834) NoSuchMethodError when invoking JavaPairRDD.reduce() in Java
[ https://issues.apache.org/jira/browse/SPARK-1834?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14086649#comment-14086649 ] Sean Owen commented on SPARK-1834: -- Ah, you're right: https://github.com/apache/spark/commit/181ec5030792a10f3ce77e997d0e2eda9bcd6139 It was unlikely to be the problem anyway. Very strange. > NoSuchMethodError when invoking JavaPairRDD.reduce() in Java > > > Key: SPARK-1834 > URL: https://issues.apache.org/jira/browse/SPARK-1834 > Project: Spark > Issue Type: Bug > Components: Spark Core >Affects Versions: 0.9.1 > Environment: Redhat Linux, Java 7, Hadoop 2.2, Scala 2.10.4 >Reporter: John Snodgrass > > I get a java.lang.NoSuchMethod error when invoking JavaPairRDD.reduce(). Here > is the partial stack trace: > Exception in thread "main" java.lang.reflect.InvocationTargetException > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) > at > org.apache.spark.deploy.worker.DriverWrapper$.main(DriverWrapper.scala:39) > at > org.apache.spark.deploy.worker.DriverWrapper.main(DriverWrapper.scala) > Caused by: java.lang.NoSuchMethodError: > org.apache.spark.api.java.JavaPairRDD.reduce(Lorg/apache/spark/api/java/function/Function2;)Lscala/Tuple2; > at JavaPairRDDReduceTest.main(JavaPairRDDReduceTest.java:49)... > I'm using Spark 0.9.1. I checked to ensure that I'm compiling with the same > version of Spark as I am running on the cluster. The reduce() method works > fine with JavaRDD, just not with JavaPairRDD. Here is a code snippet that > exhibits the problem: > ArrayList array = new ArrayList<>(); > for (int i = 0; i < 10; ++i) { > array.add(i); > } > JavaRDD rdd = javaSparkContext.parallelize(array); > JavaPairRDD testRDD = rdd.map(new > PairFunction() { > @Override > public Tuple2 call(Integer t) throws Exception { > return new Tuple2<>("" + t, t); > } > }).cache(); > > testRDD.reduce(new Function2, Tuple2 Integer>, Tuple2>() { > @Override > public Tuple2 call(Tuple2 arg0, > Tuple2 arg1) throws Exception { > return new Tuple2<>(arg0._1 + arg1._1, arg0._2 * 10 + arg0._2); > } > }); -- This message was sent by Atlassian JIRA (v6.2#6252) - To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org