hadoop-hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject svn commit: r764994 [10/12] - in /hadoop/hive/trunk: ./ data/conf/ eclipse-templates/ metastore/src/java/org/apache/hadoop/hive/metastore/ ql/ ql/lib/ ql/src/java/org/apache/hadoop/hive/ql/exec/ ql/src/java/org/apache/hadoop/hive/ql/io/ ql/src/java/org...
Date Tue, 14 Apr 2009 22:54:45 GMT
Added: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/io/DoubleWritable.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/io/DoubleWritable.java?rev=764994&view=auto
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/io/DoubleWritable.java (added)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/io/DoubleWritable.java Tue Apr 14 22:54:39 2009
@@ -0,0 +1,103 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+/**
+ * This file is back-ported from hadoop-0.19, to make sure hive can run 
+ * with hadoop-0.17.
+ */
+package org.apache.hadoop.hive.serde2.io;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.hadoop.io.WritableComparable;
+import org.apache.hadoop.io.WritableComparator;
+
+/**
+ * Writable for Double values.
+ */
+public class DoubleWritable implements WritableComparable {
+
+  private double value = 0.0;
+
+  public DoubleWritable() {
+
+  }
+
+  public DoubleWritable(double value) {
+    set(value);
+  }
+
+  public void readFields(DataInput in) throws IOException {
+    value = in.readDouble();
+  }
+
+  public void write(DataOutput out) throws IOException {
+    out.writeDouble(value);
+  }
+
+  public void set(double value) { this.value = value; }
+
+  public double get() { return value; }
+
+  /**
+   * Returns true iff <code>o</code> is a DoubleWritable with the same value.
+   */
+  public boolean equals(Object o) {
+    if (!(o instanceof DoubleWritable)) {
+      return false;
+    }
+    DoubleWritable other = (DoubleWritable)o;
+    return this.value == other.value;
+  }
+
+  public int hashCode() {
+    return (int)Double.doubleToLongBits(value);
+  }
+
+  public int compareTo(Object o) {
+    DoubleWritable other = (DoubleWritable)o;
+    return (value < other.value ? -1 : (value == other.value ? 0 : 1));
+  }
+
+  public String toString() {
+    return Double.toString(value);
+  }
+
+  /** A Comparator optimized for DoubleWritable. */
+  public static class Comparator extends WritableComparator {
+    public Comparator() {
+      super(DoubleWritable.class);
+    }
+
+    public int compare(byte[] b1, int s1, int l1,
+                       byte[] b2, int s2, int l2) {
+      double thisValue = readDouble(b1, s1);
+      double thatValue = readDouble(b2, s2);
+      return (thisValue < thatValue ? -1 : (thisValue == thatValue ? 0 : 1));
+    }
+  }
+
+  static {                                        // register this comparator
+    WritableComparator.define(DoubleWritable.class, new Comparator());
+  }
+
+}
+
+      

Added: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/io/ShortWritable.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/io/ShortWritable.java?rev=764994&view=auto
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/io/ShortWritable.java (added)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/io/ShortWritable.java Tue Apr 14 22:54:39 2009
@@ -0,0 +1,96 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.hive.serde2.io;
+
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.hadoop.io.WritableComparable;
+import org.apache.hadoop.io.WritableComparator;
+
+public class ShortWritable implements WritableComparable {
+  private short value;
+
+  public void write(DataOutput out) throws IOException {
+    out.writeShort(value);
+  }
+
+  public void readFields(DataInput in) throws IOException {
+    value = in.readShort();
+  }
+
+  public ShortWritable(short s) {
+    value = s;
+  }
+
+  public ShortWritable() {
+    value = 0;
+  }
+
+  public void set(short value) {
+    this.value = value;
+  }
+  
+  public short get() {
+    return value;
+  }
+  
+  public boolean equals(Object o) {
+    if (o == null || o.getClass() != ShortWritable.class) {
+      return false;
+    }
+    return get() == ((ShortWritable)o).get();
+  }
+
+  public int hashCode() {
+    return value;
+  }
+  
+  public String toString() {
+    return String.valueOf(get());
+  }
+  
+  public int compareTo(Object o) {
+    int thisValue = this.value;
+    int thatValue = ((ShortWritable) o).value;
+    return thisValue - thatValue;
+  }
+
+  /** A Comparator optimized for BytesWritable. */
+  public static class Comparator extends WritableComparator {
+    public Comparator() {
+      super(ShortWritable.class);
+    }
+
+    /**
+     * Compare the buffers in serialized form.
+     */
+    public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+      int a1 = (short)(readUnsignedShort(b1, s1));
+      int a2 = (short)(readUnsignedShort(b2, s2));
+      return a1 - a2;
+    }
+  }
+
+  static { // register this comparator
+    WritableComparator.define(ShortWritable.class, new Comparator());
+  }
+
+}

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyArray.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyArray.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyArray.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyArray.java Tue Apr 14 22:54:39 2009
@@ -21,6 +21,7 @@
 import java.util.Arrays;
 import java.util.List;
 
+import org.apache.hadoop.hive.serde2.typeinfo.ListTypeInfo;
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
 import org.apache.hadoop.io.Text;
 
@@ -173,7 +174,7 @@
         elementInited[index] = true;
         if (arrayElements[index] == null) {
           arrayElements[index] = LazyFactory.createLazyObject(
-            typeInfo.getListElementTypeInfo());
+            ((ListTypeInfo)typeInfo).getListElementTypeInfo());
         }
         arrayElements[index].init(bytes, startPosition[index], 
             elementLength);

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyByte.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyByte.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyByte.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyByte.java Tue Apr 14 22:54:39 2009
@@ -17,6 +17,8 @@
  */
 package org.apache.hadoop.hive.serde2.lazy;
 
+import org.apache.hadoop.hive.serde2.io.ByteWritable;
+
 /**
  * LazyObject for storing a value of Byte.
  * 
@@ -30,19 +32,19 @@
  * </p>
  * 
  */
-public class LazyByte extends LazyPrimitive<Byte> {
+public class LazyByte extends LazyPrimitive<ByteWritable> {
 
   public LazyByte() {
+    data = new ByteWritable();
   }
 
   @Override
   public void init(ByteArrayRef bytes, int start, int length) {
     try {
-      // Slower method: convert to String and then convert to Integer
-      // return Byte.valueOf(LazyUtils.convertToString(bytes, start, length));
-      data = Byte.valueOf(parseByte(bytes.getData(), start, length));
+      data.set(parseByte(bytes.getData(), start, length, 10));
+      isNull = false;
     } catch (NumberFormatException e) {
-      data = null;
+      isNull = true;
     }
   }
   

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyDouble.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyDouble.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyDouble.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyDouble.java Tue Apr 14 22:54:39 2009
@@ -19,22 +19,28 @@
 
 import java.nio.charset.CharacterCodingException;
 
+import org.apache.hadoop.hive.serde2.io.DoubleWritable;
 import org.apache.hadoop.io.Text;
 
 /**
  * LazyObject for storing a value of Double.
  * 
  */
-public class LazyDouble extends LazyPrimitive<Double> {
+public class LazyDouble extends LazyPrimitive<DoubleWritable> {
 
+  public LazyDouble() {
+    data = new DoubleWritable();
+  }
+  
   @Override
   public void init(ByteArrayRef bytes, int start, int length) {
     try {
-      data = Double.valueOf(Text.decode(bytes.getData(), start, length));
+      data.set(Double.parseDouble(Text.decode(bytes.getData(), start, length)));
+      isNull = false;
     } catch (NumberFormatException e) {
-      data = null;
+      isNull = true;
     } catch (CharacterCodingException e) {
-      data = null;
+      isNull = true;
     }
   }
 

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyFactory.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyFactory.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyFactory.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyFactory.java Tue Apr 14 22:54:39 2009
@@ -22,29 +22,48 @@
 
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory;
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
+import org.apache.hadoop.hive.serde2.typeinfo.ListTypeInfo;
+import org.apache.hadoop.hive.serde2.typeinfo.MapTypeInfo;
+import org.apache.hadoop.hive.serde2.typeinfo.StructTypeInfo;
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
+import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
 import org.apache.hadoop.io.Text;
 
 public class LazyFactory {
 
   /**
-   * Create a lazy primitive class given the java class. 
+   * Create a lazy primitive class given the type name. 
    */
-  public static LazyPrimitive<?> createLazyPrimitiveClass(Class<?> c) {
-    if (String.class.equals(c)) {
-      return new LazyString();
-    } else if (Integer.class.equals(c)) {
-      return new LazyInteger();
-    } else if (Double.class.equals(c)) {
-      return new LazyDouble();
-    } else if (Byte.class.equals(c)) {
-      return new LazyByte();
-    } else if (Short.class.equals(c)) {
-      return new LazyShort();
-    } else if (Long.class.equals(c)) {
-      return new LazyLong();
-    } else {
-      return null;
+  public static LazyPrimitive<?> createLazyPrimitiveClass(String typeName) {
+    PrimitiveCategory p = PrimitiveObjectInspectorUtils.getTypeEntryFromTypeName(typeName).primitiveCategory;
+    switch(p) {
+      case BYTE: {
+        return new LazyByte();
+      }
+      case SHORT: {
+        return new LazyShort();
+      }
+      case INT: {
+        return new LazyInteger();
+      }
+      case LONG: {
+        return new LazyLong();
+      }
+      case FLOAT: {
+        return new LazyFloat();
+      }
+      case DOUBLE: {
+        return new LazyDouble();
+      }
+      case STRING: {
+        return new LazyString();
+      }
+      default: {
+        throw new RuntimeException("Internal error: no LazyObject for " + p);
+      }
     }
   }
 
@@ -55,7 +74,7 @@
     ObjectInspector.Category c = typeInfo.getCategory();
     switch(c) {
     case PRIMITIVE:
-      return createLazyPrimitiveClass(typeInfo.getPrimitiveClass());
+      return createLazyPrimitiveClass(typeInfo.getTypeName());
     case MAP:
       return new LazyMap(typeInfo);      
     case LIST: 
@@ -84,22 +103,24 @@
     ObjectInspector.Category c = typeInfo.getCategory();
     switch(c) {
     case PRIMITIVE:
-      return ObjectInspectorFactory.getStandardPrimitiveObjectInspector(typeInfo.getPrimitiveClass());
+      return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
+          ((PrimitiveTypeInfo)typeInfo).getPrimitiveCategory());
     case MAP:
       return ObjectInspectorFactory.getLazySimpleMapObjectInspector(
-          createLazyObjectInspector(typeInfo.getMapKeyTypeInfo(), separator, separatorIndex+2, nullSequence), 
-          createLazyObjectInspector(typeInfo.getMapValueTypeInfo(), separator, separatorIndex+2, nullSequence), 
+          createLazyObjectInspector(((MapTypeInfo)typeInfo).getMapKeyTypeInfo(), separator, separatorIndex+2, nullSequence), 
+          createLazyObjectInspector(((MapTypeInfo)typeInfo).getMapValueTypeInfo(), separator, separatorIndex+2, nullSequence), 
           separator[separatorIndex], 
           separator[separatorIndex+1], 
           nullSequence);
     case LIST: 
       return ObjectInspectorFactory.getLazySimpleListObjectInspector(
-          createLazyObjectInspector(typeInfo.getListElementTypeInfo(), separator, separatorIndex+1, nullSequence),
+          createLazyObjectInspector(((ListTypeInfo)typeInfo).getListElementTypeInfo(), separator, separatorIndex+1, nullSequence),
           separator[separatorIndex], 
           nullSequence);
     case STRUCT:
-      List<String> fieldNames = typeInfo.getAllStructFieldNames();
-      List<TypeInfo> fieldTypeInfos = typeInfo.getAllStructFieldTypeInfos();
+      StructTypeInfo structTypeInfo = (StructTypeInfo)typeInfo;
+      List<String> fieldNames = structTypeInfo.getAllStructFieldNames();
+      List<TypeInfo> fieldTypeInfos = structTypeInfo.getAllStructFieldTypeInfos();
       List<ObjectInspector> fieldObjectInspectors = new ArrayList<ObjectInspector>(fieldTypeInfos.size());
       for(int i=0; i<fieldTypeInfos.size(); i++) {
         fieldObjectInspectors.add(

Added: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyFloat.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyFloat.java?rev=764994&view=auto
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyFloat.java (added)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyFloat.java Tue Apr 14 22:54:39 2009
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.hive.serde2.lazy;
+
+import java.nio.charset.CharacterCodingException;
+
+import org.apache.hadoop.io.FloatWritable;
+import org.apache.hadoop.io.Text;
+
+/**
+ * LazyObject for storing a value of Double.
+ * 
+ */
+public class LazyFloat extends LazyPrimitive<FloatWritable> {
+
+  public LazyFloat() {
+    data = new FloatWritable();
+  }
+  
+  
+  @Override
+  public void init(ByteArrayRef bytes, int start, int length) {
+    try {
+      data.set(Float.parseFloat(Text.decode(bytes.getData(), start, length)));
+      isNull = false;
+    } catch (NumberFormatException e) {
+      isNull = true;
+    } catch (CharacterCodingException e) {
+      isNull = true;
+    }
+  }
+
+}

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyInteger.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyInteger.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyInteger.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyInteger.java Tue Apr 14 22:54:39 2009
@@ -20,6 +20,8 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
+import org.apache.hadoop.io.IntWritable;
+
 /**
  * LazyObject for storing a value of Integer.
  * 
@@ -33,19 +35,19 @@
  * </p>
  * 
  */
-public class LazyInteger extends LazyPrimitive<Integer> {
+public class LazyInteger extends LazyPrimitive<IntWritable> {
 
   public LazyInteger() {
+    data = new IntWritable();
   }
 
   @Override
   public void init(ByteArrayRef bytes, int start, int length) {
     try {
-      // Slower method: convert to String and then convert to Integer
-      // return Integer.valueOf(LazyUtils.convertToString(bytes, start, length));
-      data = Integer.valueOf(parseInt(bytes.getData(), start, length));
+      data.set(parseInt(bytes.getData(), start, length, 10));
+      isNull = false;
     } catch (NumberFormatException e) {
-      data = null;
+      isNull = true;
     }
   }
   
@@ -189,4 +191,11 @@
     }
   }
   
+  public static void writeUTF8NoException(OutputStream out, int i) {
+    try {
+      writeUTF8(out, i);
+    } catch (IOException e) {
+      throw new RuntimeException(e);
+    }
+  }  
 }

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyLong.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyLong.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyLong.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyLong.java Tue Apr 14 22:54:39 2009
@@ -20,6 +20,8 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
+import org.apache.hadoop.io.LongWritable;
+
 /**
  * LazyObject for storing a value of Long.
  * 
@@ -33,19 +35,20 @@
  * </p>
  * 
  */
-public class LazyLong extends LazyPrimitive<Long> {
+public class LazyLong extends LazyPrimitive<LongWritable> {
+
 
   public LazyLong() {
+    data = new LongWritable();
   }
 
   @Override
   public void init(ByteArrayRef bytes, int start, int length) {
     try {
-      // Slower method: convert to String and then convert to Long
-      // return Long.valueOf(LazyUtils.convertToString(bytes, start, length));
-      data = Long.valueOf(parseLong(bytes.getData(), start, length));
+      data.set(parseLong(bytes.getData(), start, length, 10));
+      isNull = false;
     } catch (NumberFormatException e) {
-      data = null;
+      isNull = true;
     }
   }
 
@@ -188,5 +191,13 @@
       start /= 10;
     }
   }
-  
+
+  public static void writeUTF8NoException(OutputStream out, long i) {
+    try {
+      writeUTF8(out, i);
+    } catch (IOException e) {
+      throw new RuntimeException(e);
+    }
+  }
+
 }

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyMap.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyMap.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyMap.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyMap.java Tue Apr 14 22:54:39 2009
@@ -21,6 +21,7 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.hadoop.hive.serde2.typeinfo.MapTypeInfo;
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
 import org.apache.hadoop.io.Text;
 
@@ -237,7 +238,7 @@
       valueInited[index] = true;
       if (valueObjects[index] == null) {
         valueObjects[index] = LazyFactory.createLazyObject(
-            typeInfo.getMapValueTypeInfo());
+            ((MapTypeInfo)typeInfo).getMapValueTypeInfo());
       }
       valueObjects[index].init(bytes, valueIBegin, valueILength);
     }
@@ -263,7 +264,7 @@
       if (keyObjects[index] == null) {
         // Keys are always primitive
         keyObjects[index] = LazyFactory.createLazyPrimitiveClass(
-            typeInfo.getMapKeyTypeInfo().getPrimitiveClass());
+            ((MapTypeInfo)typeInfo).getMapKeyTypeInfo().getTypeName());
       }
       keyObjects[index].init(bytes, keyIBegin, keyILength);
     }

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyPrimitive.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyPrimitive.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyPrimitive.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyPrimitive.java Tue Apr 14 22:54:39 2009
@@ -24,12 +24,13 @@
 public abstract class LazyPrimitive<T> implements LazyObject {
 
   T data;
+  boolean isNull = false;
 
   /**
    * Returns the actual primitive object represented by this LazyObject.
    */
   public T getObject() {
-    return data;
+    return isNull ? null : data;
   }
 
 }

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyShort.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyShort.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyShort.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyShort.java Tue Apr 14 22:54:39 2009
@@ -17,6 +17,8 @@
  */
 package org.apache.hadoop.hive.serde2.lazy;
 
+import org.apache.hadoop.hive.serde2.io.ShortWritable;
+
 /**
  * LazyObject for storing a value of Short.
  * 
@@ -30,19 +32,19 @@
  * </p>
  * 
  */
-public class LazyShort extends LazyPrimitive<Short> {
+public class LazyShort extends LazyPrimitive<ShortWritable> {
 
   public LazyShort() {
+    data = new ShortWritable();
   }
   
   @Override
   public void init(ByteArrayRef bytes, int start, int length) {
     try {
-      // Slower method: convert to String and then convert to Integer
-      // return Short.valueOf(LazyUtils.convertToString(bytes, start, length));
-      data = Short.valueOf(parseShort(bytes.getData(), start, length));
+      data.set(parseShort(bytes.getData(), start, length));
+      isNull = false;
     } catch (NumberFormatException e) {
-      data = null;
+      isNull = true;
     }
   }
 

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazySimpleSerDe.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazySimpleSerDe.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazySimpleSerDe.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazySimpleSerDe.java Tue Apr 14 22:54:39 2009
@@ -36,11 +36,12 @@
 import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
-import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory;
 import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.StructField;
 import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector.Category;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
+import org.apache.hadoop.hive.serde2.typeinfo.StructTypeInfo;
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils;
@@ -76,8 +77,8 @@
 
   public String toString() {
     return getClass().toString() + "[" + Arrays.asList(separators) + ":" 
-        + rowTypeInfo.getAllStructFieldNames()
-        + ":" + rowTypeInfo.getAllStructFieldTypeInfos() + "]";
+        + ((StructTypeInfo)rowTypeInfo).getAllStructFieldNames()
+        + ":" + ((StructTypeInfo)rowTypeInfo).getAllStructFieldTypeInfos() + "]";
   }
 
   public LazySimpleSerDe() throws SerDeException {
@@ -232,8 +233,6 @@
   
   Text serializeCache = new Text();
   ByteStream.Output serializeStream = new ByteStream.Output();
-  ObjectInspector stringObjectInspector = 
-      ObjectInspectorFactory.getStandardPrimitiveObjectInspector(String.class);
   /**
    * Serialize a row of data.
    * @param obj          The row object
@@ -256,7 +255,7 @@
     List<? extends StructField> fields = soi.getAllStructFieldRefs();
     List<Object> list = soi.getStructFieldsDataAsList(obj);
     List<? extends StructField> declaredFields = 
-        (rowTypeInfo != null && rowTypeInfo.getAllStructFieldNames().size()>0)
+        (rowTypeInfo != null && ((StructTypeInfo)rowTypeInfo).getAllStructFieldNames().size()>0)
         ? ((StructObjectInspector)getObjectInspector()).getAllStructFieldRefs()
         : null;
         
@@ -292,7 +291,8 @@
                 declaredFields.get(i).getFieldObjectInspector().getCategory()
                 .equals(Category.PRIMITIVE))) {
           serialize(serializeStream, SerDeUtils.getJSONString(f, foi), 
-              stringObjectInspector, separators, 1, nullSequence);
+              PrimitiveObjectInspectorFactory.javaStringObjectInspector,
+              separators, 1, nullSequence);
         } else {
           serialize(serializeStream, f, foi, separators, 1, nullSequence);
         }
@@ -328,7 +328,7 @@
     
     switch (objInspector.getCategory()) {
       case PRIMITIVE: {
-        LazyUtils.writePrimitiveUTF8(out, obj);
+        LazyUtils.writePrimitiveUTF8(out, obj, (PrimitiveObjectInspector)objInspector);
         return;
       }
       case LIST: {

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyString.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyString.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyString.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyString.java Tue Apr 14 22:54:39 2009
@@ -17,27 +17,20 @@
  */
 package org.apache.hadoop.hive.serde2.lazy;
 
-import java.nio.charset.CharacterCodingException;
-
 import org.apache.hadoop.io.Text;
 
 /**
  * LazyObject for storing a value of String.
  */
-public class LazyString extends LazyPrimitive<String> {
+public class LazyString extends LazyPrimitive<Text> {
 
   public LazyString() {
+    data = new Text();
   }
 
   @Override
   public void init(ByteArrayRef bytes, int start, int length) {
-    // In the future, we should allow returning a Text Object to save the UTF-8
-    // decoding/encoding, and the creation of new String object.
-    try {
-      data = Text.decode(bytes.getData(), start, length);
-    } catch (CharacterCodingException e) {
-      data = null;
-    }
+    data.set(bytes.getData(), start, length);
   }
 
 }

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyStruct.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyStruct.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyStruct.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyStruct.java Tue Apr 14 22:54:39 2009
@@ -23,6 +23,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hive.serde2.typeinfo.StructTypeInfo;
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
 import org.apache.hadoop.io.Text;
 
@@ -92,7 +93,7 @@
       boolean lastColumnTakesRest) {
     
     if (fields == null) {
-      List<TypeInfo> fieldTypeInfos = typeInfo.getAllStructFieldTypeInfos();
+      List<TypeInfo> fieldTypeInfos = ((StructTypeInfo)typeInfo).getAllStructFieldTypeInfos();
       fields = new LazyObject[fieldTypeInfos.size()];
       for (int i = 0 ; i < fields.length; i++) {
         fields[i] = LazyFactory.createLazyObject(fieldTypeInfos.get(i));

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyUtils.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyUtils.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyUtils.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyUtils.java Tue Apr 14 22:54:39 2009
@@ -21,6 +21,13 @@
 import java.io.OutputStream;
 import java.nio.ByteBuffer;
 import java.nio.charset.CharacterCodingException;
+
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.ByteObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.IntObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.LongObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.ShortObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.StringObjectInspector;
 import org.apache.hadoop.io.Text;
 
 public class LazyUtils {
@@ -88,20 +95,40 @@
    * Write out the text representation of a Primitive Object to a UTF8 byte stream. 
    * @param out  The UTF8 byte OutputStream
    * @param o    The primitive Object
-   * @throws IOException
    */
-  public static void writePrimitiveUTF8(OutputStream out, Object o) throws IOException {
-    if (o.getClass() == Integer.class || o.getClass() == Short.class 
-        || o.getClass() == Byte.class) {
-      LazyInteger.writeUTF8(out, ((Number)o).intValue());
-    } else if (o.getClass() == Long.class) {
-      LazyLong.writeUTF8(out, ((Long)o).longValue());
-    } else if (o.getClass() == Text.class) {
-      Text t = (Text)o;
-      out.write(t.getBytes(), 0, t.getLength());
-    } else {
-      ByteBuffer b = Text.encode(o.toString());
-      out.write(b.array(), 0, b.limit());
+  public static void writePrimitiveUTF8(OutputStream out, Object o, PrimitiveObjectInspector oi) throws IOException {
+    
+    switch (oi.getPrimitiveCategory()) {
+      case BYTE: {
+        LazyInteger.writeUTF8(out, ((ByteObjectInspector)oi).get(o));
+        break;
+      }
+      case SHORT: {
+        LazyInteger.writeUTF8(out, ((ShortObjectInspector)oi).get(o));
+        break;
+      }
+      case INT: {
+        LazyInteger.writeUTF8(out, ((IntObjectInspector)oi).get(o));
+        break;
+      }
+      case LONG: {
+        LazyLong.writeUTF8(out, ((LongObjectInspector)oi).get(o));
+        break;
+      }
+      // TODO: We should enable this piece of code, once we pass ObjectInspector in the Operator.init() 
+      // instead of Operator.forward().  Until then, JoinOperator will assume the output columns are
+      // all strings but they may not be.
+      /*
+      case STRING: {
+        Text t = ((StringObjectInspector)oi).getPrimitiveWritableObject(o);
+        out.write(t.getBytes(), 0, t.getLength());
+        break;
+      }
+      */
+      default: { 
+        ByteBuffer b = Text.encode(o.toString());
+        out.write(b.array(), 0, b.limit());
+      }
     }
   }
   

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ListObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ListObjectInspector.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ListObjectInspector.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ListObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -35,6 +35,12 @@
   public int getListLength(Object data);
   
   /** returns null for data = null.
+   *  
+   *  Note: This method should not return a List object that is reused by the 
+   *  same ListObjectInspector, because it's possible that the same 
+   *  ListObjectInspector will be used in multiple places in the code.
+   *  
+   *  However it's OK if the List object is part of the Object data.
    */
   public List<?> getList(Object data);
 

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/MapObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/MapObjectInspector.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/MapObjectInspector.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/MapObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -36,6 +36,12 @@
   public Object getMapValueElement(Object data, Object key);
 
   /** returns null for data = null.
+   *
+   *  Note: This method should not return a Map object that is reused by the 
+   *  same MapObjectInspector, because it's possible that the same 
+   *  MapObjectInspector will be used in multiple places in the code.
+   *  
+   *  However it's OK if the Map object is part of the Object data.
    */
   public Map<?,?> getMap(Object data);
 

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/MetadataListStructObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/MetadataListStructObjectInspector.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/MetadataListStructObjectInspector.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/MetadataListStructObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -23,6 +23,8 @@
 import java.util.List;
 
 import org.apache.hadoop.hive.serde2.ColumnSet;
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
 
 /**
  * StructObjectInspector works on struct data that is stored as a Java List or Java Array object.
@@ -51,7 +53,7 @@
   static ArrayList<ObjectInspector> getFieldObjectInspectors(int fields) {
     ArrayList<ObjectInspector> r = new ArrayList<ObjectInspector>(fields);
     for(int i=0; i<fields; i++) {
-      r.add(ObjectInspectorFactory.getStandardPrimitiveObjectInspector(String.class));
+      r.add(PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector(PrimitiveCategory.STRING));
     }
     return r;
   }

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspector.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspector.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -32,7 +32,7 @@
  * An efficient implementation of ObjectInspector should rely on factory, so that we can 
  * make sure the same ObjectInspector only has one instance.  That also makes sure
  * hashCode() and equals() methods of java.lang.Object directly works for ObjectInspector
- * as well.
+ * as well.  
  */
 public interface ObjectInspector {
 

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorFactory.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorFactory.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorFactory.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorFactory.java Tue Apr 14 22:54:39 2009
@@ -27,6 +27,10 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableBooleanObjectInspector;
 import org.apache.hadoop.io.Text;
 
 
@@ -102,11 +106,24 @@
     }
     Class<?> c = (Class<?>)t;
     
-    // Primitive?
-    if (ObjectInspectorUtils.isPrimitiveClass(c)) {
-      return getStandardPrimitiveObjectInspector(c);
+    // Java Primitive Type?
+    if (PrimitiveObjectInspectorUtils.isPrimitiveJavaType(c)) {
+      return PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector(
+          PrimitiveObjectInspectorUtils.getTypeEntryFromPrimitiveJavaType(c).primitiveCategory);
+    }
+
+    // Java Primitive Class?
+    if (PrimitiveObjectInspectorUtils.isPrimitiveJavaClass(c)) {
+      return PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector(
+          PrimitiveObjectInspectorUtils.getTypeEntryFromPrimitiveJavaClass(c).primitiveCategory);
     }
     
+    // Primitive Writable class?
+    if (PrimitiveObjectInspectorUtils.isPrimitiveWritableClass(c)) {
+      return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
+          PrimitiveObjectInspectorUtils.getTypeEntryFromPrimitiveWritableClass(c).primitiveCategory);
+    }
+
     // Must be struct because List and Map need to be ParameterizedType
     assert(!List.class.isAssignableFrom(c));
     assert(!Map.class.isAssignableFrom(c));
@@ -136,18 +153,6 @@
     return oi;
   }
   
-  
-  private static HashMap<Class<?>, StandardPrimitiveObjectInspector> cachedStandardPrimitiveInspectorCache = new HashMap<Class<?>, StandardPrimitiveObjectInspector>();
-  public static StandardPrimitiveObjectInspector getStandardPrimitiveObjectInspector(Class<?> c) {
-    c = ObjectInspectorUtils.generalizePrimitive(c);
-    StandardPrimitiveObjectInspector result = cachedStandardPrimitiveInspectorCache.get(c);
-    if (result == null) {
-      result = new StandardPrimitiveObjectInspector(c);
-      cachedStandardPrimitiveInspectorCache.put(c, result);
-    }
-    return result;
-  }
-  
   static HashMap<ObjectInspector, StandardListObjectInspector> cachedStandardListObjectInspector =
     new HashMap<ObjectInspector, StandardListObjectInspector>(); 
   public static StandardListObjectInspector getStandardListObjectInspector(ObjectInspector listElementObjectInspector) {

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorUtils.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorUtils.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorUtils.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorUtils.java Tue Apr 14 22:54:39 2009
@@ -26,6 +26,18 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hive.serde.Constants;
+import org.apache.hadoop.hive.serde2.io.ByteWritable;
+import org.apache.hadoop.hive.serde2.io.DoubleWritable;
+import org.apache.hadoop.hive.serde2.io.ShortWritable;
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
+import org.apache.hadoop.io.BooleanWritable;
+import org.apache.hadoop.io.FloatWritable;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.NullWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.io.Writable;
 
 /**
  * ObjectInspectorFactory is the primary way to create new ObjectInspector instances.
@@ -37,81 +49,6 @@
 
   private static Log LOG = LogFactory.getLog(ObjectInspectorUtils.class.getName());
   
-  /** This function defines the list of PrimitiveClasses that we support. 
-   *  A PrimitiveClass should support java serialization/deserialization.
-   */
-  public static boolean isPrimitiveClass(Class<?> c) {
-    return ((c == String.class) || (c == Boolean.class) ||
-            (c == Character.class) || (c == java.sql.Date.class) || 
-            java.lang.Number.class.isAssignableFrom(c) || (c == Void.class) ||
-            c.isPrimitive());
-  }
-  
-  /**
-   * Generalize the Java primitive types to the corresponding 
-   * Java Classes.  
-   */
-  public static Class<?> generalizePrimitive(Class<?> primitiveClass) {
-    if (primitiveClass == Boolean.TYPE)   primitiveClass = Boolean.class;
-    if (primitiveClass == Byte.TYPE)      primitiveClass = Byte.class;
-    if (primitiveClass == Character.TYPE) primitiveClass = Character.class;
-    if (primitiveClass == Short.TYPE)     primitiveClass = Short.class;
-    if (primitiveClass == Integer.TYPE)   primitiveClass = Integer.class;
-    if (primitiveClass == Long.TYPE)      primitiveClass = Long.class;
-    if (primitiveClass == Float.TYPE)     primitiveClass = Float.class;
-    if (primitiveClass == Double.TYPE)    primitiveClass = Double.class;
-    if (primitiveClass == Void.TYPE)      primitiveClass = Void.class;
-    return primitiveClass;
-  }
-  
-  public static final Map<Class<?>, String> classToTypeName = new HashMap<Class<?>, String>();
-  static {
-    classToTypeName.put(Boolean.class, org.apache.hadoop.hive.serde.Constants.BOOLEAN_TYPE_NAME);
-    classToTypeName.put(Byte.class, org.apache.hadoop.hive.serde.Constants.TINYINT_TYPE_NAME);
-    classToTypeName.put(Short.class, org.apache.hadoop.hive.serde.Constants.SMALLINT_TYPE_NAME);
-    classToTypeName.put(Integer.class, org.apache.hadoop.hive.serde.Constants.INT_TYPE_NAME);
-    classToTypeName.put(Long.class, org.apache.hadoop.hive.serde.Constants.BIGINT_TYPE_NAME);
-    classToTypeName.put(Float.class, org.apache.hadoop.hive.serde.Constants.FLOAT_TYPE_NAME);
-    classToTypeName.put(Double.class, org.apache.hadoop.hive.serde.Constants.DOUBLE_TYPE_NAME);
-    classToTypeName.put(String.class, org.apache.hadoop.hive.serde.Constants.STRING_TYPE_NAME);
-    classToTypeName.put(java.sql.Date.class, org.apache.hadoop.hive.serde.Constants.DATE_TYPE_NAME);
-  }
-  
-  /**
-   * The mapping from type name in DDL to the Java class. 
-   */
-  public static final Map<String, Class<?>> typeNameToClass = new HashMap<String, Class<?>>();
-  static {
-    typeNameToClass.put(Constants.BOOLEAN_TYPE_NAME, Boolean.class);
-    typeNameToClass.put(Constants.TINYINT_TYPE_NAME, Byte.class);
-    typeNameToClass.put(Constants.SMALLINT_TYPE_NAME, Short.class);
-    typeNameToClass.put(Constants.INT_TYPE_NAME, Integer.class);
-    typeNameToClass.put(Constants.BIGINT_TYPE_NAME, Long.class);
-    typeNameToClass.put(Constants.FLOAT_TYPE_NAME, Float.class);
-    typeNameToClass.put(Constants.DOUBLE_TYPE_NAME, Double.class);
-    typeNameToClass.put(Constants.STRING_TYPE_NAME, String.class);
-    typeNameToClass.put(Constants.DATE_TYPE_NAME, java.sql.Date.class);
-    // These types are not supported yet. 
-    // TypeNameToClass.put(Constants.DATETIME_TYPE_NAME);
-    // TypeNameToClass.put(Constants.TIMESTAMP_TYPE_NAME);
-  }
-  
-  /**
-   * Get the short name for the types
-   */
-  public static String getClassShortName(Class<?> classObject) {
-    String result = classToTypeName.get(classObject);
-    if (result == null) {
-      result = classObject.getName();
-      LOG.warn("unsupported class: " + result);
-      // Remove prefix
-      String prefix = "java.lang.";
-      if (result.startsWith(prefix)) {
-        result = result.substring(prefix.length());
-      }
-    }
-    return result;
-  }
   
   static ArrayList<ArrayList<String>> integerArrayCache = new ArrayList<ArrayList<String>>();
   /**
@@ -153,16 +90,47 @@
   
 
   /**
+   * This enum controls how we copy primitive objects.
+   * 
+   * KEEP means keeping the original format of the primitive object. This is usually the most efficient. 
+   * JAVA means converting all primitive objects to java primitive objects.
+   * WRITABLE means converting all primitive objects to writable objects. 
+   *
+   */
+  public enum ObjectInspectorCopyOption {
+    KEEP,
+    JAVA,
+    WRITABLE
+  }
+  
+  /**
    * Get the standard ObjectInspector for an ObjectInspector.
    * 
    * The returned ObjectInspector can be used to inspect the standard object.
    */
   public static ObjectInspector getStandardObjectInspector(ObjectInspector oi) {
+    return getStandardObjectInspector(oi, ObjectInspectorCopyOption.KEEP);
+  }
+  
+  public static ObjectInspector getStandardObjectInspector(ObjectInspector oi, ObjectInspectorCopyOption objectInspectorOption) {
     ObjectInspector result = null;
     switch (oi.getCategory()) {
       case PRIMITIVE: {
-        PrimitiveObjectInspector poi =(PrimitiveObjectInspector)oi;
-        result = poi;
+        PrimitiveObjectInspector poi = (PrimitiveObjectInspector)oi;
+        switch (objectInspectorOption) {
+          case KEEP: {
+            result = poi;
+            break;
+          }
+          case JAVA: {
+            result = PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector(poi.getPrimitiveCategory());
+            break;
+          }
+          case WRITABLE: {
+            result = PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(poi.getPrimitiveCategory());
+            break;
+          }
+        }
         break;
       }
       case LIST: {
@@ -196,9 +164,15 @@
     return result;
   }
   
-  // TODO: should return o if the ObjectInspector is a standard ObjectInspector hierarchy
-  // (all internal ObjectInspector needs to be standard ObjectInspectors)
-  public static Object getStandardObject(Object o, ObjectInspector oi) {
+  /**
+   * Returns a deep copy of the Object o that can be scanned by a
+   * StandardObjectInspector returned by getStandardObjectInspector(oi).
+   */
+  public static Object copyToStandardObject(Object o, ObjectInspector oi) {
+    return copyToStandardObject(o, oi, ObjectInspectorCopyOption.KEEP);
+  }
+  
+  public static Object copyToStandardObject(Object o, ObjectInspector oi, ObjectInspectorCopyOption objectInspectorOption) {
     if (o == null) {
       return null;
     }
@@ -206,7 +180,21 @@
     Object result = null;
     switch (oi.getCategory()) {
       case PRIMITIVE: {
-        result = o;
+        PrimitiveObjectInspector loi = (PrimitiveObjectInspector)oi;
+        switch (objectInspectorOption) {
+          case KEEP: {
+            result = loi.copyObject(o);
+            break;
+          }
+          case JAVA: {
+            result = loi.getPrimitiveJavaObject(o);
+            break;
+          }
+          case WRITABLE: {
+            result = loi.getPrimitiveWritableObject(o);
+            break;
+          }
+        }
         break;
       }
       case LIST: {
@@ -214,9 +202,10 @@
         int length = loi.getListLength(o);
         ArrayList<Object> list = new ArrayList<Object>(length);
         for(int i=0; i<length; i++) {
-          list.add(getStandardObject(
+          list.add(copyToStandardObject(
               loi.getListElement(o, i),
-              loi.getListElementObjectInspector()));
+              loi.getListElementObjectInspector(),
+              objectInspectorOption));
         }
         result = list;
         break;
@@ -226,8 +215,8 @@
         HashMap<Object, Object> map = new HashMap<Object, Object>();
         Map<? extends Object, ? extends Object> omap = moi.getMap(o);
         for(Map.Entry<? extends Object, ? extends Object> entry: omap.entrySet()) {
-          map.put(getStandardObject(entry.getKey(), moi.getMapKeyObjectInspector()),
-              getStandardObject(entry.getValue(), moi.getMapValueObjectInspector()));
+          map.put(copyToStandardObject(entry.getKey(), moi.getMapKeyObjectInspector(), objectInspectorOption),
+              copyToStandardObject(entry.getValue(), moi.getMapValueObjectInspector(), objectInspectorOption));
         }
         result = map;
         break;
@@ -237,7 +226,7 @@
         List<? extends StructField> fields = soi.getAllStructFieldRefs();
         ArrayList<Object> struct = new ArrayList<Object>(fields.size()); 
         for(StructField f : fields) {
-          struct.add(getStandardObject(soi.getStructFieldData(o, f), f.getFieldObjectInspector()));
+          struct.add(copyToStandardObject(soi.getStructFieldData(o, f), f.getFieldObjectInspector(), objectInspectorOption));
         }
         result = struct;
         break;
@@ -251,7 +240,7 @@
   
   public static String getStandardStructTypeName(StructObjectInspector soi) {
     StringBuilder sb = new StringBuilder();
-    sb.append("struct{");
+    sb.append("struct<");
     List<? extends StructField> fields = soi.getAllStructFieldRefs(); 
     for(int i=0; i<fields.size(); i++) {
       if (i>0) sb.append(",");
@@ -259,7 +248,7 @@
       sb.append(":");
       sb.append(fields.get(i).getFieldObjectInspector().getTypeName());
     }
-    sb.append("}");
+    sb.append(">");
     return sb.toString();
   }
   
@@ -282,4 +271,45 @@
     throw new RuntimeException("cannot find field " + fieldName + " from " + fields); 
     // return null;
   }
+  
+  /**
+   * Get the class names of the ObjectInspector hierarchy. Mainly used for debugging. 
+   */
+  public static String getObjectInspectorName(ObjectInspector oi) {
+    switch (oi.getCategory()) {
+      case PRIMITIVE: {
+        return oi.getClass().getSimpleName();
+      }
+      case LIST: {
+        ListObjectInspector loi = (ListObjectInspector)oi;
+        return oi.getClass().getSimpleName() + "<" + getObjectInspectorName(loi.getListElementObjectInspector()) + ">";
+      }
+      case MAP: {
+        MapObjectInspector moi = (MapObjectInspector)oi;
+        return oi.getClass().getSimpleName() + "<" + getObjectInspectorName(moi.getMapKeyObjectInspector()) 
+            + "," + getObjectInspectorName(moi.getMapValueObjectInspector()) + ">";
+      }
+      case STRUCT: {
+        StringBuffer result = new StringBuffer();
+        result.append(oi.getClass().getSimpleName() + "<");
+        StructObjectInspector soi = (StructObjectInspector)oi;
+        List<? extends StructField> fields = soi.getAllStructFieldRefs();
+        for(int i = 0; i<fields.size(); i++) {
+          result.append(fields.get(i).getFieldName());
+          result.append(":");
+          result.append(getObjectInspectorName(fields.get(i).getFieldObjectInspector()));
+          if (i == fields.size() - 1) {
+            result.append(">");
+          } else {
+            result.append(",");
+          }
+        }
+        return result.toString();
+      }
+      default: {
+        throw new RuntimeException("Unknown ObjectInspector category!");
+      }
+    }
+  }
+    
 }

Modified: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/PrimitiveObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/PrimitiveObjectInspector.java?rev=764994&r1=764993&r2=764994&view=diff
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/PrimitiveObjectInspector.java (original)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/PrimitiveObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -17,8 +17,57 @@
  */
 package org.apache.hadoop.hive.serde2.objectinspector;
 
-public interface PrimitiveObjectInspector extends ObjectInspector{
+public interface PrimitiveObjectInspector extends ObjectInspector {
 
-  public Class<?> getPrimitiveClass();
+  /**
+   * The primitive types supported by Hive. 
+   */
+  public static enum PrimitiveCategory {
+    VOID, BOOLEAN, BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, STRING, UNKNOWN
+  };
+  
+  /**
+   * Get the primitive category of the PrimitiveObjectInspector.
+   */
+  public PrimitiveCategory getPrimitiveCategory();
+  
+  /**
+   * Get the Primitive Writable class which is the return type of 
+   * getPrimitiveWritableObject() and copyToPrimitiveWritableObject()
+   */
+  public Class<?> getPrimitiveWritableClass();
 
+  /**
+   * Return the data in an instance of primitive writable Object.  If the 
+   * Object is already a primitive writable Object, just return o.
+   */
+  public Object getPrimitiveWritableObject(Object o);
+  
+  /**
+   * Get the Java Primitive class which is the return type of 
+   * getJavaPrimitiveObject().
+   */
+  public Class<?> getJavaPrimitiveClass();
+
+  /**
+   * Get the Java Primitive object.
+   */
+  public Object getPrimitiveJavaObject(Object o);
+  
+  /**
+   * Get a copy of the Object in the same class, so the return value can be 
+   * stored independently of the parameter.
+   * 
+   * If the Object is a Primitive Java Object, we just return the parameter
+   * since Primitive Java Object is immutable.
+   */
+  public Object copyObject(Object o);
+  
+  /**
+   * Whether the ObjectInspector prefers to return a Primitive Writable Object
+   * instead of a Primitive Java Object.
+   * This can be useful for determining the most efficient way to getting
+   * data out of the Object. 
+   */
+  public boolean isWritable();
 }

Added: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveJavaObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveJavaObjectInspector.java?rev=764994&view=auto
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveJavaObjectInspector.java (added)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveJavaObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.PrimitiveTypeEntry;
+
+/**
+ * An AbstractJavaPrimitiveObjectInspector for a Java object. 
+ */
+public abstract class AbstractPrimitiveJavaObjectInspector extends AbstractPrimitiveObjectInspector {
+
+  protected AbstractPrimitiveJavaObjectInspector(PrimitiveTypeEntry typeEntry) {
+    super(typeEntry);
+  }
+  
+  @Override
+  public Object getPrimitiveJavaObject(Object o) {
+    return o;
+  }
+
+  @Override
+  public Object copyObject(Object o) {
+    return o;
+  }
+  
+  @Override
+  public boolean isWritable() {
+    return false;
+  }
+}

Added: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveObjectInspector.java?rev=764994&view=auto
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveObjectInspector.java (added)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.PrimitiveTypeEntry;
+
+/**
+ * An AbstractPrimitiveObjectInspector is based on ObjectInspectorUtils.PrimitiveTypeEntry. 
+ */
+public abstract class AbstractPrimitiveObjectInspector implements PrimitiveObjectInspector {
+
+  PrimitiveTypeEntry typeEntry;
+
+  /**
+   * Construct a AbstractPrimitiveObjectInspector.
+   */
+  protected AbstractPrimitiveObjectInspector(PrimitiveTypeEntry typeEntry) {
+    this.typeEntry = typeEntry; 
+  }
+
+  /**
+   * Return the associated Java primitive class for this primitive ObjectInspector.
+   */
+  @Override
+  public Class<?> getJavaPrimitiveClass() {
+    return typeEntry.primitiveJavaClass;
+  }
+
+  /**
+   * Return the associated primitive category for this primitive ObjectInspector.
+   */
+  @Override
+  public PrimitiveCategory getPrimitiveCategory() {
+    return typeEntry.primitiveCategory;
+  }
+
+  /**
+   * Return the associated primitive Writable class for this primitive ObjectInspector.
+   */
+  @Override
+  public Class<?> getPrimitiveWritableClass() {
+    return typeEntry.primitiveWritableClass;
+  }
+
+  /**
+   * Return the associated category this primitive ObjectInspector.
+   */
+  @Override
+  public Category getCategory() {
+    return Category.PRIMITIVE;
+  }
+
+  /**
+   * Return the type name for this primitive ObjectInspector.
+   */
+  @Override
+  public String getTypeName() {
+    return typeEntry.typeName;
+  }
+
+}

Added: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveWritableObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveWritableObjectInspector.java?rev=764994&view=auto
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveWritableObjectInspector.java (added)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveWritableObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.PrimitiveTypeEntry;
+
+/**
+ * An AbstractWritablePrimitiveObjectInspector for a Writable object. 
+ */
+public abstract class AbstractPrimitiveWritableObjectInspector extends AbstractPrimitiveObjectInspector {
+
+  protected AbstractPrimitiveWritableObjectInspector(PrimitiveTypeEntry typeEntry) {
+    super(typeEntry); 
+  }
+  
+  @Override
+  public Object getPrimitiveWritableObject(Object o) {
+    return o;
+  }
+
+  @Override
+  public boolean isWritable() {
+    return true;
+  }
+  
+}

Added: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/BooleanObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/BooleanObjectInspector.java?rev=764994&view=auto
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/BooleanObjectInspector.java (added)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/BooleanObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
+
+
+/**
+ * A BooleanObjectInspector inspects an Object representing a Boolean.
+ */
+public interface BooleanObjectInspector extends PrimitiveObjectInspector {
+  
+  /**
+   * Get the boolean data.
+   */
+  boolean get(Object o);
+}

Added: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/ByteObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/ByteObjectInspector.java?rev=764994&view=auto
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/ByteObjectInspector.java (added)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/ByteObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
+
+
+/**
+ * A ByteObjectInspector inspects an Object representing a Byte object.
+ */
+public interface ByteObjectInspector extends PrimitiveObjectInspector {
+  
+  /**
+   * Get the byte data.
+   */
+  byte get(Object o);
+}

Added: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/DoubleObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/DoubleObjectInspector.java?rev=764994&view=auto
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/DoubleObjectInspector.java (added)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/DoubleObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
+
+
+/**
+ * A DoubleObjectInspector inspects an Object representing a Double.
+ */
+public interface DoubleObjectInspector extends PrimitiveObjectInspector {
+  
+  /**
+   * Get the double data.
+   */
+  double get(Object o);
+}

Added: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/FloatObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/FloatObjectInspector.java?rev=764994&view=auto
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/FloatObjectInspector.java (added)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/FloatObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
+
+
+/**
+ * A FloatObjectInspector inspects an Object representing a Float.
+ */
+public interface FloatObjectInspector extends PrimitiveObjectInspector {
+  
+  /**
+   * Get the float data.
+   */
+  float get(Object o);
+}

Added: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/IntObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/IntObjectInspector.java?rev=764994&view=auto
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/IntObjectInspector.java (added)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/IntObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
+
+
+/**
+ * A IntObjectInspector inspects an Object representing an Integer.
+ */
+public interface IntObjectInspector extends PrimitiveObjectInspector {
+  
+  /**
+   * Get the int data.
+   */
+  int get(Object o);
+}

Added: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBooleanObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBooleanObjectInspector.java?rev=764994&view=auto
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBooleanObjectInspector.java (added)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBooleanObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.io.BooleanWritable;
+
+
+/**
+ * A JavaBooleanObjectInspector inspects a Java Boolean Object.
+ */
+public class JavaBooleanObjectInspector extends AbstractPrimitiveJavaObjectInspector 
+implements BooleanObjectInspector{
+
+  JavaBooleanObjectInspector() {
+    super(PrimitiveObjectInspectorUtils.booleanTypeEntry);
+  }
+  
+  @Override
+  public Object getPrimitiveWritableObject(Object o) {
+    return o == null ? null : new BooleanWritable(((Boolean)o).booleanValue());
+  }
+
+  @Override
+  public boolean get(Object o) {
+    return ((Boolean)o).booleanValue();
+  }
+}

Added: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaByteObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaByteObjectInspector.java?rev=764994&view=auto
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaByteObjectInspector.java (added)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaByteObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.serde2.io.ByteWritable;
+
+
+/**
+ * A JavaByteObjectInspector inspects a Java Byte Object.
+ */
+public class JavaByteObjectInspector extends AbstractPrimitiveJavaObjectInspector 
+implements ByteObjectInspector{
+
+  JavaByteObjectInspector() {
+    super(PrimitiveObjectInspectorUtils.byteTypeEntry);
+  }
+  
+  @Override
+  public Object getPrimitiveWritableObject(Object o) {
+    return o == null ? null : new ByteWritable(((Byte)o).byteValue());
+  }
+
+  @Override
+  public byte get(Object o) {
+    return ((Byte)o).byteValue();
+  }
+}

Added: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaDoubleObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaDoubleObjectInspector.java?rev=764994&view=auto
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaDoubleObjectInspector.java (added)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaDoubleObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.serde2.io.DoubleWritable;
+
+
+/**
+ * A JavaDoubleObjectInspector inspects a Java Double Object.
+ */
+public class JavaDoubleObjectInspector extends AbstractPrimitiveJavaObjectInspector 
+implements DoubleObjectInspector{
+
+  JavaDoubleObjectInspector() {
+    super(PrimitiveObjectInspectorUtils.doubleTypeEntry);
+  }
+  
+  @Override
+  public Object getPrimitiveWritableObject(Object o) {
+    return o == null ? null : new DoubleWritable(((Double)o).doubleValue());
+  }
+
+  @Override
+  public double get(Object o) {
+    return ((Double)o).doubleValue();
+  }
+}

Added: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaFloatObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaFloatObjectInspector.java?rev=764994&view=auto
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaFloatObjectInspector.java (added)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaFloatObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.io.FloatWritable;
+
+
+/**
+ * A JavaFloatObjectInspector inspects a Java Float Object.
+ */
+public class JavaFloatObjectInspector extends AbstractPrimitiveJavaObjectInspector 
+implements FloatObjectInspector{
+
+  JavaFloatObjectInspector() {
+    super(PrimitiveObjectInspectorUtils.floatTypeEntry);
+  }
+  
+  @Override
+  public Object getPrimitiveWritableObject(Object o) {
+    return o == null ? null : new FloatWritable(((Float)o).floatValue());
+  }
+
+  @Override
+  public float get(Object o) {
+    return ((Float)o).floatValue();
+  }
+}

Added: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaIntObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaIntObjectInspector.java?rev=764994&view=auto
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaIntObjectInspector.java (added)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaIntObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.io.IntWritable;
+
+
+/**
+ * A JavaIntObjectInspector inspects a Java Integer Object.
+ */
+public class JavaIntObjectInspector extends AbstractPrimitiveJavaObjectInspector 
+implements IntObjectInspector{
+
+  JavaIntObjectInspector() {
+    super(PrimitiveObjectInspectorUtils.intTypeEntry);
+  }
+  
+  @Override
+  public Object getPrimitiveWritableObject(Object o) {
+    return o == null ? null : new IntWritable(((Integer)o).intValue());
+  }
+
+  @Override
+  public int get(Object o) {
+    return ((Integer)o).intValue();
+  }
+}

Added: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaLongObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaLongObjectInspector.java?rev=764994&view=auto
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaLongObjectInspector.java (added)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaLongObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.io.LongWritable;
+
+
+/**
+ * A JavaLongObjectInspector inspects a Java Long Object.
+ */
+public class JavaLongObjectInspector extends AbstractPrimitiveJavaObjectInspector 
+implements LongObjectInspector{
+
+  JavaLongObjectInspector() {
+    super(PrimitiveObjectInspectorUtils.longTypeEntry);
+  }
+  
+  @Override
+  public Object getPrimitiveWritableObject(Object o) {
+    return o == null ? null : new LongWritable(((Long)o).longValue());
+  }
+
+  @Override
+  public long get(Object o) {
+    return ((Long)o).longValue();
+  }
+}

Added: hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaShortObjectInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaShortObjectInspector.java?rev=764994&view=auto
==============================================================================
--- hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaShortObjectInspector.java (added)
+++ hadoop/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaShortObjectInspector.java Tue Apr 14 22:54:39 2009
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.hive.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.serde2.io.ShortWritable;
+
+
+/**
+ * A JavaShortObjectInspector inspects a Java Short Object.
+ */
+public class JavaShortObjectInspector extends AbstractPrimitiveJavaObjectInspector 
+implements ShortObjectInspector{
+
+  JavaShortObjectInspector() {
+    super(PrimitiveObjectInspectorUtils.shortTypeEntry);
+  }
+  
+  @Override
+  public Object getPrimitiveWritableObject(Object o) {
+    return o == null ? null : new ShortWritable(((Short)o).shortValue());
+  }
+
+  @Override
+  public short get(Object o) {
+    return ((Short)o).shortValue();
+  }
+}



Mime
View raw message