hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1179784 [3/3] - in /hive/trunk: metastore/src/java/org/apache/hadoop/hive/metastore/ ql/src/java/org/apache/hadoop/hive/ql/exec/ ql/src/java/org/apache/hadoop/hive/ql/parse/ ql/src/java/org/apache/hadoop/hive/ql/udf/ ql/src/java/org/apache...
Date Thu, 06 Oct 2011 19:39:00 GMT
Modified: hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestObjectInspectorConverters.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestObjectInspectorConverters.java?rev=1179784&r1=1179783&r2=1179784&view=diff
==============================================================================
--- hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestObjectInspectorConverters.java
(original)
+++ hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestObjectInspectorConverters.java
Thu Oct  6 19:38:55 2011
@@ -25,6 +25,7 @@ import org.apache.hadoop.hive.serde2.io.
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters.Converter;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
 import org.apache.hadoop.io.BooleanWritable;
+import org.apache.hadoop.io.BytesWritable;
 import org.apache.hadoop.io.FloatWritable;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.LongWritable;
@@ -109,7 +110,26 @@ public class TestObjectInspectorConverte
           .convert(Integer.valueOf(0)));
       assertEquals("TextConverter", new Text("1"), textConverter
           .convert(Integer.valueOf(1)));
-
+      textConverter = ObjectInspectorConverters.getConverter(
+          PrimitiveObjectInspectorFactory.writableBinaryObjectInspector,
+          PrimitiveObjectInspectorFactory.writableStringObjectInspector);
+      assertEquals("TextConverter", new Text("hive"), textConverter
+          .convert(new BytesWritable(new byte[]
+              {(byte)'h', (byte)'i',(byte)'v',(byte)'e'})));
+
+      // Binary
+      Converter baConverter = ObjectInspectorConverters.getConverter(
+          PrimitiveObjectInspectorFactory.javaStringObjectInspector,
+          PrimitiveObjectInspectorFactory.writableBinaryObjectInspector);
+      assertEquals("BAConverter", new BytesWritable(new byte[]
+          {(byte)'h', (byte)'i',(byte)'v',(byte)'e'}),
+          baConverter.convert("hive"));
+      baConverter = ObjectInspectorConverters.getConverter(
+          PrimitiveObjectInspectorFactory.writableStringObjectInspector,
+          PrimitiveObjectInspectorFactory.writableBinaryObjectInspector);
+      assertEquals("BAConverter", new BytesWritable(new byte[]
+          {(byte)'h', (byte)'i',(byte)'v',(byte)'e'}),
+          baConverter.convert(new Text("hive")));
     } catch (Throwable e) {
       e.printStackTrace();
       throw e;

Modified: hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestStandardObjectInspectors.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestStandardObjectInspectors.java?rev=1179784&r1=1179783&r2=1179784&view=diff
==============================================================================
--- hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestStandardObjectInspectors.java
(original)
+++ hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestStandardObjectInspectors.java
Thu Oct  6 19:38:55 2011
@@ -27,6 +27,7 @@ import org.apache.hadoop.hive.serde2.Ser
 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.lazy.ByteArrayRef;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector.Category;
 import org.apache.hadoop.hive.serde2.objectinspector.StandardUnionObjectInspector.StandardUnion;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
@@ -35,6 +36,7 @@ import org.apache.hadoop.hive.serde2.typ
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils;
 import org.apache.hadoop.hive.serde2.typeinfo.UnionTypeInfo;
 import org.apache.hadoop.io.BooleanWritable;
+import org.apache.hadoop.io.BytesWritable;
 import org.apache.hadoop.io.FloatWritable;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.LongWritable;
@@ -87,6 +89,7 @@ public class TestStandardObjectInspector
       doTestStandardPrimitiveObjectInspector(FloatWritable.class, Float.class);
       doTestStandardPrimitiveObjectInspector(DoubleWritable.class, Double.class);
       doTestStandardPrimitiveObjectInspector(Text.class, String.class);
+      doTestStandardPrimitiveObjectInspector(BytesWritable.class, ByteArrayRef.class);
     } catch (Throwable e) {
       e.printStackTrace();
       throw e;
@@ -138,6 +141,9 @@ public class TestStandardObjectInspector
       doTestJavaPrimitiveObjectInspector(DoubleWritable.class, Double.class,
           (double) 1);
       doTestJavaPrimitiveObjectInspector(Text.class, String.class, "a");
+      ByteArrayRef ba = new ByteArrayRef();
+      ba.setData(new byte[]{'3'});
+      doTestJavaPrimitiveObjectInspector(BytesWritable.class, ByteArrayRef.class, ba);
 
     } catch (Throwable e) {
       e.printStackTrace();
@@ -291,7 +297,9 @@ public class TestStandardObjectInspector
       fieldComments.add("secondString comment");
       fieldComments.add("thirdBoolean comment");
     } else { // should have null for non-specified comments
-      for(int i = 0; i < 3; i++) fieldComments.add(null);
+      for(int i = 0; i < 3; i++) {
+        fieldComments.add(null);
+    }
     }
 
     StandardStructObjectInspector soi1 = testComments ?



Mime
View raw message