Index: serde/src/test/org/apache/hadoop/hive/serde2/binarysortable/TestBinarySortableSerDe.java =================================================================== --- serde/src/test/org/apache/hadoop/hive/serde2/binarysortable/TestBinarySortableSerDe.java (revision 1360908) +++ serde/src/test/org/apache/hadoop/hive/serde2/binarysortable/TestBinarySortableSerDe.java (working copy) @@ -29,7 +29,6 @@ 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 @@ 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 { Index: serde/src/test/org/apache/hadoop/hive/serde2/binarysortable/MyTestClass.java =================================================================== --- serde/src/test/org/apache/hadoop/hive/serde2/binarysortable/MyTestClass.java (revision 1360908) +++ serde/src/test/org/apache/hadoop/hive/serde2/binarysortable/MyTestClass.java (working copy) @@ -19,8 +19,6 @@ import java.util.List; -import org.apache.hadoop.hive.serde2.lazy.ByteArrayRef; - public class MyTestClass { Byte myByte; Short myShort; @@ -31,13 +29,13 @@ String myString; MyTestInnerStruct myStruct; List 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 li, ByteArrayRef ba) { + String st, MyTestInnerStruct is, List li, byte[] ba) { myByte = b; myShort = s; myInt = i; Index: serde/src/test/org/apache/hadoop/hive/serde2/columnar/TestLazyBinaryColumnarSerDe.java =================================================================== --- serde/src/test/org/apache/hadoop/hive/serde2/columnar/TestLazyBinaryColumnarSerDe.java (revision 1360908) +++ serde/src/test/org/apache/hadoop/hive/serde2/columnar/TestLazyBinaryColumnarSerDe.java (working copy) @@ -31,7 +31,6 @@ 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 @@ Float mFloat; Double mDouble; String mString; - ByteArrayRef mBA; + byte[] mBA; List mArray; Map mMap; InnerStruct mStruct; @@ -83,9 +82,7 @@ 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(2); @@ -96,7 +93,7 @@ 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 @@ 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(); outerStruct.mMap = new TreeMap(); 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 @@ 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(); outerStruct.mMap = new TreeMap(); outerStruct.mStruct = new InnerStruct(180018, 190019l); @@ -192,7 +185,7 @@ 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 @@ fail("Deserialized object does not compare"); } } - + public void testSerDeInnerNulls() throws SerDeException { StructObjectInspector oi = (StructObjectInspector) ObjectInspectorFactory .getReflectionObjectInspector(OuterStruct.class, ObjectInspectorOptions.JAVA); @@ -222,9 +215,7 @@ 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(2); @@ -235,7 +226,7 @@ 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())) { Index: serde/src/test/org/apache/hadoop/hive/serde2/TestStatsSerde.java =================================================================== --- serde/src/test/org/apache/hadoop/hive/serde2/TestStatsSerde.java (revision 1360908) +++ serde/src/test/org/apache/hadoop/hive/serde2/TestStatsSerde.java (working copy) @@ -32,7 +32,6 @@ 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 @@ .nextInt(5) - 2, r.nextInt(5) - 2); List 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; } Index: serde/src/test/org/apache/hadoop/hive/serde2/lazybinary/TestLazyBinarySerDe.java =================================================================== --- serde/src/test/org/apache/hadoop/hive/serde2/lazybinary/TestLazyBinarySerDe.java (revision 1360908) +++ serde/src/test/org/apache/hadoop/hive/serde2/lazybinary/TestLazyBinarySerDe.java (working copy) @@ -204,7 +204,7 @@ .nextInt(5) - 2, r.nextInt(5) - 2); List li = randField > 8 ? null : TestBinarySortableSerDe .getRandIntegerArray(r); - ByteArrayRef ba = TestBinarySortableSerDe.getRandBA(r, itest); + byte[] ba = TestBinarySortableSerDe.getRandBA(r, itest); Map> mp = new HashMap>(); String key = TestBinarySortableSerDe.getRandString(r); List value = randField > 10 ? null @@ -271,7 +271,7 @@ .nextInt(5) - 2, r.nextInt(5) - 2); List 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 @@ .nextInt(5) - 2, r.nextInt(5) - 2); List 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 @@ .nextInt(5) - 2, r.nextInt(5) - 2); List 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 @@ } /** - * 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 @@ 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 @@ 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 @@ 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)); } Index: serde/src/test/org/apache/hadoop/hive/serde2/lazybinary/MyTestClassBigger.java =================================================================== --- serde/src/test/org/apache/hadoop/hive/serde2/lazybinary/MyTestClassBigger.java (revision 1360908) +++ serde/src/test/org/apache/hadoop/hive/serde2/lazybinary/MyTestClassBigger.java (working copy) @@ -21,7 +21,6 @@ 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 @@ String myString; MyTestInnerStruct myStruct; List myList; - ByteArrayRef myBA; + byte[] myBA; Map> myMap; public MyTestClassBigger() { @@ -45,7 +44,7 @@ public MyTestClassBigger(Byte b, Short s, Integer i, Long l, Float f, Double d, String st, MyTestInnerStruct is, List li, - ByteArrayRef ba, Map> mp) { + byte[] ba, Map> mp) { myByte = b; myShort = s; myInt = i; Index: serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestStandardObjectInspectors.java =================================================================== --- serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestStandardObjectInspectors.java (revision 1360908) +++ serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestStandardObjectInspectors.java (working copy) @@ -27,7 +27,6 @@ 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 @@ 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 @@ 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(); Index: serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyUtils.java =================================================================== --- serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyUtils.java (revision 1360908) +++ serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyUtils.java (working copy) @@ -350,17 +350,13 @@ } /** - * 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() { Index: serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyBinaryObjectInspector.java =================================================================== --- serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyBinaryObjectInspector.java (revision 1360908) +++ serde/src/java/org/apache/hadoop/hive/serde2/lazy/objectinspector/primitive/LazyBinaryObjectInspector.java (working copy) @@ -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 @@ } @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 Index: serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableBinaryObjectInspector.java =================================================================== --- serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableBinaryObjectInspector.java (revision 1360908) +++ serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/SettableBinaryObjectInspector.java (working copy) @@ -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); } Index: serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/BinaryObjectInspector.java =================================================================== --- serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/BinaryObjectInspector.java (revision 1360908) +++ serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/BinaryObjectInspector.java (working copy) @@ -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); Index: serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBinaryObjectInspector.java =================================================================== --- serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBinaryObjectInspector.java (revision 1360908) +++ serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaBinaryObjectInspector.java (working copy) @@ -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 @@ } @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); } } Index: serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantBinaryObjectInspector.java =================================================================== --- serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantBinaryObjectInspector.java (revision 1360908) +++ serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantBinaryObjectInspector.java (working copy) @@ -35,6 +35,9 @@ this.value = value; } + /* + * {@inheritDoc} + */ @Override public BytesWritable getWritableConstantValue() { return value; Index: serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java =================================================================== --- serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java (revision 1360908) +++ serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java (working copy) @@ -30,7 +30,6 @@ 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 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); Index: serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorConverter.java =================================================================== --- serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorConverter.java (revision 1360908) +++ serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorConverter.java (working copy) @@ -21,7 +21,6 @@ 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 @@ 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 Index: serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableBinaryObjectInspector.java =================================================================== --- serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableBinaryObjectInspector.java (revision 1360908) +++ serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableBinaryObjectInspector.java (working copy) @@ -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 @@ } @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 @@ 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 @@ 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) {