Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-1040

Collect as Map throws a casting exception when run on a JavaPairRDD object

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 0.9.0
    • 0.9.1
    • Java API
    • None

    Description

      The error that arises

      Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Lscala.Tuple2;
      	at org.apache.spark.rdd.PairRDDFunctions.collectAsMap(PairRDDFunctions.scala:427)
      	at org.apache.spark.api.java.JavaPairRDD.collectAsMap(JavaPairRDD.scala:409)
      

      The code being executed

      public static String ImageSummary(final JavaPairRDD<Integer,int[]> inImg) {
      		final Set<Integer> keyList=inImg.collectAsMap().keySet();
      		for(Integer cVal: keyList) outString+=cVal+",";
      		return outString;
      	}
      

      The line 426-427 from PairRDDFunctions.scala

       def collectAsMap(): Map[K, V] = {
          val data = self.toArray()
      

      Attachments

        Issue Links

          Activity

            People

              joshrosen Josh Rosen
              kevinmader Kevin Mader
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: