hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1363427 - in /hive/trunk/serde/src: java/org/apache/hadoop/hive/serde2/lazy/ java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/ java/org/apache/hadoop/hive/serde2/objectinspector/primitive/ test/org/apache/hadoop/hive/serde...
Date Thu, 19 Jul 2012 17:06:25 GMT
Author: hashutosh
Date: Thu Jul 19 17:06:24 2012
New Revision: 1363427

URL: http://svn.apache.org/viewvc?rev=1363427&view=rev
Log:
HIVE-3246 : java primitive type for binary datatype should be byte[] (Thejas Nair via Ashutosh
Chauhan)

Modified:
    hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyUtils.java
    hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyBinaryObjectInspector.java
    hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/BinaryObjectInspector.java
    hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBinaryObjectInspector.java
    hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorConverter.java
    hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java
    hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableBinaryObjectInspector.java
    hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableBinaryObjectInspector.java
    hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantBinaryObjectInspector.java
    hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/TestStatsSerde.java
    hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/binarysortable/MyTestClass.java
    hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/binarysortable/TestBinarySortableSerDe.java
    hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/columnar/TestLazyBinaryColumnarSerDe.java
    hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/lazybinary/MyTestClassBigger.java
    hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/lazybinary/TestLazyBinarySerDe.java
    hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestStandardObjectInspectors.java

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyUtils.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyUtils.java?rev=1363427&r1=1363426&r2=1363427&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyUtils.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyUtils.java Thu Jul 19
17:06:24 2012
@@ -350,17 +350,13 @@ public final class LazyUtils {
   }
 
   /**
-   * Creates a ByteArrayRef with data from source BytesWritable
+   * gets a byte[] with copy of data from source BytesWritable
    * @param sourceBw - source BytesWritable
    */
-  public static ByteArrayRef createByteArrayRef(BytesWritable sourceBw){
-    //TODO should use BytesWritable.copyData() here once Hive
-    // removes support for the Hadoop 0.20 series.
-    byte[] newData = Arrays.copyOf(sourceBw.getBytes(), sourceBw.getLength());
-
-    ByteArrayRef bar = new ByteArrayRef();
-    bar.setData(newData);
-    return bar;
+  public static byte[] createByteArray(BytesWritable sourceBw){
+    //TODO should replace with BytesWritable.copyData() once Hive
+    //removes support for the Hadoop 0.20 series.
+    return Arrays.copyOf(sourceBw.getBytes(), sourceBw.getLength());
   }
 
   private LazyUtils() {

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyBinaryObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyBinaryObjectInspector.java?rev=1363427&r1=1363426&r2=1363427&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyBinaryObjectInspector.java
(original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyBinaryObjectInspector.java
Thu Jul 19 17:06:24 2012
@@ -18,7 +18,6 @@
 
 package org.apache.hadoop.hive.serde2.lazy.objectinspector.primitive;
 
-import org.apache.hadoop.hive.serde2.lazy.ByteArrayRef;
 import org.apache.hadoop.hive.serde2.lazy.LazyBinary;
 import org.apache.hadoop.hive.serde2.lazy.LazyUtils;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.BinaryObjectInspector;
@@ -39,11 +38,11 @@ public class LazyBinaryObjectInspector e
   }
 
   @Override
-  public ByteArrayRef getPrimitiveJavaObject(Object o) {
+  public byte[] getPrimitiveJavaObject(Object o) {
     if (null == o) {
       return null;
     }
-    return LazyUtils.createByteArrayRef(((LazyBinary) o).getWritableObject());
+    return LazyUtils.createByteArray(((LazyBinary) o).getWritableObject());
   }
 
   @Override

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/BinaryObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/BinaryObjectInspector.java?rev=1363427&r1=1363426&r2=1363427&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/BinaryObjectInspector.java
(original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/BinaryObjectInspector.java
Thu Jul 19 17:06:24 2012
@@ -18,14 +18,13 @@
 
 package org.apache.hadoop.hive.serde2.objectinspector.primitive;
 
-import org.apache.hadoop.hive.serde2.lazy.ByteArrayRef;
 import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
 import org.apache.hadoop.io.BytesWritable;
 
 public interface BinaryObjectInspector extends PrimitiveObjectInspector {
 
   @Override
-  ByteArrayRef getPrimitiveJavaObject(Object o);
+  byte[] getPrimitiveJavaObject(Object o);
 
   @Override
   BytesWritable getPrimitiveWritableObject(Object o);

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBinaryObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBinaryObjectInspector.java?rev=1363427&r1=1363426&r2=1363427&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBinaryObjectInspector.java
(original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBinaryObjectInspector.java
Thu Jul 19 17:06:24 2012
@@ -1,6 +1,7 @@
 package org.apache.hadoop.hive.serde2.objectinspector.primitive;
 
-import org.apache.hadoop.hive.serde2.lazy.ByteArrayRef;
+import java.util.Arrays;
+
 import org.apache.hadoop.hive.serde2.lazy.LazyUtils;
 import org.apache.hadoop.io.BytesWritable;
 
@@ -30,56 +31,56 @@ public class JavaBinaryObjectInspector e
   }
 
   @Override
-  public ByteArrayRef copyObject(Object o) {
+  public byte[] copyObject(Object o) {
     if (null == o){
       return null;
     }
-
-    ByteArrayRef ba = new ByteArrayRef();
-    byte[] incoming = ((ByteArrayRef)o).getData();
+    byte[] incoming = (byte[])o;
     byte[] outgoing = new byte[incoming.length];
     System.arraycopy(incoming, 0, outgoing, 0, incoming.length);
-    ba.setData(outgoing);
-    return ba;
+    return outgoing;
   }
 
   @Override
   public BytesWritable getPrimitiveWritableObject(Object o) {
-    return o == null ? null : new BytesWritable(((ByteArrayRef)o).getData());
+    return o == null ? null : new BytesWritable((byte[])o);
   }
 
   @Override
-  public ByteArrayRef getPrimitiveJavaObject(Object o) {
-    return (ByteArrayRef)o;
+  public byte[] getPrimitiveJavaObject(Object o) {
+    return (byte[])o;
   }
+
+  /*
+   * {@inheritDoc}
+   */
   @Override
-  public ByteArrayRef set(Object o, ByteArrayRef bb) {
-    ByteArrayRef ba = (ByteArrayRef)o;
-    ba.setData(bb.getData());
-    return ba;
+  public byte[] set(Object o, byte[] bb) {
+    return bb == null ? null : Arrays.copyOf(bb, bb.length);
   }
 
+  /*
+   * {@inheritDoc}
+   */
   @Override
-  public ByteArrayRef set(Object o, BytesWritable bw) {
-    if (null == bw){
-      return null;
-    }
-    return LazyUtils.createByteArrayRef(bw);
+  public byte[] set(Object o, BytesWritable bw) {
+    return bw == null ? null :  LazyUtils.createByteArray(bw);
   }
 
+  /*
+   * {@inheritDoc}
+   */
   @Override
-  public ByteArrayRef create(ByteArrayRef bb) {
-    ByteArrayRef ba = new ByteArrayRef();
-    ba.setData(bb.getData());
-    return ba;
+  public byte[] create(byte[] bb) {
+    return bb == null ? null : Arrays.copyOf(bb, bb.length);
   }
 
+  /*
+   * {@inheritDoc}
+   */
   @Override
-  public ByteArrayRef create(BytesWritable bw) {
-    if(null == bw){
-      return null;
-    }
-    return LazyUtils.createByteArrayRef(bw);
+  public byte[] create(BytesWritable bw) {
+    return bw == null ? null : LazyUtils.createByteArray(bw);
   }
 
 }

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorConverter.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorConverter.java?rev=1363427&r1=1363426&r2=1363427&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorConverter.java
(original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorConverter.java
Thu Jul 19 17:06:24 2012
@@ -21,7 +21,6 @@ package org.apache.hadoop.hive.serde2.ob
 import java.sql.Timestamp;
 
 import org.apache.hadoop.hive.serde2.ByteStream;
-import org.apache.hadoop.hive.serde2.lazy.ByteArrayRef;
 import org.apache.hadoop.hive.serde2.lazy.LazyInteger;
 import org.apache.hadoop.hive.serde2.lazy.LazyLong;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters.Converter;
@@ -268,9 +267,7 @@ public class PrimitiveObjectInspectorCon
         SettableBinaryObjectInspector outputOI) {
       this.inputOI = inputOI;
       this.outputOI = outputOI;
-      ByteArrayRef ba = new ByteArrayRef();
-      ba.setData(new byte[]{});
-      r = outputOI.create(ba);
+      r = outputOI.create(new byte[]{});
     }
 
     @Override

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java?rev=1363427&r1=1363426&r2=1363427&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java
(original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java
Thu Jul 19 17:06:24 2012
@@ -30,7 +30,6 @@ import org.apache.hadoop.hive.serde2.io.
 import org.apache.hadoop.hive.serde2.io.DoubleWritable;
 import org.apache.hadoop.hive.serde2.io.ShortWritable;
 import org.apache.hadoop.hive.serde2.io.TimestampWritable;
-import org.apache.hadoop.hive.serde2.lazy.ByteArrayRef;
 import org.apache.hadoop.hive.serde2.lazy.LazyInteger;
 import org.apache.hadoop.hive.serde2.lazy.LazyLong;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
@@ -146,7 +145,7 @@ public final class PrimitiveObjectInspec
 
   public static final PrimitiveTypeEntry binaryTypeEntry = new PrimitiveTypeEntry(
       PrimitiveCategory.BINARY, Constants.BINARY_TYPE_NAME, byte[].class,
-      ByteArrayRef.class, BytesWritable.class);
+      byte[].class, BytesWritable.class);
   public static final PrimitiveTypeEntry stringTypeEntry = new PrimitiveTypeEntry(
       PrimitiveCategory.STRING, Constants.STRING_TYPE_NAME, null, String.class,
       Text.class);

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableBinaryObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableBinaryObjectInspector.java?rev=1363427&r1=1363426&r2=1363427&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableBinaryObjectInspector.java
(original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableBinaryObjectInspector.java
Thu Jul 19 17:06:24 2012
@@ -18,16 +18,33 @@
 
 package org.apache.hadoop.hive.serde2.objectinspector.primitive;
 
-import org.apache.hadoop.hive.serde2.lazy.ByteArrayRef;
 import org.apache.hadoop.io.BytesWritable;
 
 public interface SettableBinaryObjectInspector extends BinaryObjectInspector{
 
-  Object set(Object o, ByteArrayRef bb);
-
+  /**
+   * Set the object with the value. Return the object that has the new value.
+   *
+   * In most cases the returned value should be the same as o, but in case o is
+   * unmodifiable, this will return a new object with new value.
+   */
+  Object set(Object o, byte[] bb);
+
+  /**
+   * Set the object with the value. Return the object that has the new value.
+   *
+   * In most cases the returned value should be the same as o, but in case o is
+   * unmodifiable, this will return a new object with new value.
+   */
   Object set(Object o, BytesWritable bw);
 
-  Object create(ByteArrayRef bb);
-
+  /**
+   * Create an object with the value.
+   */
+  Object create(byte[] bb);
+
+  /**
+   * Create an object with the value.
+   */
   Object create(BytesWritable bw);
 }

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableBinaryObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableBinaryObjectInspector.java?rev=1363427&r1=1363426&r2=1363427&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableBinaryObjectInspector.java
(original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableBinaryObjectInspector.java
Thu Jul 19 17:06:24 2012
@@ -18,10 +18,13 @@
 
 package org.apache.hadoop.hive.serde2.objectinspector.primitive;
 
-import org.apache.hadoop.hive.serde2.lazy.ByteArrayRef;
+import java.util.Arrays;
+
 import org.apache.hadoop.hive.serde2.lazy.LazyUtils;
 import org.apache.hadoop.io.BytesWritable;
-
+/**
+ * A WritableBinaryObjectInspector inspects a BytesWritable Object.
+ */
 public class WritableBinaryObjectInspector extends AbstractPrimitiveWritableObjectInspector
     implements SettableBinaryObjectInspector {
 
@@ -41,11 +44,8 @@ public class WritableBinaryObjectInspect
   }
 
   @Override
-  public ByteArrayRef getPrimitiveJavaObject(Object o) {
-    if (null == o){
-      return null;
-    }
-    return LazyUtils.createByteArrayRef((BytesWritable)o);
+  public byte[] getPrimitiveJavaObject(Object o) {
+    return o == null ? null : LazyUtils.createByteArray((BytesWritable)o);
   }
 
   @Override
@@ -53,15 +53,21 @@ public class WritableBinaryObjectInspect
     return null == o ? null : (BytesWritable)o;
   }
 
+  /*
+   * {@inheritDoc}
+   */
   @Override
-  public BytesWritable set(Object o, ByteArrayRef bb) {
+  public BytesWritable set(Object o, byte[] bb) {
     BytesWritable incoming = (BytesWritable)o;
     if (bb != null){
-      incoming.set(bb.getData(),0,bb.getData().length);
+      incoming.set(bb, 0, bb.length);
     }
     return incoming;
   }
 
+  /*
+   * {@inheritDoc}
+   */
   @Override
   public BytesWritable set(Object o, BytesWritable bw) {
     BytesWritable incoming = (BytesWritable)o;
@@ -71,11 +77,17 @@ public class WritableBinaryObjectInspect
     return incoming;
   }
 
+  /*
+   * {@inheritDoc}
+   */
   @Override
-  public BytesWritable create(ByteArrayRef bb) {
-    return new BytesWritable(bb.getData());
+  public BytesWritable create(byte[] bb) {
+    return new BytesWritable(Arrays.copyOf(bb, bb.length));
   }
 
+  /*
+   * {@inheritDoc}
+   */
   @Override
   public BytesWritable create(BytesWritable bw) {
 

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantBinaryObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantBinaryObjectInspector.java?rev=1363427&r1=1363426&r2=1363427&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantBinaryObjectInspector.java
(original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantBinaryObjectInspector.java
Thu Jul 19 17:06:24 2012
@@ -35,6 +35,9 @@ public class WritableConstantBinaryObjec
     this.value = value;
   }
 
+  /*
+   * {@inheritDoc}
+   */
   @Override
   public BytesWritable getWritableConstantValue() {
     return value;

Modified: hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/TestStatsSerde.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/TestStatsSerde.java?rev=1363427&r1=1363426&r2=1363427&view=diff
==============================================================================
--- hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/TestStatsSerde.java (original)
+++ hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/TestStatsSerde.java Thu Jul 19
17:06:24 2012
@@ -32,7 +32,6 @@ import org.apache.hadoop.hive.serde2.bin
 import org.apache.hadoop.hive.serde2.columnar.BytesRefArrayWritable;
 import org.apache.hadoop.hive.serde2.columnar.BytesRefWritable;
 import org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe;
-import org.apache.hadoop.hive.serde2.lazy.ByteArrayRef;
 import org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe;
 import org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
@@ -117,7 +116,7 @@ public class TestStatsSerde extends Test
             .nextInt(5) - 2, r.nextInt(5) - 2);
         List<Integer> li = randField > 8 ? null : TestBinarySortableSerDe
             .getRandIntegerArray(r);
-        ByteArrayRef ba = TestBinarySortableSerDe.getRandBA(r, i);
+        byte[] ba = TestBinarySortableSerDe.getRandBA(r, i);
         MyTestClass t = new MyTestClass(b, s, n, l, f, d, st, is, li,ba);
         rows[i] = t;
       }

Modified: hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/binarysortable/MyTestClass.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/binarysortable/MyTestClass.java?rev=1363427&r1=1363426&r2=1363427&view=diff
==============================================================================
--- hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/binarysortable/MyTestClass.java
(original)
+++ hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/binarysortable/MyTestClass.java
Thu Jul 19 17:06:24 2012
@@ -19,8 +19,6 @@ package org.apache.hadoop.hive.serde2.bi
 
 import java.util.List;
 
-import org.apache.hadoop.hive.serde2.lazy.ByteArrayRef;
-
 public class MyTestClass {
   Byte myByte;
   Short myShort;
@@ -31,13 +29,13 @@ public class MyTestClass {
   String myString;
   MyTestInnerStruct myStruct;
   List<Integer> myList;
-  ByteArrayRef myBA;
+  byte[] myBA;
 
   public MyTestClass() {
   }
 
   public MyTestClass(Byte b, Short s, Integer i, Long l, Float f, Double d,
-      String st, MyTestInnerStruct is, List<Integer> li, ByteArrayRef ba) {
+      String st, MyTestInnerStruct is, List<Integer> li, byte[] ba) {
     myByte = b;
     myShort = s;
     myInt = i;

Modified: hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/binarysortable/TestBinarySortableSerDe.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/binarysortable/TestBinarySortableSerDe.java?rev=1363427&r1=1363426&r2=1363427&view=diff
==============================================================================
--- hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/binarysortable/TestBinarySortableSerDe.java
(original)
+++ hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/binarysortable/TestBinarySortableSerDe.java
Thu Jul 19 17:06:24 2012
@@ -29,7 +29,6 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.hive.serde.Constants;
 import org.apache.hadoop.hive.serde2.SerDe;
 import org.apache.hadoop.hive.serde2.SerDeUtils;
-import org.apache.hadoop.hive.serde2.lazy.ByteArrayRef;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory.ObjectInspectorOptions;
@@ -151,14 +150,12 @@ public class TestBinarySortableSerDe ext
     return result;
   }
 
-  public static ByteArrayRef getRandBA(Random r, int len){
+  public static byte[] getRandBA(Random r, int len){
     byte[] bytes = new byte[len];
     for (int j = 0; j < len; j++){
       bytes[j] = Byte.valueOf((byte) r.nextInt());
     }
-    ByteArrayRef ba = new ByteArrayRef();
-    ba.setData(bytes);
-    return ba;
+    return bytes;
   }
 
   public void testBinarySortableSerDe() throws Throwable {

Modified: hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/columnar/TestLazyBinaryColumnarSerDe.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/columnar/TestLazyBinaryColumnarSerDe.java?rev=1363427&r1=1363426&r2=1363427&view=diff
==============================================================================
--- hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/columnar/TestLazyBinaryColumnarSerDe.java
(original)
+++ hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/columnar/TestLazyBinaryColumnarSerDe.java
Thu Jul 19 17:06:24 2012
@@ -31,7 +31,6 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.hive.serde.Constants;
 import org.apache.hadoop.hive.serde2.SerDeException;
 import org.apache.hadoop.hive.serde2.SerDeUtils;
-import org.apache.hadoop.hive.serde2.lazy.ByteArrayRef;
 import org.apache.hadoop.hive.serde2.objectinspector.CrossMapEqualComparer;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory;
@@ -59,7 +58,7 @@ public class TestLazyBinaryColumnarSerDe
     Float mFloat;
     Double mDouble;
     String mString;
-    ByteArrayRef mBA;
+    byte[] mBA;
     List<InnerStruct> mArray;
     Map<String, InnerStruct> mMap;
     InnerStruct mStruct;
@@ -83,9 +82,7 @@ public class TestLazyBinaryColumnarSerDe
     outerStruct.mFloat = 5.01f;
     outerStruct.mDouble = 6.001d;
     outerStruct.mString = "seven";
-    ByteArrayRef ba = new ByteArrayRef();
-    ba.setData(new byte[]{'2'});
-    outerStruct.mBA =  ba;
+    outerStruct.mBA =  new byte[]{'2'};
     InnerStruct is1 = new InnerStruct(8, 9l);
     InnerStruct is2 = new InnerStruct(10, 11l);
     outerStruct.mArray = new ArrayList<InnerStruct>(2);
@@ -96,7 +93,7 @@ public class TestLazyBinaryColumnarSerDe
     outerStruct.mMap.put(new String("fifteen"), new InnerStruct(16, 17l));
     outerStruct.mStruct = new InnerStruct(18, 19l);
     BytesRefArrayWritable braw = (BytesRefArrayWritable) serde.serialize(outerStruct, oi);
-    
+
     ObjectInspector out_oi = serde.getObjectInspector();
     Object out_o = serde.deserialize(braw);
     if (0 != ObjectInspectorUtils.compare(outerStruct, oi, out_o, out_oi, new CrossMapEqualComparer()))
{
@@ -126,14 +123,12 @@ public class TestLazyBinaryColumnarSerDe
     outerStruct.mFloat = 5005.01f;
     outerStruct.mDouble = 6006.001d;
     outerStruct.mString = "";
-    ByteArrayRef ba = new ByteArrayRef();
-    ba.setData(new byte[]{'a'});
-    outerStruct.mBA = ba;
+    outerStruct.mBA = new byte[]{'a'};
     outerStruct.mArray = new ArrayList<InnerStruct>();
     outerStruct.mMap = new TreeMap<String, InnerStruct>();
     outerStruct.mStruct = new InnerStruct(180018, 190019l);
     BytesRefArrayWritable braw = (BytesRefArrayWritable) serde.serialize(outerStruct, oi);
-    
+
     ObjectInspector out_oi = serde.getObjectInspector();
     Object out_o = serde.deserialize(braw);
     if (0 != ObjectInspectorUtils.compare(outerStruct, oi, out_o, out_oi, new SimpleMapEqualComparer()))
{
@@ -163,9 +158,7 @@ public class TestLazyBinaryColumnarSerDe
     outerStruct.mFloat = 5005.01f;
     outerStruct.mDouble = 6006.001d;
     outerStruct.mString = "";
-    ByteArrayRef ba = new ByteArrayRef();
-    ba.setData(new byte[]{});
-    outerStruct.mBA = ba;
+    outerStruct.mBA = new byte[]{};
     outerStruct.mArray = new ArrayList<InnerStruct>();
     outerStruct.mMap = new TreeMap<String, InnerStruct>();
     outerStruct.mStruct = new InnerStruct(180018, 190019l);
@@ -192,7 +185,7 @@ public class TestLazyBinaryColumnarSerDe
 
     OuterStruct outerStruct = new OuterStruct();
     BytesRefArrayWritable braw = (BytesRefArrayWritable) serde.serialize(outerStruct, oi);
-    
+
     ObjectInspector out_oi = serde.getObjectInspector();
     Object out_o = serde.deserialize(braw);
     if (0 != ObjectInspectorUtils.compare(outerStruct, oi, out_o, out_oi, new SimpleMapEqualComparer()))
{
@@ -203,7 +196,7 @@ public class TestLazyBinaryColumnarSerDe
       fail("Deserialized object does not compare");
     }
   }
-  
+
   public void testSerDeInnerNulls() throws SerDeException {
     StructObjectInspector oi = (StructObjectInspector) ObjectInspectorFactory
         .getReflectionObjectInspector(OuterStruct.class, ObjectInspectorOptions.JAVA);
@@ -222,9 +215,7 @@ public class TestLazyBinaryColumnarSerDe
     outerStruct.mFloat = 5.01f;
     outerStruct.mDouble = 6.001d;
     outerStruct.mString = "seven";
-    ByteArrayRef ba = new ByteArrayRef();
-    ba.setData(new byte[]{'3'});
-    outerStruct.mBA = ba;
+    outerStruct.mBA = new byte[]{'3'};
     InnerStruct is1 = new InnerStruct(null, 9l);
     InnerStruct is2 = new InnerStruct(10, null);
     outerStruct.mArray = new ArrayList<InnerStruct>(2);
@@ -235,7 +226,7 @@ public class TestLazyBinaryColumnarSerDe
     outerStruct.mMap.put(new String("fifteen"), null);
     outerStruct.mStruct = new InnerStruct(null, null);
     BytesRefArrayWritable braw = (BytesRefArrayWritable) serde.serialize(outerStruct, oi);
-    
+
     ObjectInspector out_oi = serde.getObjectInspector();
     Object out_o = serde.deserialize(braw);
     if (0 != ObjectInspectorUtils.compare(outerStruct, oi, out_o, out_oi, new SimpleMapEqualComparer()))
{

Modified: hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/lazybinary/MyTestClassBigger.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/lazybinary/MyTestClassBigger.java?rev=1363427&r1=1363426&r2=1363427&view=diff
==============================================================================
--- hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/lazybinary/MyTestClassBigger.java
(original)
+++ hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/lazybinary/MyTestClassBigger.java
Thu Jul 19 17:06:24 2012
@@ -21,7 +21,6 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.hadoop.hive.serde2.binarysortable.MyTestInnerStruct;
-import org.apache.hadoop.hive.serde2.lazy.ByteArrayRef;
 
 /**
  * MyTestClassBigger.
@@ -37,7 +36,7 @@ public class MyTestClassBigger {
   String myString;
   MyTestInnerStruct myStruct;
   List<Integer> myList;
-  ByteArrayRef myBA;
+  byte[] myBA;
   Map<String, List<MyTestInnerStruct>> myMap;
 
   public MyTestClassBigger() {
@@ -45,7 +44,7 @@ public class MyTestClassBigger {
 
   public MyTestClassBigger(Byte b, Short s, Integer i, Long l, Float f,
       Double d, String st, MyTestInnerStruct is, List<Integer> li,
-      ByteArrayRef ba, Map<String, List<MyTestInnerStruct>> mp) {
+      byte[] ba, Map<String, List<MyTestInnerStruct>> mp) {
     myByte = b;
     myShort = s;
     myInt = i;

Modified: hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/lazybinary/TestLazyBinarySerDe.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/lazybinary/TestLazyBinarySerDe.java?rev=1363427&r1=1363426&r2=1363427&view=diff
==============================================================================
--- hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/lazybinary/TestLazyBinarySerDe.java
(original)
+++ hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/lazybinary/TestLazyBinarySerDe.java
Thu Jul 19 17:06:24 2012
@@ -204,7 +204,7 @@ public class TestLazyBinarySerDe extends
           .nextInt(5) - 2, r.nextInt(5) - 2);
       List<Integer> li = randField > 8 ? null : TestBinarySortableSerDe
           .getRandIntegerArray(r);
-      ByteArrayRef ba  = TestBinarySortableSerDe.getRandBA(r, itest);
+      byte[] ba  = TestBinarySortableSerDe.getRandBA(r, itest);
       Map<String, List<MyTestInnerStruct>> mp = new HashMap<String, List<MyTestInnerStruct>>();
       String key = TestBinarySortableSerDe.getRandString(r);
       List<MyTestInnerStruct> value = randField > 10 ? null
@@ -271,7 +271,7 @@ public class TestLazyBinarySerDe extends
           .nextInt(5) - 2, r.nextInt(5) - 2);
       List<Integer> li = randField > 8 ? null : TestBinarySortableSerDe
           .getRandIntegerArray(r);
-      ByteArrayRef ba = TestBinarySortableSerDe.getRandBA(r, itest);
+      byte[] ba = TestBinarySortableSerDe.getRandBA(r, itest);
       MyTestClass input = new MyTestClass(b, s, n, l, f, d, st, is, li, ba);
       BytesWritable bw = (BytesWritable) serde1.serialize(input, rowOI1);
       Object output = serde2.deserialize(bw);
@@ -326,7 +326,7 @@ public class TestLazyBinarySerDe extends
           .nextInt(5) - 2, r.nextInt(5) - 2);
       List<Integer> li = randField > 8 ? null : TestBinarySortableSerDe
           .getRandIntegerArray(r);
-      ByteArrayRef ba = TestBinarySortableSerDe.getRandBA(r, itest);
+      byte[] ba = TestBinarySortableSerDe.getRandBA(r, itest);
       MyTestClass input = new MyTestClass(b, s, n, l, f, d, st, is, li,ba);
       BytesWritable bw = (BytesWritable) serde1.serialize(input, rowOI1);
       Object output = serde2.deserialize(bw);
@@ -499,7 +499,7 @@ public class TestLazyBinarySerDe extends
             .nextInt(5) - 2, r.nextInt(5) - 2);
         List<Integer> li = randField > 8 ? null : TestBinarySortableSerDe
             .getRandIntegerArray(r);
-        ByteArrayRef ba = TestBinarySortableSerDe.getRandBA(r, i);
+        byte[] ba = TestBinarySortableSerDe.getRandBA(r, i);
         MyTestClass t = new MyTestClass(b, s, n, l, f, d, st, is, li, ba);
         rows[i] = t;
       }
@@ -541,7 +541,7 @@ public class TestLazyBinarySerDe extends
   }
 
   /**
-   * Test to see if ByteArrayRef with correct contents is generated by
+   * Test to see if byte[] with correct contents is generated by
    * JavaBinaryObjectInspector from input BytesWritable
    * @throws Throwable
    */
@@ -552,16 +552,16 @@ public class TestLazyBinarySerDe extends
     JavaBinaryObjectInspector binInspector =
         PrimitiveObjectInspectorFactory.javaByteArrayObjectInspector;
 
-    //convert BytesWritable to ByteArrayRef
-    ByteArrayRef outBARef = binInspector.set(null, bW);
+    //convert BytesWritable to byte][
+    byte[] outBARef = binInspector.set(null, bW);
 
     assertTrue("compare input and output BAs",
-        Arrays.equals(inpBArray, outBARef.getData()));
+        Arrays.equals(inpBArray, outBARef));
   }
 
 
   /**
-   * Test to see if ByteArrayRef with correct contents is generated by
+   * Test to see if byte[] with correct contents is generated by
    * WritableBinaryObjectInspector from input BytesWritable
    * @throws Throwable
    */
@@ -572,15 +572,15 @@ public class TestLazyBinarySerDe extends
     WritableBinaryObjectInspector writableBinInsp =
         PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
 
-    //convert BytesWritable to ByteArrayRef
-    ByteArrayRef outBARef = writableBinInsp.getPrimitiveJavaObject(bW);
+    //convert BytesWritable to byte[]
+    byte[] outBARef = writableBinInsp.getPrimitiveJavaObject(bW);
 
     assertTrue("compare input and output BAs",
-        Arrays.equals(inpBArray, outBARef.getData()));
+        Arrays.equals(inpBArray, outBARef));
   }
 
   /**
-   * Test to see if ByteArrayRef with correct contents is generated by
+   * Test to see if byte[] with correct contents is generated by
    * LazyBinaryObjectInspector from input BytesWritable
    * @throws Throwable
    */
@@ -597,11 +597,11 @@ public class TestLazyBinarySerDe extends
     LazyBinary lazyBin = (LazyBinary) LazyFactory.createLazyObject(binInspector);
     lazyBin.init(inpBARef, 0, inpBArray.length);
 
-    //use inspector to get a ByteArrayRef out of LazyBinary
-    ByteArrayRef outBARef = (ByteArrayRef) binInspector.getPrimitiveJavaObject(lazyBin);
+    //use inspector to get a byte[] out of LazyBinary
+    byte[] outBARef = (byte[]) binInspector.getPrimitiveJavaObject(lazyBin);
 
     assertTrue("compare input and output BAs",
-        Arrays.equals(inpBArray, outBARef.getData()));
+        Arrays.equals(inpBArray, outBARef));
 
   }
 

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=1363427&r1=1363426&r2=1363427&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 Jul 19 17:06:24 2012
@@ -27,7 +27,6 @@ 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;
@@ -89,7 +88,7 @@ public class TestStandardObjectInspector
       doTestStandardPrimitiveObjectInspector(FloatWritable.class, Float.class);
       doTestStandardPrimitiveObjectInspector(DoubleWritable.class, Double.class);
       doTestStandardPrimitiveObjectInspector(Text.class, String.class);
-      doTestStandardPrimitiveObjectInspector(BytesWritable.class, ByteArrayRef.class);
+      doTestStandardPrimitiveObjectInspector(BytesWritable.class, byte[].class);
     } catch (Throwable e) {
       e.printStackTrace();
       throw e;
@@ -141,9 +140,7 @@ 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);
+      doTestJavaPrimitiveObjectInspector(BytesWritable.class, byte[].class, new byte[]{'3'});
 
     } catch (Throwable e) {
       e.printStackTrace();



Mime
View raw message