Skip to content
Closed
Prev Previous commit
also fix default path for sc.wholeTextFiles and identation based on CR
  • Loading branch information
wyaron committed Dec 24, 2015
commit 08d3fe25e4621812d963af502815a508da8930c8
2 changes: 1 addition & 1 deletion core/src/main/scala/org/apache/spark/SparkContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli
classOf[Text],
classOf[Text],
updateConf,
minPartitions).setName(path).map(record => (record._1.toString, record._2.toString))
minPartitions).map(record => (record._1.toString, record._2.toString)).setName(path)
}

/**
Expand Down
32 changes: 16 additions & 16 deletions core/src/test/scala/org/apache/spark/SparkContextSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -274,29 +274,29 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext {
}
}

test("Default path for file based RDDs is properly set (SPARK-12517)") {
sc = new SparkContext(new SparkConf().setAppName("test").setMaster("local"))
test("Default path for file based RDDs is properly set (SPARK-12517)") {
sc = new SparkContext(new SparkConf().setAppName("test").setMaster("local"))

// Test filetextFile, wholeTextFiles, binaryFiles, hadoopFile and
// newAPIHadoopFile for setting the default path as the RDD name
val mockPath = "default/path/for/"
// Test filetextFile, wholeTextFiles, binaryFiles, hadoopFile and
// newAPIHadoopFile for setting the default path as the RDD name
val mockPath = "default/path/for/"

var targetPath = mockPath + "textFile"
assert(sc.textFile(targetPath).name == targetPath)
var targetPath = mockPath + "textFile"
assert(sc.textFile(targetPath).name === targetPath)

Copy link
Member

Choose a reason for hiding this comment

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

Could you compare by === instead of == ?
We can get better error messages by === operator.

targetPath = mockPath + "wholeTextFiles"
assert(sc.wholeTextFiles(targetPath).name == targetPath)
targetPath = mockPath + "wholeTextFiles"
assert(sc.wholeTextFiles(targetPath).name === targetPath)

targetPath = mockPath + "binaryFiles"
assert(sc.binaryFiles(targetPath).name == targetPath)
targetPath = mockPath + "binaryFiles"
assert(sc.binaryFiles(targetPath).name === targetPath)

targetPath = mockPath + "hadoopFile"
assert(sc.hadoopFile(targetPath).name == targetPath)
targetPath = mockPath + "hadoopFile"
assert(sc.hadoopFile(targetPath).name === targetPath)

targetPath = mockPath + "newAPIHadoopFile"
assert(sc.newAPIHadoopFile(targetPath).name == targetPath)
targetPath = mockPath + "newAPIHadoopFile"
assert(sc.newAPIHadoopFile(targetPath).name === targetPath)

sc.stop()
sc.stop()
}

test("calling multiple sc.stop() must not throw any exception") {
Expand Down