Skip to content

Commit 25f98d0

Browse files
committed
test read data by NewHadoopRDD.
1 parent 527b367 commit 25f98d0

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

core/src/main/scala/org/apache/spark/internal/config/package.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ package object config {
271271
.createWithDefault(4 * 1024 * 1024)
272272

273273
private[spark] val IGNORE_EMPTY_SPLITS = ConfigBuilder("spark.files.ignoreEmptySplits")
274-
.doc("If true, methods like that use HadoopRDD and NewHadoopRDD such as " +
274+
.doc("If true, methods that use HadoopRDD and NewHadoopRDD such as " +
275275
"SparkContext.textFiles will not create a partition for input splits that are empty.")
276276
.booleanConf
277277
.createWithDefault(false)

core/src/test/scala/org/apache/spark/FileSuite.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,10 @@ class FileSuite extends SparkFunSuite with LocalSparkContext {
561561
val output = new File(tempDir, "output" + outputSuffix)
562562
dataRDD.saveAsNewAPIHadoopFile[NewTextOutputFormat[String, String]](output.getPath)
563563
assert(new File(output, checkPart).exists() === true)
564-
val hadoopRDD = sc.textFile(new File(output, "part-r-*").getPath)
564+
565+
val hadoopRDD = sc.newAPIHadoopFile(new File(output, "part-r-*").getPath,
566+
classOf[NewTextInputFormat], classOf[LongWritable], classOf[Text])
567+
.asInstanceOf[NewHadoopRDD[_, _]]
565568
assert(hadoopRDD.partitions.length === expectedPartitionNum)
566569
}
567570

@@ -575,15 +578,15 @@ class FileSuite extends SparkFunSuite with LocalSparkContext {
575578

576579
// Ensure that if no split is empty, we don't lose any splits
577580
testIgnoreEmptySplits(
578-
data = Array(("key1", "a"), ("key2", "a"), ("key3", "b")),
581+
data = Array(("1", "a"), ("2", "a"), ("3", "b")),
579582
numSlices = 2,
580583
outputSuffix = 1,
581584
checkPart = "part-r-00001",
582585
expectedPartitionNum = 2)
583586

584587
// Ensure that if part of the splits are empty, we remove the splits correctly
585588
testIgnoreEmptySplits(
586-
data = Array(("key1", "a"), ("key2", "a")),
589+
data = Array(("1", "a"), ("2", "b")),
587590
numSlices = 5,
588591
outputSuffix = 2,
589592
checkPart = "part-r-00004",

0 commit comments

Comments
 (0)