You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Ian Hummel (JIRA)" <ji...@apache.org> on 2014/07/01 15:47:25 UTC
[jira] [Comment Edited] (SPARK-2331) SparkContext.emptyRDD has
wrong return type
[ https://issues.apache.org/jira/browse/SPARK-2331?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14048884#comment-14048884 ]
Ian Hummel edited comment on SPARK-2331 at 7/1/14 1:46 PM:
-----------------------------------------------------------
Hi Sean,
The code I was testing was actually equivalent to your second example. I'm not sure if this is a covariance issue or not though, because both the RDD and the EmptyRDD above are parameterized by type {{String}}.
Most of other RDD methods return {{RDD\[T\]}} explicitly. Compare the functions below
{code}
/** Build the union of a list of RDDs. */
def union[T: ClassTag](rdds: Seq[RDD[T]]): RDD[T] = new UnionRDD(this, rdds)
/** Build the union of a list of RDDs passed as variable-length arguments. */
def union[T: ClassTag](first: RDD[T], rest: RDD[T]*): RDD[T] =
new UnionRDD(this, Seq(first) ++ rest)
/** Get an RDD that has no partitions or elements. */
def emptyRDD[T: ClassTag] = new EmptyRDD[T](this)
{code}
Is it really just a case of forgetting to annotate the return type properly?
was (Author: themodernlife):
Hi Sean,
The code I was testing was actually equivalent to your second example. I'm not sure if this is a covariance issue or not though, because both the RDD and the EmptyRDD above are parameterized by type {{String}}.
Most of other RDD methods return {{RDD[T]}} explicitly. Compare the functions below
{monospace}
/** Build the union of a list of RDDs. */
def union[T: ClassTag](rdds: Seq[RDD[T]]): RDD[T] = new UnionRDD(this, rdds)
/** Build the union of a list of RDDs passed as variable-length arguments. */
def union[T: ClassTag](first: RDD[T], rest: RDD[T]*): RDD[T] =
new UnionRDD(this, Seq(first) ++ rest)
/** Get an RDD that has no partitions or elements. */
def emptyRDD[T: ClassTag] = new EmptyRDD[T](this)
{monospace}
Is it really just a case of forgetting to annotate the return type properly?
> SparkContext.emptyRDD has wrong return type
> -------------------------------------------
>
> Key: SPARK-2331
> URL: https://issues.apache.org/jira/browse/SPARK-2331
> Project: Spark
> Issue Type: Bug
> Affects Versions: 1.0.0
> Reporter: Ian Hummel
>
> The return type for SparkContext.emptyRDD is EmptyRDD[T].
> It should be RDD[T]. That means you have to add extra type annotations on code like the below (which creates a union of RDDs over some subset of paths in a folder)
> val rdds = Seq("a", "b", "c").foldLeft[RDD[String]](sc.emptyRDD[String]) { (rdd, path) ⇒
> rdd.union(sc.textFile(path))
> }
--
This message was sent by Atlassian JIRA
(v6.2#6252)