incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r703297 - in /incubator/hama/trunk: CHANGES.txt src/java/org/apache/hama/shell/HamaShellEnv.java src/java/org/apache/hama/shell/execution/HamaOperation.java src/java/org/apache/hama/shell/parser/expression/HamaExpressionParser.jjt
Date Fri, 10 Oct 2008 00:19:15 GMT
Author: edwardyoon
Date: Thu Oct  9 17:19:14 2008
New Revision: 703297

URL: http://svn.apache.org/viewvc?rev=703297&view=rev
Log:
Set the number of map/reduce task on the shell 

Modified:
    incubator/hama/trunk/CHANGES.txt
    incubator/hama/trunk/src/java/org/apache/hama/shell/HamaShellEnv.java
    incubator/hama/trunk/src/java/org/apache/hama/shell/execution/HamaOperation.java
    incubator/hama/trunk/src/java/org/apache/hama/shell/parser/expression/HamaExpressionParser.jjt

Modified: incubator/hama/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/CHANGES.txt?rev=703297&r1=703296&r2=703297&view=diff
==============================================================================
--- incubator/hama/trunk/CHANGES.txt (original)
+++ incubator/hama/trunk/CHANGES.txt Thu Oct  9 17:19:14 2008
@@ -26,6 +26,7 @@
   IMPROVEMENTS
     
     HAMA-76: Remove load() since it duplicated with constructor (edwardyoon)
+    HAMA-74: set the number of map/reduce task on the shell (samuel)
     HAMA-73: Add setNumMap/ReduceTasks() to HamaConfiguration (edwardyoon)
     HAMA-60: Add an arguments for handle parallel degree to MatrixAddition (edwardyoon)
     HAMA-68: Shell parser JUnit test cases (samuel via edwardyoon)

Modified: incubator/hama/trunk/src/java/org/apache/hama/shell/HamaShellEnv.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/shell/HamaShellEnv.java?rev=703297&r1=703296&r2=703297&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/shell/HamaShellEnv.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/shell/HamaShellEnv.java Thu Oct  9 17:19:14
2008
@@ -35,6 +35,9 @@
 
   Map<String, Object> aliases = new HashMap<String, Object>();
   
+  public static final int DEFAULT_MAP_NUM = 2;
+  public static final int DEFAULT_REDUCE_NUM = 1;
+  
   public Object getAliase(String var) {
     return aliases.get(var);
   }

Modified: incubator/hama/trunk/src/java/org/apache/hama/shell/execution/HamaOperation.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/shell/execution/HamaOperation.java?rev=703297&r1=703296&r2=703297&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/shell/execution/HamaOperation.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/shell/execution/HamaOperation.java Thu Oct
 9 17:19:14 2008
@@ -25,7 +25,6 @@
 public abstract class HamaOperation {
 
   HamaConfiguration conf;
-  int map, reduce;
   
   public HamaOperation(HamaConfiguration conf) {
     this(conf, 2, 1);
@@ -33,16 +32,16 @@
   
   public HamaOperation(HamaConfiguration conf, int map, int reduce) {
     this.conf = conf;
-    this.map = map;
-    this.reduce = reduce;
+    this.conf.setNumMapTasks(map);
+    this.conf.setNumReduceTasks(reduce);
   }
   
-  public void setMapNum(int mapNum) {
-    this.map = mapNum;
+  public void setNumMapTasks(int mapNum) {
+    this.conf.setNumMapTasks(mapNum);
   }
   
-  public void setReduceNum(int reduceNum) {
-    this.reduce = reduceNum;
+  public void setNumReduceTasks(int reduceNum) {
+    this.conf.setNumReduceTasks(reduceNum);
   }
   
   /**

Modified: incubator/hama/trunk/src/java/org/apache/hama/shell/parser/expression/HamaExpressionParser.jjt
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/shell/parser/expression/HamaExpressionParser.jjt?rev=703297&r1=703296&r2=703297&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/shell/parser/expression/HamaExpressionParser.jjt
(original)
+++ incubator/hama/trunk/src/java/org/apache/hama/shell/parser/expression/HamaExpressionParser.jjt
Thu Oct  9 17:19:14 2008
@@ -149,22 +149,30 @@
 }
 
 /** An Expression. */
-HamaExpression Expression() : {HamaExpression expression = null; Token t1, t2, t3; Object
value; String filename; HamaOperation operation;}
+HamaExpression Expression() : {boolean isMapNumSet = false; boolean isReduceNumSet = false;
HamaExpression expression = null; Token t1, t2, t3; Object value; String filename; HamaOperation
operation;}
 {
   (
   ( t3=<IDENTIFIER> "=" operation=BasicOperation() 
   	[ <MAP> t1=<INTEGER>
   	  {
-  	  	operation.setMapNum(Integer.valueOf(t1.image));
+  	  	operation.setNumMapTasks(Integer.valueOf(t1.image));
+  	  	isMapNumSet = true;
   	  } 
   	] 
   	[ <REDUCE> t2=<INTEGER>
   	  {
-  	  	operation.setReduceNum(Integer.valueOf(t2.image));
+  	  	operation.setNumReduceTasks(Integer.valueOf(t2.image));
+  	  	isReduceNumSet = true;
   	  } 
   	] 
   ) 
-  { expression = new EvalExpression(conf, shellEnv, t3.image, operation); } 
+  { 
+  	if(!isMapNumSet)
+  	  operation.setNumMapTasks(HamaShellEnv.DEFAULT_MAP_NUM);
+  	if(!isReduceNumSet)
+  	  operation.setNumReduceTasks(HamaShellEnv.DEFAULT_REDUCE_NUM);
+  	expression = new EvalExpression(conf, shellEnv, t3.image, operation); 
+  } 
   | 
   ( <SAVE> value=AliaseName() <AS> filename=FileName() ) 
   { expression = new SaveExpression(conf, shellEnv, value, filename); }



Mime
View raw message