You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by an...@apache.org on 2014/10/16 19:52:15 UTC

git commit: [SPARK-3944][Core] Code re-factored as suggested

Repository: spark
Updated Branches:
  refs/heads/master 044583a24 -> 4c589cac4


[SPARK-3944][Core] Code re-factored as suggested

Author: Shiti <ss...@gmail.com>

Closes #2810 from Shiti/master and squashes the following commits:

051d82f [Shiti] setting the default value of uri scheme to "file"  where matching "file" or None yields the same result


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/4c589cac
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/4c589cac
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/4c589cac

Branch: refs/heads/master
Commit: 4c589cac4496c6a4bb8485a340bd0641dca13847
Parents: 044583a
Author: Shiti <ss...@gmail.com>
Authored: Thu Oct 16 10:52:06 2014 -0700
Committer: Andrew Or <an...@gmail.com>
Committed: Thu Oct 16 10:52:06 2014 -0700

----------------------------------------------------------------------
 .../main/scala/org/apache/spark/util/Utils.scala    | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/4c589cac/core/src/main/scala/org/apache/spark/util/Utils.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/org/apache/spark/util/Utils.scala b/core/src/main/scala/org/apache/spark/util/Utils.scala
index cbc4095..53a7512 100644
--- a/core/src/main/scala/org/apache/spark/util/Utils.scala
+++ b/core/src/main/scala/org/apache/spark/util/Utils.scala
@@ -340,8 +340,8 @@ private[spark] object Utils extends Logging {
     val targetFile = new File(targetDir, filename)
     val uri = new URI(url)
     val fileOverwrite = conf.getBoolean("spark.files.overwrite", defaultValue = false)
-    Option(uri.getScheme) match {
-      case Some("http") | Some("https") | Some("ftp") =>
+    Option(uri.getScheme).getOrElse("file") match {
+      case "http" | "https" | "ftp" =>
         logInfo("Fetching " + url + " to " + tempFile)
 
         var uc: URLConnection = null
@@ -374,7 +374,7 @@ private[spark] object Utils extends Logging {
           }
         }
         Files.move(tempFile, targetFile)
-      case Some("file") | None =>
+      case "file" =>
         // In the case of a local file, copy the local file to the target directory.
         // Note the difference between uri vs url.
         val sourceFile = if (uri.isAbsolute) new File(uri) else new File(url)
@@ -403,7 +403,7 @@ private[spark] object Utils extends Logging {
           logInfo("Copying " + sourceFile.getAbsolutePath + " to " + targetFile.getAbsolutePath)
           Files.copy(sourceFile, targetFile)
         }
-      case Some(other) =>
+      case _ =>
         // Use the Hadoop filesystem library, which supports file://, hdfs://, s3://, and others
         val fs = getHadoopFileSystem(uri, hadoopConf)
         val in = fs.open(new Path(uri))
@@ -1401,10 +1401,10 @@ private[spark] object Utils extends Logging {
       paths.split(",").filter { p =>
         val formattedPath = if (windows) formatWindowsPath(p) else p
         val uri = new URI(formattedPath)
-        Option(uri.getScheme) match {
-          case Some(windowsDrive(d)) if windows => false
-          case Some("local") | Some("file") | None => false
-          case Some(other) => true
+        Option(uri.getScheme).getOrElse("file") match {
+          case windowsDrive(d) if windows => false
+          case "local" | "file" => false
+          case _ => true
         }
       }
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org