hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r568856 - in /lucene/hadoop/trunk: ./ src/java/org/apache/hadoop/io/ src/java/org/apache/hadoop/mapred/
Date Thu, 23 Aug 2007 07:13:24 GMT
Author: ab
Date: Thu Aug 23 00:13:23 2007
New Revision: 568856

URL: http://svn.apache.org/viewvc?rev=568856&view=rev
Log:
HADOOP-1756 Add toString() to some Writable-s.

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/io/BooleanWritable.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/io/GenericWritable.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/io/NullWritable.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/io/ObjectWritable.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/Counters.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?rev=568856&r1=568855&r2=568856&view=diff
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Thu Aug 23 00:13:23 2007
@@ -49,6 +49,8 @@
 
   IMPROVEMENTS
 
+    HADOOP-1756. Add toString() to some Writable-s. (ab)
+
     HADOOP-1727.  New classes: MapWritable and SortedMapWritable.
     (Jim Kellerman via ab)
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/io/BooleanWritable.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/io/BooleanWritable.java?rev=568856&r1=568855&r2=568856&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/io/BooleanWritable.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/io/BooleanWritable.java Thu Aug 23 00:13:23
2007
@@ -85,6 +85,10 @@
     boolean b = ((BooleanWritable) o).value;
     return ((a == b) ? 0 : (a == false) ? -1 : 1);
   }
+  
+  public String toString() {
+    return Boolean.toString(get());
+  }
 
   /** 
    * A Comparator optimized for BooleanWritable. 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/io/GenericWritable.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/io/GenericWritable.java?rev=568856&r1=568855&r2=568856&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/io/GenericWritable.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/io/GenericWritable.java Thu Aug 23 00:13:23
2007
@@ -96,6 +96,11 @@
   public Writable get() {
     return instance;
   }
+  
+  public String toString() {
+    return "GW[" + (instance != null ? ("class=" + instance.getClass().getName() +
+        ",value=" + instance.toString()) : "(null)") + "]";
+  }
 
   public void readFields(DataInput in) throws IOException {
     type = in.readByte();

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/io/NullWritable.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/io/NullWritable.java?rev=568856&r1=568855&r2=568856&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/io/NullWritable.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/io/NullWritable.java Thu Aug 23 00:13:23
2007
@@ -29,6 +29,10 @@
 
   /** Returns the single instance of this class. */
   public static NullWritable get() { return THIS; }
+  
+  public String toString() {
+    return "(null)";
+  }
 
   public void readFields(DataInput in) throws IOException {}
   public void write(DataOutput out) throws IOException {}

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/io/ObjectWritable.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/io/ObjectWritable.java?rev=568856&r1=568855&r2=568856&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/io/ObjectWritable.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/io/ObjectWritable.java Thu Aug 23 00:13:23
2007
@@ -57,6 +57,11 @@
     this.instance = instance;
   }
   
+  public String toString() {
+    return "OW[class=" + declaredClass + ",value=" + instance + "]";
+  }
+
+  
   public void readFields(DataInput in) throws IOException {
     readObject(in, this, this.conf);
   }

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/Counters.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/Counters.java?rev=568856&r1=568855&r2=568856&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/Counters.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/Counters.java Thu Aug 23 00:13:23
2007
@@ -367,6 +367,22 @@
       }
     }
   }
-
+  
+  /**
+   * Return textual representation of the counter values.
+   */
+  public String toString() {
+    StringBuilder sb = new StringBuilder("Counters: " + size());
+    Collection<String> groupNames = getGroupNames();
+    for (String groupName : groupNames) {
+      Group group = getGroup(groupName);
+      sb.append("\n\t" + group.getDisplayName());
+      for (String counterName : group.getCounterNames()) {
+        sb.append("\n\t\t" + group.getDisplayName(counterName) + "=" + 
+                 group.getCounter(counterName));
+      }
+    }
+    return sb.toString();
+  }
   
 }



Mime
View raw message