hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r524178 - in /lucene/hadoop/trunk: CHANGES.txt src/java/org/apache/hadoop/record/Record.java src/java/org/apache/hadoop/record/compiler/JRecord.java
Date Fri, 30 Mar 2007 17:03:52 GMT
Author: cutting
Date: Fri Mar 30 10:03:51 2007
New Revision: 524178

URL: http://svn.apache.org/viewvc?view=rev&rev=524178
Log:
HADOOP-1165.  In records, replace identical generated toString methods with a method on the
base class.  Contributed by Milind.

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/record/Record.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/record/compiler/JRecord.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=524178&r1=524177&r2=524178
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Fri Mar 30 10:03:51 2007
@@ -52,6 +52,9 @@
     "reduce input records" counter to be "reduce input groups".
     (David Bowen via cutting)
 
+16. HADOOP-1165.  In records, replace idential generated toString
+    methods with a method on the base class.  (Milind Bhandarkar via cutting)
+
 
 Release 0.12.3 (not yet released)
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/record/Record.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/record/Record.java?view=diff&rev=524178&r1=524177&r2=524178
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/record/Record.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/record/Record.java Fri Mar 30 10:03:51
2007
@@ -20,6 +20,7 @@
 
 import java.io.DataInput;
 import java.io.DataOutput;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import org.apache.hadoop.io.WritableComparable;
 
@@ -75,5 +76,17 @@
   public void readFields(final DataInput din) throws java.io.IOException {
     BinaryRecordInput rin = BinaryRecordInput.get(din);
     this.deserialize(rin);
+  }
+
+  // inherit javadoc
+  public String toString() {
+    try {
+      ByteArrayOutputStream s = new ByteArrayOutputStream();
+      CsvRecordOutput a = new CsvRecordOutput(s);
+      this.serialize(a);
+      return new String(s.toByteArray(), "UTF-8");
+    } catch (Throwable ex) {
+      throw new RuntimeException(ex);
+    }
   }
 }

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/record/compiler/JRecord.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/record/compiler/JRecord.java?view=diff&rev=524178&r1=524177&r2=524178
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/record/compiler/JRecord.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/record/compiler/JRecord.java Fri Mar 30
10:03:51 2007
@@ -161,19 +161,6 @@
       cb.append("a.endRecord(tag);\n");
       cb.append("}\n");
       
-      cb.append("public String toString() {\n");
-      cb.append("try {\n");
-      cb.append("java.io.ByteArrayOutputStream s =\n");
-      cb.append("  new java.io.ByteArrayOutputStream();\n");
-      cb.append("org.apache.hadoop.record.CsvRecordOutput a = \n");
-      cb.append("  new org.apache.hadoop.record.CsvRecordOutput(s);\n");
-      cb.append("this.serialize(a);\n");
-      cb.append("return new String(s.toByteArray(), \"UTF-8\");\n");
-      cb.append("} catch (Throwable ex) {\n");
-      cb.append("throw new RuntimeException(ex);\n");
-      cb.append("}\n");
-      cb.append("}\n");
-      
       cb.append("public int compareTo (final Object peer_) throws ClassCastException {\n");
       cb.append("if (!(peer_ instanceof "+name+")) {\n");
       cb.append("throw new ClassCastException(\"Comparing different types of records.\");\n");



Mime
View raw message