Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-11806 Spark 2.0 deprecations and removals
  3. SPARK-14873

Java sampleByKey methods take ju.Map but with Scala Double values; results in type Object

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.6.1
    • 2.0.0
    • Java API, Spark Core
    • None

    Description

      There's this odd bit of code in JavaStratifiedSamplingExample:

          // specify the exact fraction desired from each key Map<K, Object>
          ImmutableMap<Integer, Object> fractions =
            ImmutableMap.of(1, (Object)0.1, 2, (Object) 0.6, 3, (Object) 0.3);
      
          // Get an approximate sample from each stratum
          JavaPairRDD<Integer, Character> approxSample = data.sampleByKey(false, fractions);
      

      It highlights a problem like that in https://issues.apache.org/jira/browse/SPARK-12604 where Scala primitive types are used where Java requires an object, and the result is that a signature that logically takes Double (objects) takes an Object in the Java API. It's an easy, similar fix.

      Attachments

        Issue Links

          Activity

            People

              srowen Sean R. Owen
              srowen Sean R. Owen
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: