dongjoon-hyun commented on a change in pull request #23383: [SPARK-23817][SQL]
Create file source V2 framework and migrate ORC read path
URL: https://github.com/apache/spark/pull/23383#discussion_r247025611
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileScanRDD.scala
##########
@@ -57,7 +58,25 @@ case class PartitionedFile(
* A collection of file blocks that should be read as a single task
* (possibly from multiple partitioned directories).
*/
-case class FilePartition(index: Int, files: Seq[PartitionedFile]) extends
RDDPartition
+case class FilePartition(index: Int, files: Seq[PartitionedFile])
+ extends RDDPartition with InputPartition {
+ override def preferredLocations(): Array[String] = {
+ // Computes total number of bytes can be retrieved from each host.
+ val hostToNumBytes = mutable.HashMap.empty[String, Long]
+ files.foreach { file =>
+ file.locations.filter(_ != "localhost").foreach { host =>
+ hostToNumBytes(host) = hostToNumBytes.getOrElse(host, 0L) + file.length
+ }
+ }
+
+ // Takes the first 3 hosts with the most data to be retrieved
+ hostToNumBytes.toSeq.sortBy {
+ case (host, numBytes) => numBytes
+ }.reverse.take(3).map {
+ case (host, numBytes) => host
+ }.toArray
Review comment:
Since this is `FilePartition`, can we move this logic to `FilePartitionUtil`
object?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]