Skip to content

Commit 209e49c

Browse files
committed
Better fix to style issue.
1 parent 4a5866f commit 209e49c

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

streaming/src/main/scala/org/apache/spark/streaming/rdd/WriteAheadLogBackedBlockRDD.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ class WriteAheadLogBackedBlockRDD[T: ClassTag](
117117
*/
118118
override def getPreferredLocations(split: Partition): Seq[String] = {
119119
val partition = split.asInstanceOf[WriteAheadLogBackedBlockRDDPartition]
120-
def blockLocations = getBlockIdLocations().get(partition.blockId)
120+
val blockLocations = getBlockIdLocations().get(partition.blockId)
121121
def segmentLocations = HdfsUtils.getFileSegmentLocations(
122122
partition.segment.path, partition.segment.offset, partition.segment.length, hadoopConfig)
123-
blockLocations.orElse(segmentLocations).getOrElse(Seq.empty)
123+
blockLocations.getOrElse(segmentLocations)
124124
}
125125
}

streaming/src/main/scala/org/apache/spark/streaming/util/HdfsUtils.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ private[streaming] object HdfsUtils {
5454

5555
/** Get the locations of the HDFS blocks containing the given file segment. */
5656
def getFileSegmentLocations(
57-
path: String, offset: Long, length: Long, conf: Configuration): Option[Seq[String]] = {
57+
path: String, offset: Long, length: Long, conf: Configuration): Array[String] = {
5858
val dfsPath = new Path(path)
5959
val dfs = getFileSystemForPath(dfsPath, conf)
6060
val fileStatus = dfs.getFileStatus(dfsPath)
6161
val blockLocs = Option(dfs.getFileBlockLocations(fileStatus, offset, length))
62-
blockLocs.map(_.flatMap(_.getHosts))
62+
blockLocs.map(_.flatMap(_.getHosts)).getOrElse(Array.empty)
6363
}
6464

6565
def getFileSystemForPath(path: Path, conf: Configuration): FileSystem = {

0 commit comments

Comments
 (0)