Ver código fonte

HADOOP-1150. Fix streaming -reducer and -mapper to give them defaults. Contributed by Owen O'Malley.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@521835 13f79535-47bb-0310-9956-ffa450edef68
Thomas White 18 anos atrás
pai
commit
c070cd96af

+ 3 - 0
CHANGES.txt

@@ -11,6 +11,9 @@ Trunk (unreleased changes)
 
  3. HADOOP-1140.  Fix a deadlock in metrics. (David Bowen via cutting)
 
+ 4. HADOOP-1150.  Fix streaming -reducer and -mapper to give them
+    defaults. (Owen O'Malley via tomwhite)
+
 
 Release 0.12.1 - 2007-03-17
 

+ 12 - 8
src/contrib/streaming/src/java/org/apache/hadoop/streaming/StreamJob.java

@@ -368,12 +368,12 @@ public class StreamJob {
         "DFS output directory for the Reduce step", 
         "path", 1, true); 
     Option mapper  = createOption("mapper", 
-        "The streaming command to run", "cmd", 1, true);
+        "The streaming command to run", "cmd", 1, false);
     Option combiner = createOption("combiner", 
         "The streaming command to run", "cmd",1, false);
     // reducer could be NONE 
     Option reducer = createOption("reducer", 
-        "The streaming command to run", "cmd", 1, true); 
+        "The streaming command to run", "cmd", 1, false); 
     Option file = createOption("file", 
         "File/dir to be shipped in the Job jar file", 
         "file", Integer.MAX_VALUE, false, execValidator); 
@@ -692,12 +692,16 @@ public class StreamJob {
 
     String defaultPackage = this.getClass().getPackage().getName();
 
-    Class c = StreamUtil.goodClassOrNull(mapCmd_, defaultPackage);
-    if (c != null) {
-      jobConf_.setMapperClass(c);
-    } else {
-      jobConf_.setMapperClass(PipeMapper.class);
-      jobConf_.set("stream.map.streamprocessor", URLEncoder.encode(mapCmd_, "UTF-8"));
+    Class c;
+    if (mapCmd_ != null) {
+      c = StreamUtil.goodClassOrNull(mapCmd_, defaultPackage);
+      if (c != null) {
+        jobConf_.setMapperClass(c);
+      } else {
+        jobConf_.setMapperClass(PipeMapper.class);
+        jobConf_.set("stream.map.streamprocessor", 
+                     URLEncoder.encode(mapCmd_, "UTF-8"));
+      }
     }
 
     if (comCmd_ != null) {