Skip to content

Commit

Permalink
Better fix to style issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
tdas committed Oct 30, 2014
1 parent 4a5866f commit 209e49c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ class WriteAheadLogBackedBlockRDD[T: ClassTag](
*/
override def getPreferredLocations(split: Partition): Seq[String] = {
val partition = split.asInstanceOf[WriteAheadLogBackedBlockRDDPartition]
def blockLocations = getBlockIdLocations().get(partition.blockId)
val blockLocations = getBlockIdLocations().get(partition.blockId)
def segmentLocations = HdfsUtils.getFileSegmentLocations(
partition.segment.path, partition.segment.offset, partition.segment.length, hadoopConfig)
blockLocations.orElse(segmentLocations).getOrElse(Seq.empty)
blockLocations.getOrElse(segmentLocations)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ private[streaming] object HdfsUtils {

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

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

0 comments on commit 209e49c

Please sign in to comment.