hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdoug...@apache.org
Subject svn commit: r919648 - in /hadoop/common/branches/branch-0.20: ./ src/mapred/org/apache/hadoop/mapreduce/lib/input/ src/test/org/apache/hadoop/mapreduce/lib/input/
Date Fri, 05 Mar 2010 22:21:02 GMT
Author: cdouglas
Date: Fri Mar  5 22:21:02 2010
New Revision: 919648

URL: http://svn.apache.org/viewvc?rev=919648&view=rev
Log:
MAPREDUCE-1522. FileInputFormat may use the default FileSystem for the
input path. Contributed by Tsz Wo (Nicholas), SZE

Added:
    hadoop/common/branches/branch-0.20/src/test/org/apache/hadoop/mapreduce/lib/input/
    hadoop/common/branches/branch-0.20/src/test/org/apache/hadoop/mapreduce/lib/input/TestFileInputFormat.java
Modified:
    hadoop/common/branches/branch-0.20/CHANGES.txt
    hadoop/common/branches/branch-0.20/src/mapred/org/apache/hadoop/mapreduce/lib/input/FileInputFormat.java

Modified: hadoop/common/branches/branch-0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20/CHANGES.txt?rev=919648&r1=919647&r2=919648&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.20/CHANGES.txt Fri Mar  5 22:21:02 2010
@@ -2,6 +2,9 @@
 
 Release 0.20.3 - Unreleased
 
+    MAPREDUCE-1522. FileInputFormat may use the default FileSystem for the
+    input path. (Tsz Wo (Nicholas), SZE via cdouglas)
+
 Release 0.20.2 - 2010-2-19
 
   NEW FEATURES

Modified: hadoop/common/branches/branch-0.20/src/mapred/org/apache/hadoop/mapreduce/lib/input/FileInputFormat.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20/src/mapred/org/apache/hadoop/mapreduce/lib/input/FileInputFormat.java?rev=919648&r1=919647&r2=919648&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20/src/mapred/org/apache/hadoop/mapreduce/lib/input/FileInputFormat.java
(original)
+++ hadoop/common/branches/branch-0.20/src/mapred/org/apache/hadoop/mapreduce/lib/input/FileInputFormat.java
Fri Mar  5 22:21:02 2010
@@ -333,12 +333,11 @@
   public static void setInputPaths(Job job, 
                                    Path... inputPaths) throws IOException {
     Configuration conf = job.getConfiguration();
-    FileSystem fs = FileSystem.get(conf);
-    Path path = inputPaths[0].makeQualified(fs);
+    Path path = inputPaths[0].getFileSystem(conf).makeQualified(inputPaths[0]);
     StringBuffer str = new StringBuffer(StringUtils.escapeString(path.toString()));
     for(int i = 1; i < inputPaths.length;i++) {
       str.append(StringUtils.COMMA_STR);
-      path = inputPaths[i].makeQualified(fs);
+      path = inputPaths[i].getFileSystem(conf).makeQualified(inputPaths[i]);
       str.append(StringUtils.escapeString(path.toString()));
     }
     conf.set("mapred.input.dir", str.toString());
@@ -354,8 +353,7 @@
   public static void addInputPath(Job job, 
                                   Path path) throws IOException {
     Configuration conf = job.getConfiguration();
-    FileSystem fs = FileSystem.get(conf);
-    path = path.makeQualified(fs);
+    path = path.getFileSystem(conf).makeQualified(path);
     String dirStr = StringUtils.escapeString(path.toString());
     String dirs = conf.get("mapred.input.dir");
     conf.set("mapred.input.dir", dirs == null ? dirStr : dirs + "," + dirStr);

Added: hadoop/common/branches/branch-0.20/src/test/org/apache/hadoop/mapreduce/lib/input/TestFileInputFormat.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20/src/test/org/apache/hadoop/mapreduce/lib/input/TestFileInputFormat.java?rev=919648&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20/src/test/org/apache/hadoop/mapreduce/lib/input/TestFileInputFormat.java
(added)
+++ hadoop/common/branches/branch-0.20/src/test/org/apache/hadoop/mapreduce/lib/input/TestFileInputFormat.java
Fri Mar  5 22:21:02 2010
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapreduce.lib.input;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.mapreduce.Job;
+
+public class TestFileInputFormat extends TestCase {
+
+  public void testAddInputPath() throws IOException {
+    final Configuration conf = new Configuration();
+    conf.set("fs.default.name", "s3://abc:xyz@hostname/");
+    final Job j = new Job(conf);
+
+    //setup default fs
+    final FileSystem defaultfs = FileSystem.get(conf);
+    System.out.println("defaultfs.getUri() = " + defaultfs.getUri());
+
+    {
+      //test addInputPath
+      final Path original = new Path("file:/foo");
+      System.out.println("original = " + original);
+      FileInputFormat.addInputPath(j, original);
+      final Path[] results = FileInputFormat.getInputPaths(j);
+      System.out.println("results = " + Arrays.asList(results));
+      assertEquals(1, results.length);
+      assertEquals(original, results[0]);
+    }
+
+    {
+      //test setInputPaths
+      final Path original = new Path("file:/bar");
+      System.out.println("original = " + original);
+      FileInputFormat.setInputPaths(j, original);
+      final Path[] results = FileInputFormat.getInputPaths(j);
+      System.out.println("results = " + Arrays.asList(results));
+      assertEquals(1, results.length);
+      assertEquals(original, results[0]);
+    }
+  }
+
+}



Mime
View raw message