Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename ExistingRDD to ExternalRDD.
  • Loading branch information
ueshin committed Jul 8, 2016
commit e218f5fbef996ca3e9606cc68bf433c83ebf224e
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class SparkSession private(
def createDataFrame[A <: Product : TypeTag](rdd: RDD[A]): DataFrame = {
SparkSession.setActiveSession(this)
val encoder = Encoders.product[A]
Dataset.ofRows(self, ExistingRDD(rdd)(self)(encoder))
Dataset.ofRows(self, ExternalRDD(rdd)(self)(encoder))
}

/**
Expand Down Expand Up @@ -423,7 +423,7 @@ class SparkSession private(
*/
@Experimental
def createDataset[T : Encoder](data: RDD[T]): Dataset[T] = {
Dataset[T](self, ExistingRDD(data)(self))
Dataset[T](self, ExternalRDD(data)(self))
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,28 @@ object RDDConversions {
}
}

private[sql] object ExistingRDD {
private[sql] object ExternalRDD {

def apply[T: Encoder](rdd: RDD[T])(session: SparkSession): LogicalPlan = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why curry here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I wanted to make the signature similar to the case class constructor.
Should I uncurry?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I'm not sure why we curry the constructor either. Since RDDScan does it, it's ok we follow it. But for this apply method, I don't see the value of doing it. cc @yhuai

Copy link
Contributor

@marmbrus marmbrus Jul 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is probably no reason to use multiple parameter lists here. We sometimes use it for case classes so that arguments that should not effect equality are not included in the generated equals method.

val exisitingRdd = ExistingRDD(CatalystSerde.generateObjAttr[T], rdd)(session)
CatalystSerde.serialize[T](exisitingRdd)
val externalRdd = ExternalRDD(CatalystSerde.generateObjAttr[T], rdd)(session)
CatalystSerde.serialize[T](externalRdd)
}
}

/** Logical plan node for scanning data from an RDD. */
private[sql] case class ExistingRDD[T](
private[sql] case class ExternalRDD[T](
outputObjAttr: Attribute,
rdd: RDD[T])(session: SparkSession)
extends LeafNode with ObjectProducer with MultiInstanceRelation {

override protected final def otherCopyArgs: Seq[AnyRef] = session :: Nil

override def newInstance(): ExistingRDD.this.type =
ExistingRDD(outputObjAttr.newInstance(), rdd)(session).asInstanceOf[this.type]
override def newInstance(): ExternalRDD.this.type =
ExternalRDD(outputObjAttr.newInstance(), rdd)(session).asInstanceOf[this.type]

override def sameResult(plan: LogicalPlan): Boolean = {
plan.canonicalized match {
case ExistingRDD(_, otherRDD) => rdd.id == otherRDD.id
case ExternalRDD(_, otherRDD) => rdd.id == otherRDD.id
case _ => false
}
}
Expand All @@ -110,7 +110,7 @@ private[sql] case class ExistingRDD[T](
}

/** Physical plan node for scanning data from an RDD. */
private[sql] case class ExistingRDDScanExec[T](
private[sql] case class ExternalRDDScanExec[T](
outputObjAttr: Attribute,
rdd: RDD[T]) extends LeafExecNode with ObjectProducerExec {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ private[sql] abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
case logical.RepartitionByExpression(expressions, child, nPartitions) =>
exchange.ShuffleExchange(HashPartitioning(
expressions, nPartitions.getOrElse(numPartitions)), planLater(child)) :: Nil
case ExistingRDD(outputObjAttr, rdd) => ExistingRDDScanExec(outputObjAttr, rdd) :: Nil
case ExternalRDD(outputObjAttr, rdd) => ExternalRDDScanExec(outputObjAttr, rdd) :: Nil
case LogicalRDD(output, rdd) => RDDScanExec(output, rdd, "ExistingRDD") :: Nil
case BroadcastHint(child) => planLater(child) :: Nil
case _ => Nil
Expand Down