Explorar o código

HADOOP-1716. Fix Pipes wordcount example to remove the 'file:' schema from its output path. Contributed by Owen.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@565932 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting %!s(int64=18) %!d(string=hai) anos
pai
achega
3d4b7010bd

+ 4 - 0
CHANGES.txt

@@ -523,6 +523,10 @@ Branch 0.14 (unreleased changes)
 153. HADOOP-1698.  Fix performance problems on map output sorting for jobs
      with large numbers of reduces. (Devaraj Das via omalley)
 
+154. HADOOP-1716.  Fix a Pipes wordcount example to remove the 'file:'
+     schema from its output path.  (omalley via cutting)
+
+
 Release 0.13.0 - 2007-06-08
 
  1. HADOOP-1047.  Fix TestReplication to succeed more reliably.

+ 6 - 0
src/examples/pipes/impl/wordcount-nopipe.cc

@@ -87,9 +87,15 @@ public:
     const HadoopPipes::JobConf* job = context.getJobConf();
     int part = job->getInt("mapred.task.partition");
     std::string outDir = job->get("mapred.output.dir");
+    // remove the file: schema substring
+    std::string::size_type posn = outDir.find(":");
+    HADOOP_ASSERT(posn != std::string::npos, 
+                  "no schema found in output dir: " + outDir);
+    outDir.erase(0, posn+1);
     mkdir(outDir.c_str(), 0777);
     std::string outFile = outDir + "/part-" + HadoopUtils::toString(part);
     file = fopen(outFile.c_str(), "wt");
+    HADOOP_ASSERT(file != NULL, "can't open file for writing: " + outFile);
   }
 
   ~WordCountWriter() {

+ 2 - 1
src/test/org/apache/hadoop/mapred/pipes/TestPipes.java

@@ -150,7 +150,8 @@ public class TestPipes extends TestCase {
     JobConf job = mr.createJobConf();
     job.setInputFormat(WordCountInputFormat.class);
     FileSystem local = FileSystem.getLocal(job);
-    Path testDir = new Path(System.getProperty("test.build.data"), "pipes");
+    Path testDir = new Path("file:" + System.getProperty("test.build.data"), 
+                            "pipes");
     Path inDir = new Path(testDir, "input");
     Path outDir = new Path(testDir, "output");
     Path wordExec = new Path("/testing/bin/application");

+ 1 - 1
src/test/org/apache/hadoop/mapred/pipes/WordCountInputFormat.java

@@ -35,7 +35,7 @@ public class WordCountInputFormat implements InputFormat {
     private String filename;
     WordCountInputSplit() { }
     WordCountInputSplit(Path filename) {
-      this.filename = filename.toString();
+      this.filename = filename.toUri().getPath();
     }
     public void write(DataOutput out) throws IOException { 
       Text.writeString(out, filename);