You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by cu...@apache.org on 2009/08/13 00:35:01 UTC

svn commit: r803730 - in /hadoop/avro/trunk: CHANGES.txt src/java/org/apache/avro/specific/SpecificCompiler.java

Author: cutting
Date: Wed Aug 12 22:35:00 2009
New Revision: 803730

URL: http://svn.apache.org/viewvc?rev=803730&view=rev
Log:
AVRO-89.  Use unboxed types for generated fields.

Modified:
    hadoop/avro/trunk/CHANGES.txt
    hadoop/avro/trunk/src/java/org/apache/avro/specific/SpecificCompiler.java

Modified: hadoop/avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=803730&r1=803729&r2=803730&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Wed Aug 12 22:35:00 2009
@@ -30,6 +30,9 @@
     AVRO-84, AVRO-85.  Clarify a few things in the specification
     document.  (Thiruvalluvan M. G. and cutting)
 
+    AVRO-89. In fields of Java generated classes, use unboxed numeric
+    types.  (cutting)
+
   OPTIMIZATIONS
 
   BUG FIXES

Modified: hadoop/avro/trunk/src/java/org/apache/avro/specific/SpecificCompiler.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/java/org/apache/avro/specific/SpecificCompiler.java?rev=803730&r1=803729&r2=803730&view=diff
==============================================================================
--- hadoop/avro/trunk/src/java/org/apache/avro/specific/SpecificCompiler.java (original)
+++ hadoop/avro/trunk/src/java/org/apache/avro/specific/SpecificCompiler.java Wed Aug 12 22:35:00 2009
@@ -150,7 +150,7 @@
       // field declations
       for (Map.Entry<String, Schema> field : schema.getFieldSchemas()) {
         String fieldName = field.getKey();
-        line(d+1, "public "+type(field.getValue(),fieldName)+" "+fieldName+";");
+        line(d+1,"public "+unbox(field.getValue(),fieldName)+" "+fieldName+";");
       }
       // schema method
       line(d+1, "public Schema schema() { return _SCHEMA; }");
@@ -246,6 +246,17 @@
     }
   }
 
+  private String unbox(Schema schema, String name) {
+    switch (schema.getType()) {
+    case INT:     return "int";
+    case LONG:    return "long";
+    case FLOAT:   return "float";
+    case DOUBLE:  return "double";
+    case BOOLEAN: return "boolean";
+    default:      return type(schema, name);
+    }
+  }
+
   private void line(int indent, String text) {
     for (int i = 0; i < indent; i ++) {
       buffer.append("  ");