Browse Source

HADOOP-852. Add an ant task to compile record definitions. Contributed by Milind.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@496837 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 years ago
parent
commit
7679e13f69

+ 3 - 0
CHANGES.txt

@@ -11,6 +11,9 @@ Trunk (unreleased changes)
     locations on the basis of network topology.
     (Hairong Kuang via cutting)
 
+ 3. HADOOP-852.  Add an ant task to compile record definitions, and
+    use it to compile record unit tests.  (Milind Bhandarkar via cutting)
+
 
 Release 0.10.1 - 2007-01-10
 

+ 42 - 3
build.xml

@@ -37,6 +37,7 @@
 
   <property name="test.src.dir" value="${basedir}/src/test"/>
   <property name="test.build.dir" value="${build.dir}/test"/>
+  <property name="test.generated.dir" value="${test.build.dir}/src"/>
   <property name="test.build.data" value="${test.build.dir}/data"/>
   <property name="test.cache.data" value="${test.build.dir}/cache"/>
   <property name="test.log.dir" value="${test.build.dir}/logs"/>
@@ -143,7 +144,27 @@
       />
   </target>
   
-  <target name="compile-core-classes" depends="init, record-parser">
+  <target name="compile-rcc-compiler" depends="init, record-parser">
+    <javac 
+        encoding="${build.encoding}" 
+        srcdir="${src.dir}"
+        includes="org/apache/hadoop/record/compiler/**/*.java"
+        destdir="${build.classes}"
+        debug="${javac.debug}"
+        optimize="${javac.optimize}"
+        target="${javac.version}"
+        source="${javac.version}"
+        deprecation="${javac.deprecation}">
+        <classpath refid="classpath"/>
+    </javac>
+    
+    <taskdef name="recordcc" classname="org.apache.hadoop.record.compiler.ant.RccTask">
+      <classpath refid="classpath" />
+    </taskdef>
+  </target>
+  
+  
+  <target name="compile-core-classes" depends="init, compile-rcc-compiler">
 
     <copy file="${src.webapps}/datanode/browseDirectory.jsp" todir="${src.webapps}/dfs/"/>
     <jsp-compile
@@ -319,11 +340,29 @@
     </jar>
   </target>
 
-
+  <target name="generate-test-records" depends="compile-rcc-compiler">
+    <recordcc destdir="${test.generated.dir}">
+      <fileset dir="${test.src.dir}"
+	         includes="**/*.jr" />
+    </recordcc>
+  </target>
+  
   <!-- ================================================================== -->
   <!-- Compile test code                                                  --> 
   <!-- ================================================================== -->
-  <target name="compile-core-test" depends="compile-examples">
+  <target name="compile-core-test" depends="compile-examples, generate-test-records">
+    <javac 
+     encoding="${build.encoding}" 
+     srcdir="${test.generated.dir}"
+     includes="org/apache/hadoop/**/*.java"
+     destdir="${test.build.classes}"
+     debug="${javac.debug}"
+     optimize="${javac.optimize}"
+     target="${javac.version}"
+     source="${javac.version}"
+     deprecation="${javac.deprecation}">
+      <classpath refid="test.classpath"/>
+    </javac>
     <javac 
      encoding="${build.encoding}" 
      srcdir="${test.src.dir}"

+ 3 - 4
src/java/org/apache/hadoop/record/compiler/CppGenerator.java

@@ -30,7 +30,6 @@ import java.util.Iterator;
  * @author Milind Bhandarkar
  */
 class CppGenerator {
-    private String mFullName;
     private String mName;
     private ArrayList mInclFiles;
     private ArrayList mRecList;
@@ -40,10 +39,10 @@ class CppGenerator {
      * @param name possibly full pathname to the file
      * @param ilist included files (as JFile)
      * @param rlist List of records defined within this file
+     * @param destDir Output directory
      */
-    CppGenerator(String name, ArrayList ilist, ArrayList rlist) {
-        mFullName = name;
-        mName = (new File(name)).getName();
+    CppGenerator(String name, ArrayList ilist, ArrayList rlist, String destDir) {
+        mName = new File(destDir, (new File(name)).getName()).getAbsolutePath();
         mInclFiles = ilist;
         mRecList = rlist;
     }

+ 6 - 5
src/java/org/apache/hadoop/record/compiler/JFile.java

@@ -55,16 +55,17 @@ public class JFile {
     /** Generate record code in given language. Language should be all
      *  lowercase.
      */
-    public void genCode(String language) throws IOException {
+    public int genCode(String language, String destDir) throws IOException {
         if ("c++".equals(language)) {
-            CppGenerator gen = new CppGenerator(mName, mInclFiles, mRecords);
+            CppGenerator gen = new CppGenerator(mName, mInclFiles, mRecords, destDir);
             gen.genCode();
         } else if ("java".equals(language)) {
-            JavaGenerator gen = new JavaGenerator(mName, mInclFiles, mRecords);
+            JavaGenerator gen = new JavaGenerator(mName, mInclFiles, mRecords, destDir);
             gen.genCode();
         } else {
-            System.out.println("Cannnot recognize language:"+language);
-            System.exit(1);
+            System.err.println("Cannnot recognize language:"+language);
+            return 1;
         }
+        return 0;
     }
 }

+ 4 - 6
src/java/org/apache/hadoop/record/compiler/JRecord.java

@@ -237,21 +237,19 @@ public class JRecord extends JCompType {
         
     }
     
-    public void genJavaCode() throws IOException {
+    public void genJavaCode(String destDir) throws IOException {
         String pkg = getJavaPackage();
         String pkgpath = pkg.replaceAll("\\.", "/");
-        File pkgdir = new File(pkgpath);
+        File pkgdir = new File(destDir, pkgpath);
         if (!pkgdir.exists()) {
             // create the pkg directory
             boolean ret = pkgdir.mkdirs();
             if (!ret) {
-                System.out.println("Cannnot create directory: "+pkgpath);
-                System.exit(1);
+                throw new IOException("Cannnot create directory: "+pkgpath);
             }
         } else if (!pkgdir.isDirectory()) {
             // not a directory
-            System.out.println(pkgpath+" is not a directory.");
-            System.exit(1);
+            throw new IOException(pkgpath+" is not a directory.");
         }
         File jfile = new File(pkgdir, getName()+".java");
         FileWriter jj = new FileWriter(jfile);

+ 5 - 2
src/java/org/apache/hadoop/record/compiler/JavaGenerator.java

@@ -31,6 +31,7 @@ import java.util.Iterator;
  */
 class JavaGenerator {
     private String mName;
+    private String destDir;
     private ArrayList mInclFiles;
     private ArrayList mRecList;
     
@@ -39,11 +40,13 @@ class JavaGenerator {
      * @param name possibly full pathname to the file
      * @param incl included files (as JFile)
      * @param records List of records defined within this file
+     * @param destDir output directory
      */
-    JavaGenerator(String name, ArrayList incl, ArrayList records) {
+    JavaGenerator(String name, ArrayList incl, ArrayList records, String destDir) {
         mName = name;
         mInclFiles = incl;
         mRecList = records;
+        this.destDir = destDir;
     }
     
     /**
@@ -53,7 +56,7 @@ class JavaGenerator {
     void genCode() throws IOException {
         for (Iterator i = mRecList.iterator(); i.hasNext(); ) {
             JRecord rec = (JRecord) i.next();
-            rec.genJavaCode();
+            rec.genJavaCode(destDir);
         }
     }
 }

+ 136 - 0
src/java/org/apache/hadoop/record/compiler/ant/RccTask.java

@@ -0,0 +1,136 @@
+/**
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.record.compiler.ant;
+
+import java.io.File;
+import java.util.Vector;
+import org.apache.hadoop.record.compiler.generated.Rcc;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.FileSet;
+
+/**
+ * Hadoop record compiler ant Task
+ *<p> This task takes the given record definition files and compiles them into
+ * java or c++
+ * files. It is then up to the user to compile the generated files.
+ *
+ * <p> The task requires the <code>file</code> or the nested fileset element to be
+ * specified. Optional attributes are <code>language</code> (set the output
+ * language, default is "java"),
+ * <code>destdir</code> (name of the destination directory for generated java/c++
+ * code, default is ".") and <code>failonerror</code> (specifies error handling
+ * behavior. default is true).
+ * <p><h4>Usage</h4>
+ * <pre>
+ * &lt;recordcc
+ *       destdir="${basedir}/gensrc"
+ *       language="java"&gt;
+ *   &lt;fileset include="**\/*.jr" /&gt;
+ * &lt;/recordcc&gt;
+ * </pre>
+ *
+ * @author Milind Bhandarkar
+ */
+public class RccTask extends Task {
+  
+  private String language = "java";
+  private File src;
+  private File dest = new File(".");
+  private final Vector<FileSet> filesets = new Vector();
+  private boolean failOnError = true;
+  
+  /** Creates a new instance of RccTask */
+  public RccTask() {
+  }
+  
+  /**
+   * Sets the output language option
+   * @param language "java"/"c++"
+   */
+  public void setLanguage(String language) {
+    this.language = language;
+  }
+  
+  /**
+   * Sets the record definition file attribute
+   * @param file record definition file
+   */
+  public void setFile(File file) {
+    this.src = file;
+  }
+  
+  /**
+   * Given multiple files (via fileset), set the error handling behavior
+   * @param flag true will throw build exception in case of failure (default)
+   */
+  public void setFailonerror(boolean flag) {
+    this.failOnError = flag;
+  }
+  
+  /**
+   * Sets directory where output files will be generated
+   * @param dir output directory
+   */
+  public void setDestdir(File dir) {
+    this.dest = dir;
+  }
+  
+  /**
+   * Adds a fileset that can consist of one or more files
+   * @param set Set of record definition files
+   */
+  public void addFileset(FileSet set) {
+    filesets.add(set);
+  }
+  
+  /**
+   * Invoke the Hadoop record compiler on each record definition file
+   */
+  public void execute() throws BuildException {
+    if (src == null && filesets.size()==0) {
+      throw new BuildException("There must be a file attribute or a fileset child element");
+    }
+    if (src != null) {
+      doCompile(src);
+    }
+    Project myProject = getProject();
+    for (int i = 0; i < filesets.size(); i++) {
+      FileSet fs = filesets.elementAt(i);
+      DirectoryScanner ds = fs.getDirectoryScanner(myProject);
+      File dir = fs.getDir(myProject);
+      String[] srcs = ds.getIncludedFiles();
+      for (int j = 0; j < srcs.length; j++) {
+        doCompile(new File(dir, srcs[j]));
+      }
+    }
+  }
+  
+  private void doCompile(File file) throws BuildException {
+    String[] args = new String[5];
+    args[0] = "--language";
+    args[1] = this.language;
+    args[2] = "--destdir";
+    args[3] = this.dest.getPath();
+    args[4] = file.getPath();
+    int retVal = Rcc.driver(args);
+    if (retVal != 0 && failOnError) {
+      throw new BuildException("Hadoop record compiler returned error code "+retVal);
+    }
+  }
+}

+ 25 - 16
src/java/org/apache/hadoop/record/compiler/generated/Rcc.java

@@ -30,62 +30,71 @@ import java.io.IOException;
 
 public class Rcc implements RccConstants {
     private static String language = "java";
+    private static String destDir = ".";
     private static ArrayList recFiles = new ArrayList();
     private static JFile curFile;
     private static Hashtable recTab;
-    private static String curDir = System.getProperty("user.dir");
+    private static String curDir = ".";
     private static String curFileName;
     private static String curModuleName;
 
-    public static void main(String args[]) {
+    public static void main(String[] args) {
+        System.exit(driver(args));
+    }
+
+    public static int driver(String[] args) {
         for (int i=0; i<args.length; i++) {
             if ("-l".equalsIgnoreCase(args[i]) ||
                 "--language".equalsIgnoreCase(args[i])) {
                 language = args[i+1].toLowerCase();
                 i++;
+            } else if ("-d".equalsIgnoreCase(args[i]) ||
+                "--destdir".equalsIgnoreCase(args[i])) {
+                destDir = args[i+1];
+                i++;
             } else {
                 recFiles.add(args[i]);
             }
         }
         if (!"c++".equals(language) && !"java".equals(language)) {
-            System.out.println("Cannot recognize language:" + language);
-            System.exit(1);
+            System.err.println("Cannot recognize language:" + language);
+            return 1;
         }
         if (recFiles.size() == 0) {
-            System.out.println("No record files specified. Exiting.");
-            System.exit(1);
+            System.err.println("No record files specified. Exiting.");
+            return 1;
         }
         for (int i=0; i<recFiles.size(); i++) {
             curFileName = (String) recFiles.get(i);
-            File file = new File(curDir, curFileName);
+            File file = new File(curFileName);
             try {
                 FileReader reader = new FileReader(file);
                 Rcc parser = new Rcc(reader);
                 try {
                     recTab = new Hashtable();
                     curFile = parser.Input();
-                    System.out.println((String) recFiles.get(i) +
-                        " Parsed Successfully");
                 } catch (ParseException e) {
-                    System.out.println(e.toString());
-                    System.exit(1);
+                    System.err.println(e.toString());
+                    return 1;
                 }
                 try {
                     reader.close();
                 } catch (IOException e) {
                 }
             } catch (FileNotFoundException e) {
-                System.out.println("File " + (String) recFiles.get(i) +
+                System.err.println("File " + (String) recFiles.get(i) +
                     " Not found.");
-                System.exit(1);
+                return 1;
             }
             try {
-                curFile.genCode(language);
+                int retCode = curFile.genCode(language, destDir);
+                if (retCode != 0) { return retCode; }
             } catch (IOException e) {
-                System.out.println(e.toString());
-                System.exit(1);
+                System.err.println(e.toString());
+                return 1;
             }
         }
+        return 0;
     }
 
   final public JFile Input() throws ParseException {

+ 25 - 16
src/java/org/apache/hadoop/record/compiler/generated/rcc.jj

@@ -34,62 +34,71 @@ import java.io.IOException;
 
 public class Rcc {
     private static String language = "java";
+    private static String destDir = ".";
     private static ArrayList recFiles = new ArrayList();
     private static JFile curFile;
     private static Hashtable recTab;
-    private static String curDir = System.getProperty("user.dir");
+    private static String curDir = ".";
     private static String curFileName;
     private static String curModuleName;
 
-    public static void main(String args[]) {
+    public static void main(String[] args) {
+        System.exit(driver(args));
+    }
+ 
+    public static int driver(String[] args) {
         for (int i=0; i<args.length; i++) {
             if ("-l".equalsIgnoreCase(args[i]) ||
                 "--language".equalsIgnoreCase(args[i])) {
                 language = args[i+1].toLowerCase();
                 i++;
+            } else if ("-d".equalsIgnoreCase(args[i]) ||
+                "--destdir".equalsIgnoreCase(args[i])) {
+                destDir = args[i+1];
+                i++;
             } else {
                 recFiles.add(args[i]);
             }
         }
         if (!"c++".equals(language) && !"java".equals(language)) {
-            System.out.println("Cannot recognize language:" + language);
-            System.exit(1);
+            System.err.println("Cannot recognize language:" + language);
+            return 1;
         }
         if (recFiles.size() == 0) {
-            System.out.println("No record files specified. Exiting.");
-            System.exit(1);
+            System.err.println("No record files specified. Exiting.");
+            return 1;
         }
         for (int i=0; i<recFiles.size(); i++) {
             curFileName = (String) recFiles.get(i);
-            File file = new File(curDir, curFileName);
+            File file = new File(curFileName);
             try {
                 FileReader reader = new FileReader(file);
                 Rcc parser = new Rcc(reader);
                 try {
                     recTab = new Hashtable();
                     curFile = parser.Input();
-                    System.out.println((String) recFiles.get(i) +
-                        " Parsed Successfully");
                 } catch (ParseException e) {
-                    System.out.println(e.toString());
-                    System.exit(1);
+                    System.err.println(e.toString());
+                    return 1;
                 }
                 try {
                     reader.close();
                 } catch (IOException e) {
                 }
             } catch (FileNotFoundException e) {
-                System.out.println("File " + (String) recFiles.get(i) +
+                System.err.println("File " + (String) recFiles.get(i) +
                     " Not found.");
-                System.exit(1);
+                return 1;
             }
             try {
-                curFile.genCode(language);
+                int retCode = curFile.genCode(language, destDir);
+                if (retCode != 0) { return retCode; }
             } catch (IOException e) {
-                System.out.println(e.toString());
-                System.exit(1);
+                System.err.println(e.toString());
+                return 1;
             }
         }
+        return 0;
     }
 }
 

+ 0 - 18
src/test/ddl/links.jr

@@ -1,18 +0,0 @@
-include "location.jr"
-
-module org.apache.hadoop.record.Links {
-    class Link {
-        ustring URL;
-        vector<org.apache.hadoop.record.Location.LinkLocation> Locations;
-        boolean IsRelative;
-        double Weight;
-    }
-
-    class HTTP_Transaction {
-        ustring URL;
-        ustring Request;
-        map<ustring,ustring> ResponseHeader;
-        buffer Source;
-    }
-} // end module
-

+ 0 - 8
src/test/ddl/location.jr

@@ -1,8 +0,0 @@
-module org.apache.hadoop.record.Location {
-    class LinkLocation {
-        int RowNum;
-        int ColNum;
-        ustring AnchorText;
-    }
-}
-

+ 0 - 156
src/test/org/apache/hadoop/record/test/RecBuffer.java

@@ -1,156 +0,0 @@
-// File generated by hadoop record compiler. Do not edit.
-package org.apache.hadoop.record.test;
-
-import java.io.IOException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.io.WritableComparator;
-import org.apache.hadoop.io.WritableComparable;
-import org.apache.hadoop.io.WritableUtils;
-import org.apache.hadoop.io.Text;
-
-public class RecBuffer implements org.apache.hadoop.record.Record, WritableComparable {
-  private static final Log LOG= LogFactory.getLog("org.apache.hadoop.record.test.RecBuffer");
-  private java.io.ByteArrayOutputStream mData;
-  private java.util.BitSet bs_;
-  public RecBuffer() {
-    bs_ = new java.util.BitSet(2);
-    bs_.set(1);
-  }
-  public RecBuffer(
-        java.io.ByteArrayOutputStream m0) {
-    bs_ = new java.util.BitSet(2);
-    bs_.set(1);
-    mData=m0; bs_.set(0);
-  }
-  public java.io.ByteArrayOutputStream getData() {
-    return mData;
-  }
-  public void setData(java.io.ByteArrayOutputStream m_) {
-    mData=m_; bs_.set(0);
-  }
-  public void serialize(org.apache.hadoop.record.OutputArchive a_, String tag) throws java.io.IOException {
-    if (!validate()) throw new java.io.IOException("All fields not set:");
-    a_.startRecord(this,tag);
-    a_.writeBuffer(mData,"Data");
-    bs_.clear(0);
-    a_.endRecord(this,tag);
-  }
-  public void deserialize(org.apache.hadoop.record.InputArchive a_, String tag) throws java.io.IOException {
-    a_.startRecord(tag);
-    mData=a_.readBuffer("Data");
-    bs_.set(0);
-    a_.endRecord(tag);
-}
-  public String toString() {
-    try {
-      java.io.ByteArrayOutputStream s =
-        new java.io.ByteArrayOutputStream();
-      org.apache.hadoop.record.CsvOutputArchive a_ = 
-        new org.apache.hadoop.record.CsvOutputArchive(s);
-      a_.startRecord(this,"");
-    a_.writeBuffer(mData,"Data");
-      a_.endRecord(this,"");
-      return new String(s.toByteArray(), "UTF-8");
-    } catch (Throwable ex) {
-      ex.printStackTrace();
-    }
-    return "ERROR";
-  }
-  public void write(java.io.DataOutput out) throws java.io.IOException {
-    org.apache.hadoop.record.BinaryOutputArchive archive = new org.apache.hadoop.record.BinaryOutputArchive(out);
-    serialize(archive, "");
-  }
-  public void readFields(java.io.DataInput in) throws java.io.IOException {
-    org.apache.hadoop.record.BinaryInputArchive archive = new org.apache.hadoop.record.BinaryInputArchive(in);
-    deserialize(archive, "");
-  }
-  public boolean validate() {
-    if (bs_.cardinality() != bs_.length()) return false;
-    return true;
-}
-  public int compareTo (Object peer_) throws ClassCastException {
-    if (!(peer_ instanceof RecBuffer)) {
-      throw new ClassCastException("Comparing different types of records.");
-    }
-    RecBuffer peer = (RecBuffer) peer_;
-    int ret = 0;
-    {
-      byte[] my = mData.toByteArray();
-      byte[] ur = peer.mData.toByteArray();
-      ret = WritableComparator.compareBytes(my,0,my.length,ur,0,ur.length);
-    }
-    if (ret != 0) return ret;
-     return ret;
-  }
-  public boolean equals(Object peer_) {
-    if (!(peer_ instanceof RecBuffer)) {
-      return false;
-    }
-    if (peer_ == this) {
-      return true;
-    }
-    RecBuffer peer = (RecBuffer) peer_;
-    boolean ret = false;
-    ret = org.apache.hadoop.record.Utils.bufEquals(mData,peer.mData);
-    if (!ret) return ret;
-     return ret;
-  }
-  public int hashCode() {
-    int result = 17;
-    int ret;
-    ret = mData.toString().hashCode();
-    result = 37*result + ret;
-    return result;
-  }
-  public static String signature() {
-    return "LRecBuffer(B)";
-  }
-  public static class Comparator extends WritableComparator {
-    public Comparator() {
-      super(RecBuffer.class);
-    }
-    static public int slurpRaw(byte[] b, int s, int l) {
-      try {
-        int os = s;
-        {
-           int i = WritableComparator.readVInt(b, s);
-           int z = WritableUtils.getVIntSize(i);
-           s += z+i; l -= (z+i);
-        }
-        return (os - s);
-      } catch(IOException e) {
-        LOG.warn(e);
-        throw new RuntimeException(e);
-      }
-    }
-    static public int compareRaw(byte[] b1, int s1, int l1,
-                       byte[] b2, int s2, int l2) {
-      try {
-        int os1 = s1;
-        {
-           int i1 = WritableComparator.readVInt(b1, s1);
-           int i2 = WritableComparator.readVInt(b2, s2);
-           int z1 = WritableUtils.getVIntSize(i1);
-           int z2 = WritableUtils.getVIntSize(i2);
-           s1+=z1; s2+=z2; l1-=z1; l2-=z2;
-           int r1 = WritableComparator.compareBytes(b1,s1,l1,b2,s2,l2);
-           if (r1 != 0) { return (r1<0)?-1:0; }
-           s1+=i1; s2+=i2; l1-=i1; l1-=i2;
-        }
-        return (os1 - s1);
-      } catch(IOException e) {
-        LOG.warn(e);
-        throw new RuntimeException(e);
-      }
-    }
-    public int compare(byte[] b1, int s1, int l1,
-                       byte[] b2, int s2, int l2) {
-      int ret = compareRaw(b1,s1,l1,b2,s2,l2);
-      return (ret == -1)? -1 : ((ret==0)? 1 : 0);    }
-  }
-
-  static {
-    WritableComparator.define(RecBuffer.class, new Comparator());
-  }
-}

+ 0 - 152
src/test/org/apache/hadoop/record/test/RecInt.java

@@ -1,152 +0,0 @@
-// File generated by hadoop record compiler. Do not edit.
-package org.apache.hadoop.record.test;
-
-import java.io.IOException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.io.WritableComparator;
-import org.apache.hadoop.io.WritableComparable;
-import org.apache.hadoop.io.WritableUtils;
-import org.apache.hadoop.io.Text;
-
-public class RecInt implements org.apache.hadoop.record.Record, WritableComparable {
-  private static final Log LOG= LogFactory.getLog("org.apache.hadoop.record.test.RecInt");
-  private int mData;
-  private java.util.BitSet bs_;
-  public RecInt() {
-    bs_ = new java.util.BitSet(2);
-    bs_.set(1);
-  }
-  public RecInt(
-        int m0) {
-    bs_ = new java.util.BitSet(2);
-    bs_.set(1);
-    mData=m0; bs_.set(0);
-  }
-  public int getData() {
-    return mData;
-  }
-  public void setData(int m_) {
-    mData=m_; bs_.set(0);
-  }
-  public void serialize(org.apache.hadoop.record.OutputArchive a_, String tag) throws java.io.IOException {
-    if (!validate()) throw new java.io.IOException("All fields not set:");
-    a_.startRecord(this,tag);
-    a_.writeInt(mData,"Data");
-    bs_.clear(0);
-    a_.endRecord(this,tag);
-  }
-  public void deserialize(org.apache.hadoop.record.InputArchive a_, String tag) throws java.io.IOException {
-    a_.startRecord(tag);
-    mData=a_.readInt("Data");
-    bs_.set(0);
-    a_.endRecord(tag);
-}
-  public String toString() {
-    try {
-      java.io.ByteArrayOutputStream s =
-        new java.io.ByteArrayOutputStream();
-      org.apache.hadoop.record.CsvOutputArchive a_ = 
-        new org.apache.hadoop.record.CsvOutputArchive(s);
-      a_.startRecord(this,"");
-    a_.writeInt(mData,"Data");
-      a_.endRecord(this,"");
-      return new String(s.toByteArray(), "UTF-8");
-    } catch (Throwable ex) {
-      ex.printStackTrace();
-    }
-    return "ERROR";
-  }
-  public void write(java.io.DataOutput out) throws java.io.IOException {
-    org.apache.hadoop.record.BinaryOutputArchive archive = new org.apache.hadoop.record.BinaryOutputArchive(out);
-    serialize(archive, "");
-  }
-  public void readFields(java.io.DataInput in) throws java.io.IOException {
-    org.apache.hadoop.record.BinaryInputArchive archive = new org.apache.hadoop.record.BinaryInputArchive(in);
-    deserialize(archive, "");
-  }
-  public boolean validate() {
-    if (bs_.cardinality() != bs_.length()) return false;
-    return true;
-}
-  public int compareTo (Object peer_) throws ClassCastException {
-    if (!(peer_ instanceof RecInt)) {
-      throw new ClassCastException("Comparing different types of records.");
-    }
-    RecInt peer = (RecInt) peer_;
-    int ret = 0;
-    ret = (mData == peer.mData)? 0 :((mData<peer.mData)?-1:1);
-    if (ret != 0) return ret;
-     return ret;
-  }
-  public boolean equals(Object peer_) {
-    if (!(peer_ instanceof RecInt)) {
-      return false;
-    }
-    if (peer_ == this) {
-      return true;
-    }
-    RecInt peer = (RecInt) peer_;
-    boolean ret = false;
-    ret = (mData==peer.mData);
-    if (!ret) return ret;
-     return ret;
-  }
-  public int hashCode() {
-    int result = 17;
-    int ret;
-    ret = (int)mData;
-    result = 37*result + ret;
-    return result;
-  }
-  public static String signature() {
-    return "LRecInt(i)";
-  }
-  public static class Comparator extends WritableComparator {
-    public Comparator() {
-      super(RecInt.class);
-    }
-    static public int slurpRaw(byte[] b, int s, int l) {
-      try {
-        int os = s;
-        {
-           int i = WritableComparator.readVInt(b, s);
-           int z = WritableUtils.getVIntSize(i);
-           s+=z; l-=z;
-        }
-        return (os - s);
-      } catch(IOException e) {
-        LOG.warn(e);
-        throw new RuntimeException(e);
-      }
-    }
-    static public int compareRaw(byte[] b1, int s1, int l1,
-                       byte[] b2, int s2, int l2) {
-      try {
-        int os1 = s1;
-        {
-           int i1 = WritableComparator.readVInt(b1, s1);
-           int i2 = WritableComparator.readVInt(b2, s2);
-           if (i1 != i2) {
-             return ((i1-i2) < 0) ? -1 : 0;
-           }
-           int z1 = WritableUtils.getVIntSize(i1);
-           int z2 = WritableUtils.getVIntSize(i2);
-           s1+=z1; s2+=z2; l1-=z1; l2-=z2;
-        }
-        return (os1 - s1);
-      } catch(IOException e) {
-        LOG.warn(e);
-        throw new RuntimeException(e);
-      }
-    }
-    public int compare(byte[] b1, int s1, int l1,
-                       byte[] b2, int s2, int l2) {
-      int ret = compareRaw(b1,s1,l1,b2,s2,l2);
-      return (ret == -1)? -1 : ((ret==0)? 1 : 0);    }
-  }
-
-  static {
-    WritableComparator.define(RecInt.class, new Comparator());
-  }
-}

+ 0 - 152
src/test/org/apache/hadoop/record/test/RecRecord0.java

@@ -1,152 +0,0 @@
-// File generated by hadoop record compiler. Do not edit.
-package org.apache.hadoop.record.test;
-
-import java.io.IOException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.io.WritableComparator;
-import org.apache.hadoop.io.WritableComparable;
-import org.apache.hadoop.io.WritableUtils;
-import org.apache.hadoop.io.Text;
-
-public class RecRecord0 implements org.apache.hadoop.record.Record, WritableComparable {
-  private static final Log LOG= LogFactory.getLog("org.apache.hadoop.record.test.RecRecord0");
-  private Text mStringVal;
-  private java.util.BitSet bs_;
-  public RecRecord0() {
-    bs_ = new java.util.BitSet(2);
-    bs_.set(1);
-  }
-  public RecRecord0(
-        Text m0) {
-    bs_ = new java.util.BitSet(2);
-    bs_.set(1);
-    mStringVal=m0; bs_.set(0);
-  }
-  public Text getStringVal() {
-    return mStringVal;
-  }
-  public void setStringVal(Text m_) {
-    mStringVal=m_; bs_.set(0);
-  }
-  public void serialize(org.apache.hadoop.record.OutputArchive a_, String tag) throws java.io.IOException {
-    if (!validate()) throw new java.io.IOException("All fields not set:");
-    a_.startRecord(this,tag);
-    a_.writeString(mStringVal,"StringVal");
-    bs_.clear(0);
-    a_.endRecord(this,tag);
-  }
-  public void deserialize(org.apache.hadoop.record.InputArchive a_, String tag) throws java.io.IOException {
-    a_.startRecord(tag);
-    mStringVal=a_.readString("StringVal");
-    bs_.set(0);
-    a_.endRecord(tag);
-}
-  public String toString() {
-    try {
-      java.io.ByteArrayOutputStream s =
-        new java.io.ByteArrayOutputStream();
-      org.apache.hadoop.record.CsvOutputArchive a_ = 
-        new org.apache.hadoop.record.CsvOutputArchive(s);
-      a_.startRecord(this,"");
-    a_.writeString(mStringVal,"StringVal");
-      a_.endRecord(this,"");
-      return new String(s.toByteArray(), "UTF-8");
-    } catch (Throwable ex) {
-      ex.printStackTrace();
-    }
-    return "ERROR";
-  }
-  public void write(java.io.DataOutput out) throws java.io.IOException {
-    org.apache.hadoop.record.BinaryOutputArchive archive = new org.apache.hadoop.record.BinaryOutputArchive(out);
-    serialize(archive, "");
-  }
-  public void readFields(java.io.DataInput in) throws java.io.IOException {
-    org.apache.hadoop.record.BinaryInputArchive archive = new org.apache.hadoop.record.BinaryInputArchive(in);
-    deserialize(archive, "");
-  }
-  public boolean validate() {
-    if (bs_.cardinality() != bs_.length()) return false;
-    return true;
-}
-  public int compareTo (Object peer_) throws ClassCastException {
-    if (!(peer_ instanceof RecRecord0)) {
-      throw new ClassCastException("Comparing different types of records.");
-    }
-    RecRecord0 peer = (RecRecord0) peer_;
-    int ret = 0;
-    ret = mStringVal.compareTo(peer.mStringVal);
-    if (ret != 0) return ret;
-     return ret;
-  }
-  public boolean equals(Object peer_) {
-    if (!(peer_ instanceof RecRecord0)) {
-      return false;
-    }
-    if (peer_ == this) {
-      return true;
-    }
-    RecRecord0 peer = (RecRecord0) peer_;
-    boolean ret = false;
-    ret = mStringVal.equals(peer.mStringVal);
-    if (!ret) return ret;
-     return ret;
-  }
-  public int hashCode() {
-    int result = 17;
-    int ret;
-    ret = mStringVal.hashCode();
-    result = 37*result + ret;
-    return result;
-  }
-  public static String signature() {
-    return "LRecRecord0(s)";
-  }
-  public static class Comparator extends WritableComparator {
-    public Comparator() {
-      super(RecRecord0.class);
-    }
-    static public int slurpRaw(byte[] b, int s, int l) {
-      try {
-        int os = s;
-        {
-           int i = WritableComparator.readVInt(b, s);
-           int z = WritableUtils.getVIntSize(i);
-           s+=(z+i); l-= (z+i);
-        }
-        return (os - s);
-      } catch(IOException e) {
-        LOG.warn(e);
-        throw new RuntimeException(e);
-      }
-    }
-    static public int compareRaw(byte[] b1, int s1, int l1,
-                       byte[] b2, int s2, int l2) {
-      try {
-        int os1 = s1;
-        {
-           int i1 = WritableComparator.readVInt(b1, s1);
-           int i2 = WritableComparator.readVInt(b2, s2);
-           int z1 = WritableUtils.getVIntSize(i1);
-           int z2 = WritableUtils.getVIntSize(i2);
-           s1+=z1; s2+=z2; l1-=z1; l2-=z2;
-           int r1 = WritableComparator.compareBytes(b1,s1,l1,b2,s2,l2);
-           if (r1 != 0) { return (r1<0)?-1:0; }
-           s1+=i1; s2+=i2; l1-=i1; l1-=i2;
-        }
-        return (os1 - s1);
-      } catch(IOException e) {
-        LOG.warn(e);
-        throw new RuntimeException(e);
-      }
-    }
-    public int compare(byte[] b1, int s1, int l1,
-                       byte[] b2, int s2, int l2) {
-      int ret = compareRaw(b1,s1,l1,b2,s2,l2);
-      return (ret == -1)? -1 : ((ret==0)? 1 : 0);    }
-  }
-
-  static {
-    WritableComparator.define(RecRecord0.class, new Comparator());
-  }
-}

+ 0 - 629
src/test/org/apache/hadoop/record/test/RecRecord1.java

@@ -1,629 +0,0 @@
-// File generated by hadoop record compiler. Do not edit.
-package org.apache.hadoop.record.test;
-
-import java.io.IOException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.io.WritableComparator;
-import org.apache.hadoop.io.WritableComparable;
-import org.apache.hadoop.io.WritableUtils;
-import org.apache.hadoop.io.Text;
-
-public class RecRecord1 implements org.apache.hadoop.record.Record, WritableComparable {
-  private static final Log LOG= LogFactory.getLog("org.apache.hadoop.record.test.RecRecord1");
-  private boolean mBoolVal;
-  private byte mByteVal;
-  private int mIntVal;
-  private long mLongVal;
-  private float mFloatVal;
-  private double mDoubleVal;
-  private Text mStringVal;
-  private java.io.ByteArrayOutputStream mBufferVal;
-  private java.util.ArrayList mVectorVal;
-  private java.util.TreeMap mMapVal;
-  private org.apache.hadoop.record.test.RecRecord0 mRecordVal;
-  private java.util.BitSet bs_;
-  public RecRecord1() {
-    bs_ = new java.util.BitSet(12);
-    bs_.set(11);
-  }
-  public RecRecord1(
-        boolean m0,
-        byte m1,
-        int m2,
-        long m3,
-        float m4,
-        double m5,
-        Text m6,
-        java.io.ByteArrayOutputStream m7,
-        java.util.ArrayList m8,
-        java.util.TreeMap m9,
-        org.apache.hadoop.record.test.RecRecord0 m10) {
-    bs_ = new java.util.BitSet(12);
-    bs_.set(11);
-    mBoolVal=m0; bs_.set(0);
-    mByteVal=m1; bs_.set(1);
-    mIntVal=m2; bs_.set(2);
-    mLongVal=m3; bs_.set(3);
-    mFloatVal=m4; bs_.set(4);
-    mDoubleVal=m5; bs_.set(5);
-    mStringVal=m6; bs_.set(6);
-    mBufferVal=m7; bs_.set(7);
-    mVectorVal=m8; bs_.set(8);
-    mMapVal=m9; bs_.set(9);
-    mRecordVal=m10; bs_.set(10);
-  }
-  public boolean getBoolVal() {
-    return mBoolVal;
-  }
-  public void setBoolVal(boolean m_) {
-    mBoolVal=m_; bs_.set(0);
-  }
-  public byte getByteVal() {
-    return mByteVal;
-  }
-  public void setByteVal(byte m_) {
-    mByteVal=m_; bs_.set(1);
-  }
-  public int getIntVal() {
-    return mIntVal;
-  }
-  public void setIntVal(int m_) {
-    mIntVal=m_; bs_.set(2);
-  }
-  public long getLongVal() {
-    return mLongVal;
-  }
-  public void setLongVal(long m_) {
-    mLongVal=m_; bs_.set(3);
-  }
-  public float getFloatVal() {
-    return mFloatVal;
-  }
-  public void setFloatVal(float m_) {
-    mFloatVal=m_; bs_.set(4);
-  }
-  public double getDoubleVal() {
-    return mDoubleVal;
-  }
-  public void setDoubleVal(double m_) {
-    mDoubleVal=m_; bs_.set(5);
-  }
-  public Text getStringVal() {
-    return mStringVal;
-  }
-  public void setStringVal(Text m_) {
-    mStringVal=m_; bs_.set(6);
-  }
-  public java.io.ByteArrayOutputStream getBufferVal() {
-    return mBufferVal;
-  }
-  public void setBufferVal(java.io.ByteArrayOutputStream m_) {
-    mBufferVal=m_; bs_.set(7);
-  }
-  public java.util.ArrayList getVectorVal() {
-    return mVectorVal;
-  }
-  public void setVectorVal(java.util.ArrayList m_) {
-    mVectorVal=m_; bs_.set(8);
-  }
-  public java.util.TreeMap getMapVal() {
-    return mMapVal;
-  }
-  public void setMapVal(java.util.TreeMap m_) {
-    mMapVal=m_; bs_.set(9);
-  }
-  public org.apache.hadoop.record.test.RecRecord0 getRecordVal() {
-    return mRecordVal;
-  }
-  public void setRecordVal(org.apache.hadoop.record.test.RecRecord0 m_) {
-    mRecordVal=m_; bs_.set(10);
-  }
-  public void serialize(org.apache.hadoop.record.OutputArchive a_, String tag) throws java.io.IOException {
-    if (!validate()) throw new java.io.IOException("All fields not set:");
-    a_.startRecord(this,tag);
-    a_.writeBool(mBoolVal,"BoolVal");
-    bs_.clear(0);
-    a_.writeByte(mByteVal,"ByteVal");
-    bs_.clear(1);
-    a_.writeInt(mIntVal,"IntVal");
-    bs_.clear(2);
-    a_.writeLong(mLongVal,"LongVal");
-    bs_.clear(3);
-    a_.writeFloat(mFloatVal,"FloatVal");
-    bs_.clear(4);
-    a_.writeDouble(mDoubleVal,"DoubleVal");
-    bs_.clear(5);
-    a_.writeString(mStringVal,"StringVal");
-    bs_.clear(6);
-    a_.writeBuffer(mBufferVal,"BufferVal");
-    bs_.clear(7);
-    {
-      a_.startVector(mVectorVal,"VectorVal");
-      int len1 = mVectorVal.size();
-      for(int vidx1 = 0; vidx1<len1; vidx1++) {
-        Text e1 = (Text) mVectorVal.get(vidx1);
-        a_.writeString(e1,"e1");
-      }
-      a_.endVector(mVectorVal,"VectorVal");
-    }
-    bs_.clear(8);
-    {
-      a_.startMap(mMapVal,"MapVal");
-      java.util.Set es1 = mMapVal.entrySet();
-      for(java.util.Iterator midx1 = es1.iterator(); midx1.hasNext(); ) {
-        java.util.Map.Entry me1 = (java.util.Map.Entry) midx1.next();
-        Text k1 = (Text) me1.getKey();
-        Text v1 = (Text) me1.getValue();
-        a_.writeString(k1,"k1");
-        a_.writeString(v1,"v1");
-      }
-      a_.endMap(mMapVal,"MapVal");
-    }
-    bs_.clear(9);
-    a_.writeRecord(mRecordVal,"RecordVal");
-    bs_.clear(10);
-    a_.endRecord(this,tag);
-  }
-  public void deserialize(org.apache.hadoop.record.InputArchive a_, String tag) throws java.io.IOException {
-    a_.startRecord(tag);
-    mBoolVal=a_.readBool("BoolVal");
-    bs_.set(0);
-    mByteVal=a_.readByte("ByteVal");
-    bs_.set(1);
-    mIntVal=a_.readInt("IntVal");
-    bs_.set(2);
-    mLongVal=a_.readLong("LongVal");
-    bs_.set(3);
-    mFloatVal=a_.readFloat("FloatVal");
-    bs_.set(4);
-    mDoubleVal=a_.readDouble("DoubleVal");
-    bs_.set(5);
-    mStringVal=a_.readString("StringVal");
-    bs_.set(6);
-    mBufferVal=a_.readBuffer("BufferVal");
-    bs_.set(7);
-    {
-      org.apache.hadoop.record.Index vidx1 = a_.startVector("VectorVal");
-      mVectorVal=new java.util.ArrayList();
-      for (; !vidx1.done(); vidx1.incr()) {
-    Text e1;
-        e1=a_.readString("e1");
-        mVectorVal.add(e1);
-      }
-    a_.endVector("VectorVal");
-    }
-    bs_.set(8);
-    {
-      org.apache.hadoop.record.Index midx1 = a_.startMap("MapVal");
-      mMapVal=new java.util.TreeMap();
-      for (; !midx1.done(); midx1.incr()) {
-    Text k1;
-        k1=a_.readString("k1");
-    Text v1;
-        v1=a_.readString("v1");
-        mMapVal.put(k1,v1);
-      }
-    a_.endMap("MapVal");
-    }
-    bs_.set(9);
-    mRecordVal= new org.apache.hadoop.record.test.RecRecord0();
-    a_.readRecord(mRecordVal,"RecordVal");
-    bs_.set(10);
-    a_.endRecord(tag);
-}
-  public String toString() {
-    try {
-      java.io.ByteArrayOutputStream s =
-        new java.io.ByteArrayOutputStream();
-      org.apache.hadoop.record.CsvOutputArchive a_ = 
-        new org.apache.hadoop.record.CsvOutputArchive(s);
-      a_.startRecord(this,"");
-    a_.writeBool(mBoolVal,"BoolVal");
-    a_.writeByte(mByteVal,"ByteVal");
-    a_.writeInt(mIntVal,"IntVal");
-    a_.writeLong(mLongVal,"LongVal");
-    a_.writeFloat(mFloatVal,"FloatVal");
-    a_.writeDouble(mDoubleVal,"DoubleVal");
-    a_.writeString(mStringVal,"StringVal");
-    a_.writeBuffer(mBufferVal,"BufferVal");
-    {
-      a_.startVector(mVectorVal,"VectorVal");
-      int len1 = mVectorVal.size();
-      for(int vidx1 = 0; vidx1<len1; vidx1++) {
-        Text e1 = (Text) mVectorVal.get(vidx1);
-        a_.writeString(e1,"e1");
-      }
-      a_.endVector(mVectorVal,"VectorVal");
-    }
-    {
-      a_.startMap(mMapVal,"MapVal");
-      java.util.Set es1 = mMapVal.entrySet();
-      for(java.util.Iterator midx1 = es1.iterator(); midx1.hasNext(); ) {
-        java.util.Map.Entry me1 = (java.util.Map.Entry) midx1.next();
-        Text k1 = (Text) me1.getKey();
-        Text v1 = (Text) me1.getValue();
-        a_.writeString(k1,"k1");
-        a_.writeString(v1,"v1");
-      }
-      a_.endMap(mMapVal,"MapVal");
-    }
-    a_.writeRecord(mRecordVal,"RecordVal");
-      a_.endRecord(this,"");
-      return new String(s.toByteArray(), "UTF-8");
-    } catch (Throwable ex) {
-      ex.printStackTrace();
-    }
-    return "ERROR";
-  }
-  public void write(java.io.DataOutput out) throws java.io.IOException {
-    org.apache.hadoop.record.BinaryOutputArchive archive = new org.apache.hadoop.record.BinaryOutputArchive(out);
-    serialize(archive, "");
-  }
-  public void readFields(java.io.DataInput in) throws java.io.IOException {
-    org.apache.hadoop.record.BinaryInputArchive archive = new org.apache.hadoop.record.BinaryInputArchive(in);
-    deserialize(archive, "");
-  }
-  public boolean validate() {
-    if (bs_.cardinality() != bs_.length()) return false;
-    if (!mRecordVal.validate()) return false;
-    return true;
-}
-  public int compareTo (Object peer_) throws ClassCastException {
-    if (!(peer_ instanceof RecRecord1)) {
-      throw new ClassCastException("Comparing different types of records.");
-    }
-    RecRecord1 peer = (RecRecord1) peer_;
-    int ret = 0;
-    ret = (mBoolVal == peer.mBoolVal)? 0 : (mBoolVal?1:-1);
-    if (ret != 0) return ret;
-    ret = (mByteVal == peer.mByteVal)? 0 :((mByteVal<peer.mByteVal)?-1:1);
-    if (ret != 0) return ret;
-    ret = (mIntVal == peer.mIntVal)? 0 :((mIntVal<peer.mIntVal)?-1:1);
-    if (ret != 0) return ret;
-    ret = (mLongVal == peer.mLongVal)? 0 :((mLongVal<peer.mLongVal)?-1:1);
-    if (ret != 0) return ret;
-    ret = (mFloatVal == peer.mFloatVal)? 0 :((mFloatVal<peer.mFloatVal)?-1:1);
-    if (ret != 0) return ret;
-    ret = (mDoubleVal == peer.mDoubleVal)? 0 :((mDoubleVal<peer.mDoubleVal)?-1:1);
-    if (ret != 0) return ret;
-    ret = mStringVal.compareTo(peer.mStringVal);
-    if (ret != 0) return ret;
-    {
-      byte[] my = mBufferVal.toByteArray();
-      byte[] ur = peer.mBufferVal.toByteArray();
-      ret = WritableComparator.compareBytes(my,0,my.length,ur,0,ur.length);
-    }
-    if (ret != 0) return ret;
-    {
-      int len10 = mVectorVal.size();
-      int len20 = peer.mVectorVal.size();
-      for(int vidx0 = 0; vidx0<len10 && vidx0<len20; vidx0++) {
-        Text e10 = (Text) mVectorVal.get(vidx0);
-        Text e20 = (Text) peer.mVectorVal.get(vidx0);
-        ret = e10.compareTo(e20);
-         if (ret != 0) { return ret; }
-      }
-      ret = (len10 - len20);
-    }
-    if (ret != 0) return ret;
-    {
-      java.util.Set set10 = mMapVal.keySet();
-      java.util.Set set20 = peer.mMapVal.keySet();
-      java.util.Iterator miter10 = set10.iterator();
-      java.util.Iterator miter20 = set20.iterator();
-      for(; miter10.hasNext() && miter20.hasNext(); ) {
-        Text k10 = (Text) miter10.next();
-        Text k20 = (Text) miter20.next();
-        ret = k10.compareTo(k20);
-         if (ret != 0) { return ret; }
-      }
-      ret = (set10.size() - set20.size());
-    }
-    if (ret != 0) return ret;
-    ret = mRecordVal.compareTo(peer.mRecordVal);
-    if (ret != 0) return ret;
-     return ret;
-  }
-  public boolean equals(Object peer_) {
-    if (!(peer_ instanceof RecRecord1)) {
-      return false;
-    }
-    if (peer_ == this) {
-      return true;
-    }
-    RecRecord1 peer = (RecRecord1) peer_;
-    boolean ret = false;
-    ret = (mBoolVal==peer.mBoolVal);
-    if (!ret) return ret;
-    ret = (mByteVal==peer.mByteVal);
-    if (!ret) return ret;
-    ret = (mIntVal==peer.mIntVal);
-    if (!ret) return ret;
-    ret = (mLongVal==peer.mLongVal);
-    if (!ret) return ret;
-    ret = (mFloatVal==peer.mFloatVal);
-    if (!ret) return ret;
-    ret = (mDoubleVal==peer.mDoubleVal);
-    if (!ret) return ret;
-    ret = mStringVal.equals(peer.mStringVal);
-    if (!ret) return ret;
-    ret = org.apache.hadoop.record.Utils.bufEquals(mBufferVal,peer.mBufferVal);
-    if (!ret) return ret;
-    ret = mVectorVal.equals(peer.mVectorVal);
-    if (!ret) return ret;
-    ret = mMapVal.equals(peer.mMapVal);
-    if (!ret) return ret;
-    ret = mRecordVal.equals(peer.mRecordVal);
-    if (!ret) return ret;
-     return ret;
-  }
-  public int hashCode() {
-    int result = 17;
-    int ret;
-     ret = (mBoolVal)?0:1;
-    result = 37*result + ret;
-    ret = (int)mByteVal;
-    result = 37*result + ret;
-    ret = (int)mIntVal;
-    result = 37*result + ret;
-    ret = (int) (mLongVal^(mLongVal>>>32));
-    result = 37*result + ret;
-    ret = Float.floatToIntBits(mFloatVal);
-    result = 37*result + ret;
-    ret = (int)(Double.doubleToLongBits(mDoubleVal)^(Double.doubleToLongBits(mDoubleVal)>>>32));
-    result = 37*result + ret;
-    ret = mStringVal.hashCode();
-    result = 37*result + ret;
-    ret = mBufferVal.toString().hashCode();
-    result = 37*result + ret;
-    ret = mVectorVal.hashCode();
-    result = 37*result + ret;
-    ret = mMapVal.hashCode();
-    result = 37*result + ret;
-    ret = mRecordVal.hashCode();
-    result = 37*result + ret;
-    return result;
-  }
-  public static String signature() {
-    return "LRecRecord1(zbilfdsB[s]{ss}LRecRecord0(s))";
-  }
-  public static class Comparator extends WritableComparator {
-    public Comparator() {
-      super(RecRecord1.class);
-    }
-    static public int slurpRaw(byte[] b, int s, int l) {
-      try {
-        int os = s;
-        {
-           if (l<1) {
-             throw new IOException("Boolean is exactly 1 byte. Provided buffer is smaller.");
-           }
-           s++; l--;
-        }
-        {
-           if (l<1) {
-             throw new IOException("Byte is exactly 1 byte. Provided buffer is smaller.");
-           }
-           s++; l--;
-        }
-        {
-           int i = WritableComparator.readVInt(b, s);
-           int z = WritableUtils.getVIntSize(i);
-           s+=z; l-=z;
-        }
-        {
-           long i = WritableComparator.readVLong(b, s);
-           int z = WritableUtils.getVIntSize(i);
-           s+=z; l-=z;
-        }
-        {
-           if (l<4) {
-             throw new IOException("Float is exactly 4 bytes. Provided buffer is smaller.");
-           }
-           s+=4; l-=4;
-        }
-        {
-           if (l<8) {
-             throw new IOException("Double is exactly 8 bytes. Provided buffer is smaller.");
-           }
-           s+=8; l-=8;
-        }
-        {
-           int i = WritableComparator.readVInt(b, s);
-           int z = WritableUtils.getVIntSize(i);
-           s+=(z+i); l-= (z+i);
-        }
-        {
-           int i = WritableComparator.readVInt(b, s);
-           int z = WritableUtils.getVIntSize(i);
-           s += z+i; l -= (z+i);
-        }
-        {
-           int vi1 = WritableComparator.readVInt(b, s);
-           int vz1 = WritableUtils.getVIntSize(vi1);
-           s+=vz1; l-=vz1;
-           for (int vidx1 = 0; vidx1 < vi1; vidx1++)        {
-           int i = WritableComparator.readVInt(b, s);
-           int z = WritableUtils.getVIntSize(i);
-           s+=(z+i); l-= (z+i);
-        }
-        }
-        {
-           int mi1 = WritableComparator.readVInt(b, s);
-           int mz1 = WritableUtils.getVIntSize(mi1);
-           s+=mz1; l-=mz1;
-           for (int midx1 = 0; midx1 < mi1; midx1++) {        {
-           int i = WritableComparator.readVInt(b, s);
-           int z = WritableUtils.getVIntSize(i);
-           s+=(z+i); l-= (z+i);
-        }
-        {
-           int i = WritableComparator.readVInt(b, s);
-           int z = WritableUtils.getVIntSize(i);
-           s+=(z+i); l-= (z+i);
-        }
-           }
-        }
-        {
-           int r = org.apache.hadoop.record.test.RecRecord0.Comparator.slurpRaw(b,s,l);
-           s+=r; l-=r;
-        }
-        return (os - s);
-      } catch(IOException e) {
-        LOG.warn(e);
-        throw new RuntimeException(e);
-      }
-    }
-    static public int compareRaw(byte[] b1, int s1, int l1,
-                       byte[] b2, int s2, int l2) {
-      try {
-        int os1 = s1;
-        {
-           if (l1<1 || l2<1) {
-             throw new IOException("Boolean is exactly 1 byte. Provided buffer is smaller.");
-           }
-           if (b1[s1] != b2[s2]) {
-             return (b1[s1]<b2[s2])? -1 : 0;
-           }
-           s1++; s2++; l1--; l2--;
-        }
-        {
-           if (l1<1 || l2<1) {
-             throw new IOException("Byte is exactly 1 byte. Provided buffer is smaller.");
-           }
-           if (b1[s1] != b2[s2]) {
-             return (b1[s1]<b2[s2])?-1:0;
-           }
-           s1++; s2++; l1--; l2--;
-        }
-        {
-           int i1 = WritableComparator.readVInt(b1, s1);
-           int i2 = WritableComparator.readVInt(b2, s2);
-           if (i1 != i2) {
-             return ((i1-i2) < 0) ? -1 : 0;
-           }
-           int z1 = WritableUtils.getVIntSize(i1);
-           int z2 = WritableUtils.getVIntSize(i2);
-           s1+=z1; s2+=z2; l1-=z1; l2-=z2;
-        }
-        {
-           long i1 = WritableComparator.readVLong(b1, s1);
-           long i2 = WritableComparator.readVLong(b2, s2);
-           if (i1 != i2) {
-             return ((i1-i2) < 0) ? -1 : 0;
-           }
-           int z1 = WritableUtils.getVIntSize(i1);
-           int z2 = WritableUtils.getVIntSize(i2);
-           s1+=z1; s2+=z2; l1-=z1; l2-=z2;
-        }
-        {
-           if (l1<4 || l2<4) {
-             throw new IOException("Float is exactly 4 bytes. Provided buffer is smaller.");
-           }
-           float f1 = WritableComparator.readFloat(b1, s1);
-           float f2 = WritableComparator.readFloat(b2, s2);
-           if (f1 != f2) {
-             return ((f1-f2) < 0) ? -1 : 0;
-           }
-           s1+=4; s2+=4; l1-=4; l2-=4;
-        }
-        {
-           if (l1<8 || l2<8) {
-             throw new IOException("Double is exactly 8 bytes. Provided buffer is smaller.");
-           }
-           double d1 = WritableComparator.readDouble(b1, s1);
-           double d2 = WritableComparator.readDouble(b2, s2);
-           if (d1 != d2) {
-             return ((d1-d2) < 0) ? -1 : 0;
-           }
-           s1+=8; s2+=8; l1-=8; l2-=8;
-        }
-        {
-           int i1 = WritableComparator.readVInt(b1, s1);
-           int i2 = WritableComparator.readVInt(b2, s2);
-           int z1 = WritableUtils.getVIntSize(i1);
-           int z2 = WritableUtils.getVIntSize(i2);
-           s1+=z1; s2+=z2; l1-=z1; l2-=z2;
-           int r1 = WritableComparator.compareBytes(b1,s1,l1,b2,s2,l2);
-           if (r1 != 0) { return (r1<0)?-1:0; }
-           s1+=i1; s2+=i2; l1-=i1; l1-=i2;
-        }
-        {
-           int i1 = WritableComparator.readVInt(b1, s1);
-           int i2 = WritableComparator.readVInt(b2, s2);
-           int z1 = WritableUtils.getVIntSize(i1);
-           int z2 = WritableUtils.getVIntSize(i2);
-           s1+=z1; s2+=z2; l1-=z1; l2-=z2;
-           int r1 = WritableComparator.compareBytes(b1,s1,l1,b2,s2,l2);
-           if (r1 != 0) { return (r1<0)?-1:0; }
-           s1+=i1; s2+=i2; l1-=i1; l1-=i2;
-        }
-        {
-           int vi11 = WritableComparator.readVInt(b1, s1);
-           int vi21 = WritableComparator.readVInt(b2, s2);
-           int vz11 = WritableUtils.getVIntSize(vi11);
-           int vz21 = WritableUtils.getVIntSize(vi21);
-           s1+=vz11; s2+=vz21; l1-=vz11; l2-=vz21;
-           for (int vidx1 = 0; vidx1 < vi11 && vidx1 < vi21; vidx1++)        {
-           int i1 = WritableComparator.readVInt(b1, s1);
-           int i2 = WritableComparator.readVInt(b2, s2);
-           int z1 = WritableUtils.getVIntSize(i1);
-           int z2 = WritableUtils.getVIntSize(i2);
-           s1+=z1; s2+=z2; l1-=z1; l2-=z2;
-           int r1 = WritableComparator.compareBytes(b1,s1,l1,b2,s2,l2);
-           if (r1 != 0) { return (r1<0)?-1:0; }
-           s1+=i1; s2+=i2; l1-=i1; l1-=i2;
-        }
-           if (vi11 != vi21) { return (vi11<vi21)?-1:0; }
-        }
-        {
-           int mi11 = WritableComparator.readVInt(b1, s1);
-           int mi21 = WritableComparator.readVInt(b2, s2);
-           int mz11 = WritableUtils.getVIntSize(mi11);
-           int mz21 = WritableUtils.getVIntSize(mi21);
-           s1+=mz11; s2+=mz21; l1-=mz11; l2-=mz21;
-           for (int midx1 = 0; midx1 < mi11 && midx1 < mi21; midx1++) {        {
-           int i1 = WritableComparator.readVInt(b1, s1);
-           int i2 = WritableComparator.readVInt(b2, s2);
-           int z1 = WritableUtils.getVIntSize(i1);
-           int z2 = WritableUtils.getVIntSize(i2);
-           s1+=z1; s2+=z2; l1-=z1; l2-=z2;
-           int r1 = WritableComparator.compareBytes(b1,s1,l1,b2,s2,l2);
-           if (r1 != 0) { return (r1<0)?-1:0; }
-           s1+=i1; s2+=i2; l1-=i1; l1-=i2;
-        }
-        {
-           int i = WritableComparator.readVInt(b1, s1);
-           int z = WritableUtils.getVIntSize(i);
-           s1+=(z+i); l1-= (z+i);
-        }
-        {
-           int i = WritableComparator.readVInt(b2, s2);
-           int z = WritableUtils.getVIntSize(i);
-           s2+=(z+i); l2-= (z+i);
-        }
-           }
-           if (mi11 != mi21) { return (mi11<mi21)?-1:0; }
-        }
-        {
-           int r1 = org.apache.hadoop.record.test.RecRecord0.Comparator.compareRaw(b1,s1,l1,b2,s2,l2);
-           if (r1 <= 0) { return r1; }
-           s1+=r1; s2+=r1; l1-=r1; l2-=r1;
-        }
-        return (os1 - s1);
-      } catch(IOException e) {
-        LOG.warn(e);
-        throw new RuntimeException(e);
-      }
-    }
-    public int compare(byte[] b1, int s1, int l1,
-                       byte[] b2, int s2, int l2) {
-      int ret = compareRaw(b1,s1,l1,b2,s2,l2);
-      return (ret == -1)? -1 : ((ret==0)? 1 : 0);    }
-  }
-
-  static {
-    WritableComparator.define(RecRecord1.class, new Comparator());
-  }
-}

+ 0 - 152
src/test/org/apache/hadoop/record/test/RecString.java

@@ -1,152 +0,0 @@
-// File generated by hadoop record compiler. Do not edit.
-package org.apache.hadoop.record.test;
-
-import java.io.IOException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.io.WritableComparator;
-import org.apache.hadoop.io.WritableComparable;
-import org.apache.hadoop.io.WritableUtils;
-import org.apache.hadoop.io.Text;
-
-public class RecString implements org.apache.hadoop.record.Record, WritableComparable {
-  private static final Log LOG= LogFactory.getLog("org.apache.hadoop.record.test.RecString");
-  private Text mData;
-  private java.util.BitSet bs_;
-  public RecString() {
-    bs_ = new java.util.BitSet(2);
-    bs_.set(1);
-  }
-  public RecString(
-        Text m0) {
-    bs_ = new java.util.BitSet(2);
-    bs_.set(1);
-    mData=m0; bs_.set(0);
-  }
-  public Text getData() {
-    return mData;
-  }
-  public void setData(Text m_) {
-    mData=m_; bs_.set(0);
-  }
-  public void serialize(org.apache.hadoop.record.OutputArchive a_, String tag) throws java.io.IOException {
-    if (!validate()) throw new java.io.IOException("All fields not set:");
-    a_.startRecord(this,tag);
-    a_.writeString(mData,"Data");
-    bs_.clear(0);
-    a_.endRecord(this,tag);
-  }
-  public void deserialize(org.apache.hadoop.record.InputArchive a_, String tag) throws java.io.IOException {
-    a_.startRecord(tag);
-    mData=a_.readString("Data");
-    bs_.set(0);
-    a_.endRecord(tag);
-}
-  public String toString() {
-    try {
-      java.io.ByteArrayOutputStream s =
-        new java.io.ByteArrayOutputStream();
-      org.apache.hadoop.record.CsvOutputArchive a_ = 
-        new org.apache.hadoop.record.CsvOutputArchive(s);
-      a_.startRecord(this,"");
-    a_.writeString(mData,"Data");
-      a_.endRecord(this,"");
-      return new String(s.toByteArray(), "UTF-8");
-    } catch (Throwable ex) {
-      ex.printStackTrace();
-    }
-    return "ERROR";
-  }
-  public void write(java.io.DataOutput out) throws java.io.IOException {
-    org.apache.hadoop.record.BinaryOutputArchive archive = new org.apache.hadoop.record.BinaryOutputArchive(out);
-    serialize(archive, "");
-  }
-  public void readFields(java.io.DataInput in) throws java.io.IOException {
-    org.apache.hadoop.record.BinaryInputArchive archive = new org.apache.hadoop.record.BinaryInputArchive(in);
-    deserialize(archive, "");
-  }
-  public boolean validate() {
-    if (bs_.cardinality() != bs_.length()) return false;
-    return true;
-}
-  public int compareTo (Object peer_) throws ClassCastException {
-    if (!(peer_ instanceof RecString)) {
-      throw new ClassCastException("Comparing different types of records.");
-    }
-    RecString peer = (RecString) peer_;
-    int ret = 0;
-    ret = mData.compareTo(peer.mData);
-    if (ret != 0) return ret;
-     return ret;
-  }
-  public boolean equals(Object peer_) {
-    if (!(peer_ instanceof RecString)) {
-      return false;
-    }
-    if (peer_ == this) {
-      return true;
-    }
-    RecString peer = (RecString) peer_;
-    boolean ret = false;
-    ret = mData.equals(peer.mData);
-    if (!ret) return ret;
-     return ret;
-  }
-  public int hashCode() {
-    int result = 17;
-    int ret;
-    ret = mData.hashCode();
-    result = 37*result + ret;
-    return result;
-  }
-  public static String signature() {
-    return "LRecString(s)";
-  }
-  public static class Comparator extends WritableComparator {
-    public Comparator() {
-      super(RecString.class);
-    }
-    static public int slurpRaw(byte[] b, int s, int l) {
-      try {
-        int os = s;
-        {
-           int i = WritableComparator.readVInt(b, s);
-           int z = WritableUtils.getVIntSize(i);
-           s+=(z+i); l-= (z+i);
-        }
-        return (os - s);
-      } catch(IOException e) {
-        LOG.warn(e);
-        throw new RuntimeException(e);
-      }
-    }
-    static public int compareRaw(byte[] b1, int s1, int l1,
-                       byte[] b2, int s2, int l2) {
-      try {
-        int os1 = s1;
-        {
-           int i1 = WritableComparator.readVInt(b1, s1);
-           int i2 = WritableComparator.readVInt(b2, s2);
-           int z1 = WritableUtils.getVIntSize(i1);
-           int z2 = WritableUtils.getVIntSize(i2);
-           s1+=z1; s2+=z2; l1-=z1; l2-=z2;
-           int r1 = WritableComparator.compareBytes(b1,s1,l1,b2,s2,l2);
-           if (r1 != 0) { return (r1<0)?-1:0; }
-           s1+=i1; s2+=i2; l1-=i1; l1-=i2;
-        }
-        return (os1 - s1);
-      } catch(IOException e) {
-        LOG.warn(e);
-        throw new RuntimeException(e);
-      }
-    }
-    public int compare(byte[] b1, int s1, int l1,
-                       byte[] b2, int s2, int l2) {
-      int ret = compareRaw(b1,s1,l1,b2,s2,l2);
-      return (ret == -1)? -1 : ((ret==0)? 1 : 0);    }
-  }
-
-  static {
-    WritableComparator.define(RecString.class, new Comparator());
-  }
-}