Github user liancheng commented on a diff in the pull request: https://github.com/apache/spark/pull/12153#discussion_r59707908 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileSourceStrategy.scala --- @@ -197,4 +204,26 @@ private[sql] object FileSourceStrategy extends Strategy with Logging { case _ => Nil } + + private def getBlockLocations(file: FileStatus): Array[BlockLocation] = file match { + case f: LocatedFileStatus => f.getBlockLocations + case f => Array.empty[BlockLocation] + } + + // Given locations of all blocks of a single file, `blockLocations`, and an `offset` position of + // the same file, find out the index of the block that contains this `offset`. If no such block + // can be found, returns -1. + private def getBlockIndex(blockLocations: Array[BlockLocation], offset: Long): Int = { + blockLocations.indexWhere { b => + b.getOffset <= offset && offset < b.getOffset + b.getLength + } + } + + // Given locations of all blocks of a single file, `blockLocations`, and an `offset` position of + // the same file, find out the block that contains this `offset`, and returns location hosts of + // that block. If no such block can be found, returns an empty array. + private def getBlockHosts(blockLocations: Array[BlockLocation], offset: Long): Array[String] = { --- End diff -- Makes sense, updated.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org