Index: contrib/src/java/org/apache/hadoop/hive/contrib/util/typedbytes/TypedBytesWritableOutput.java =================================================================== --- contrib/src/java/org/apache/hadoop/hive/contrib/util/typedbytes/TypedBytesWritableOutput.java (revision 1597349) +++ contrib/src/java/org/apache/hadoop/hive/contrib/util/typedbytes/TypedBytesWritableOutput.java (working copy) @@ -44,7 +44,6 @@ import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.WritableComparable; import org.apache.hadoop.io.WritableUtils; -import org.apache.hadoop.record.Record; /** * Provides functionality for writing Writable objects as typed bytes. @@ -139,8 +138,6 @@ writeMap((MapWritable) w); } else if (w instanceof SortedMapWritable) { writeSortedMap((SortedMapWritable) w); - } else if (w instanceof Record) { - writeRecord((Record) w); } else if (w instanceof NullWritable || w == null) { writeNull(); } else { @@ -221,10 +218,6 @@ } } - public void writeRecord(Record r) throws IOException { - r.serialize(TypedBytesRecordOutput.get(out)); - } - public void writeNull() throws IOException { out.writeNull(); } Index: contrib/src/java/org/apache/hadoop/hive/contrib/util/typedbytes/TypedBytesRecordInput.java =================================================================== --- contrib/src/java/org/apache/hadoop/hive/contrib/util/typedbytes/TypedBytesRecordInput.java (revision 1597349) +++ contrib/src/java/org/apache/hadoop/hive/contrib/util/typedbytes/TypedBytesRecordInput.java (working copy) @@ -21,14 +21,10 @@ import java.io.DataInput; import java.io.IOException; -import org.apache.hadoop.record.Buffer; -import org.apache.hadoop.record.Index; -import org.apache.hadoop.record.RecordInput; - /** * Serializer for records that writes typed bytes. */ -public class TypedBytesRecordInput implements RecordInput { +public class TypedBytesRecordInput { private TypedBytesInput in; @@ -49,7 +45,7 @@ /** * Get a thread-local typed bytes record input for the supplied * {@link TypedBytesInput}. - * + * * @param in * typed bytes input object * @return typed bytes record input corresponding to the supplied @@ -64,7 +60,7 @@ /** * Get a thread-local typed bytes record input for the supplied * {@link DataInput}. - * + * * @param in * data input object * @return typed bytes record input corresponding to the supplied @@ -89,11 +85,6 @@ return in.readBool(); } - public Buffer readBuffer(String tag) throws IOException { - in.skipType(); - return new Buffer(in.readBytes()); - } - public byte readByte(String tag) throws IOException { in.skipType(); return in.readByte(); @@ -128,16 +119,6 @@ in.skipType(); } - public Index startVector(String tag) throws IOException { - in.skipType(); - return new TypedBytesIndex(in.readVectorHeader()); - } - - public Index startMap(String tag) throws IOException { - in.skipType(); - return new TypedBytesIndex(in.readMapHeader()); - } - public void endRecord(String tag) throws IOException { } @@ -146,21 +127,4 @@ public void endMap(String tag) throws IOException { } - - private static final class TypedBytesIndex implements Index { - private int nelems; - - private TypedBytesIndex(int nelems) { - this.nelems = nelems; - } - - public boolean done() { - return (nelems <= 0); - } - - public void incr() { - nelems--; - } - } - } Index: contrib/src/java/org/apache/hadoop/hive/contrib/util/typedbytes/TypedBytesInput.java =================================================================== --- contrib/src/java/org/apache/hadoop/hive/contrib/util/typedbytes/TypedBytesInput.java (revision 1597349) +++ contrib/src/java/org/apache/hadoop/hive/contrib/util/typedbytes/TypedBytesInput.java (working copy) @@ -26,7 +26,6 @@ import java.util.TreeMap; import org.apache.hadoop.io.WritableUtils; -import org.apache.hadoop.record.Buffer; /** * Provides functionality for reading typed bytes. @@ -51,7 +50,7 @@ /** * Get a thread-local typed bytes input for the supplied {@link DataInput}. - * + * * @param in * data input object * @return typed bytes input corresponding to the supplied {@link DataInput}. @@ -71,7 +70,7 @@ * Reads a typed bytes sequence and converts it to a Java object. The first * byte is interpreted as a type code, and then the right number of subsequent * bytes are read depending on the obtained type. - * + * * @return the obtained object or null when the end of the file is reached * @throws IOException */ @@ -82,9 +81,7 @@ } catch (EOFException eof) { return null; } - if (code == Type.BYTES.code) { - return new Buffer(readBytes()); - } else if (code == Type.BYTE.code) { + if (code == Type.BYTE.code) { return readByte(); } else if (code == Type.BOOL.code) { return readBool(); @@ -108,8 +105,6 @@ return readMap(); } else if (code == Type.MARKER.code) { return null; - } else if (50 <= code && code <= 200) { // application-specific typecodes - return new Buffer(readBytes()); } else { throw new RuntimeException("unknown type"); } @@ -119,7 +114,7 @@ * Reads a typed bytes sequence. The first byte is interpreted as a type code, * and then the right number of subsequent bytes are read depending on the * obtained type. - * + * * @return the obtained typed bytes sequence or null when the end of the file * is reached * @throws IOException @@ -147,12 +142,6 @@ return readRawDouble(); } else if (code == Type.STRING.code) { return readRawString(); - } else if (code == Type.VECTOR.code) { - return readRawVector(); - } else if (code == Type.LIST.code) { - return readRawList(); - } else if (code == Type.MAP.code) { - return readRawMap(); } else if (code == Type.MARKER.code) { return null; } else if (50 <= code && code <= 200) { // application-specific typecodes @@ -164,7 +153,7 @@ /** * Reads a type byte and returns the corresponding {@link Type}. - * + * * @return the obtained Type or null when the end of the file is reached * @throws IOException */ @@ -185,7 +174,7 @@ /** * Skips a type byte. - * + * * @return true iff the end of the file was not reached * @throws IOException */ @@ -200,7 +189,7 @@ /** * Reads the bytes following a Type.BYTES code. - * + * * @return the obtained bytes sequence * @throws IOException */ @@ -213,7 +202,7 @@ /** * Reads the raw bytes following a Type.BYTES code. - * + * * @return the obtained bytes sequence * @throws IOException */ @@ -231,7 +220,7 @@ /** * Reads the byte following a Type.BYTE code. - * + * * @return the obtained byte * @throws IOException */ @@ -241,7 +230,7 @@ /** * Reads the raw byte following a Type.BYTE code. - * + * * @return the obtained byte * @throws IOException */ @@ -254,7 +243,7 @@ /** * Reads the boolean following a Type.BOOL code. - * + * * @return the obtained boolean * @throws IOException */ @@ -264,7 +253,7 @@ /** * Reads the raw bytes following a Type.BOOL code. - * + * * @return the obtained bytes sequence * @throws IOException */ @@ -277,7 +266,7 @@ /** * Reads the integer following a Type.INT code. - * + * * @return the obtained integer * @throws IOException */ @@ -287,7 +276,7 @@ /** * Reads the short following a Type.SHORT code. - * + * * @return the obtained short * @throws IOException */ @@ -297,7 +286,7 @@ /** * Reads the raw bytes following a Type.INT code. - * + * * @return the obtained bytes sequence * @throws IOException */ @@ -310,7 +299,7 @@ /** * Reads the long following a Type.LONG code. - * + * * @return the obtained long * @throws IOException */ @@ -320,7 +309,7 @@ /** * Reads the raw bytes following a Type.LONG code. - * + * * @return the obtained bytes sequence * @throws IOException */ @@ -333,7 +322,7 @@ /** * Reads the float following a Type.FLOAT code. - * + * * @return the obtained float * @throws IOException */ @@ -343,7 +332,7 @@ /** * Reads the raw bytes following a Type.FLOAT code. - * + * * @return the obtained bytes sequence * @throws IOException */ @@ -356,7 +345,7 @@ /** * Reads the double following a Type.DOUBLE code. - * + * * @return the obtained double * @throws IOException */ @@ -366,7 +355,7 @@ /** * Reads the raw bytes following a Type.DOUBLE code. - * + * * @return the obtained bytes sequence * @throws IOException */ @@ -379,7 +368,7 @@ /** * Reads the string following a Type.STRING code. - * + * * @return the obtained string * @throws IOException */ @@ -389,7 +378,7 @@ /** * Reads the raw bytes following a Type.STRING code. - * + * * @return the obtained bytes sequence * @throws IOException */ @@ -407,7 +396,7 @@ /** * Reads the vector following a Type.VECTOR code. - * + * * @return the obtained vector * @throws IOException */ @@ -422,26 +411,8 @@ } /** - * Reads the raw bytes following a Type.VECTOR code. - * - * @return the obtained bytes sequence - * @throws IOException - */ - public byte[] readRawVector() throws IOException { - Buffer buffer = new Buffer(); - int length = readVectorHeader(); - buffer.append(new byte[] {(byte) Type.VECTOR.code, - (byte) (0xff & (length >> 24)), (byte) (0xff & (length >> 16)), - (byte) (0xff & (length >> 8)), (byte) (0xff & length)}); - for (int i = 0; i < length; i++) { - buffer.append(readRaw()); - } - return buffer.get(); - } - - /** * Reads the header following a Type.VECTOR code. - * + * * @return the number of elements in the vector * @throws IOException */ @@ -451,7 +422,7 @@ /** * Reads the list following a Type.LIST code. - * + * * @return the obtained list * @throws IOException */ @@ -467,25 +438,8 @@ } /** - * Reads the raw bytes following a Type.LIST code. - * - * @return the obtained bytes sequence - * @throws IOException - */ - public byte[] readRawList() throws IOException { - Buffer buffer = new Buffer(new byte[] {(byte) Type.LIST.code}); - byte[] bytes = readRaw(); - while (bytes != null) { - buffer.append(bytes); - bytes = readRaw(); - } - buffer.append(new byte[] {(byte) Type.MARKER.code}); - return buffer.get(); - } - - /** * Reads the map following a Type.MAP code. - * + * * @return the obtained map * @throws IOException */ @@ -502,27 +456,8 @@ } /** - * Reads the raw bytes following a Type.MAP code. - * - * @return the obtained bytes sequence - * @throws IOException - */ - public byte[] readRawMap() throws IOException { - Buffer buffer = new Buffer(); - int length = readMapHeader(); - buffer.append(new byte[] {(byte) Type.MAP.code, - (byte) (0xff & (length >> 24)), (byte) (0xff & (length >> 16)), - (byte) (0xff & (length >> 8)), (byte) (0xff & length)}); - for (int i = 0; i < length; i++) { - buffer.append(readRaw()); - buffer.append(readRaw()); - } - return buffer.get(); - } - - /** * Reads the header following a Type.MAP code. - * + * * @return the number of key-value pairs in the map * @throws IOException */ Index: contrib/src/java/org/apache/hadoop/hive/contrib/util/typedbytes/TypedBytesRecordOutput.java =================================================================== --- contrib/src/java/org/apache/hadoop/hive/contrib/util/typedbytes/TypedBytesRecordOutput.java (revision 1597349) +++ contrib/src/java/org/apache/hadoop/hive/contrib/util/typedbytes/TypedBytesRecordOutput.java (working copy) @@ -23,14 +23,10 @@ import java.util.ArrayList; import java.util.TreeMap; -import org.apache.hadoop.record.Buffer; -import org.apache.hadoop.record.Record; -import org.apache.hadoop.record.RecordOutput; - /** * Deserialized for records that reads typed bytes. */ -public class TypedBytesRecordOutput implements RecordOutput { +public class TypedBytesRecordOutput { private TypedBytesOutput out; @@ -51,7 +47,7 @@ /** * Get a thread-local typed bytes record input for the supplied * {@link TypedBytesOutput}. - * + * * @param out * typed bytes output object * @return typed bytes record output corresponding to the supplied @@ -66,7 +62,7 @@ /** * Get a thread-local typed bytes record output for the supplied * {@link DataOutput}. - * + * * @param out * data output object * @return typed bytes record output corresponding to the supplied @@ -90,10 +86,6 @@ out.writeBool(b); } - public void writeBuffer(Buffer buf, String tag) throws IOException { - out.writeBytes(buf.get()); - } - public void writeByte(byte b, String tag) throws IOException { out.writeByte(b); } @@ -118,10 +110,6 @@ out.writeString(s); } - public void startRecord(Record r, String tag) throws IOException { - out.writeListHeader(); - } - public void startVector(ArrayList v, String tag) throws IOException { out.writeVectorHeader(v.size()); } @@ -130,10 +118,6 @@ out.writeMapHeader(m.size()); } - public void endRecord(Record r, String tag) throws IOException { - out.writeListFooter(); - } - public void endVector(ArrayList v, String tag) throws IOException { } Index: contrib/src/java/org/apache/hadoop/hive/contrib/util/typedbytes/TypedBytesOutput.java =================================================================== --- contrib/src/java/org/apache/hadoop/hive/contrib/util/typedbytes/TypedBytesOutput.java (revision 1597349) +++ contrib/src/java/org/apache/hadoop/hive/contrib/util/typedbytes/TypedBytesOutput.java (working copy) @@ -27,7 +27,6 @@ import java.util.Map.Entry; import org.apache.hadoop.io.WritableUtils; -import org.apache.hadoop.record.Buffer; /** * Provides functionality for writing typed bytes. @@ -77,9 +76,7 @@ * @throws IOException */ public void write(Object obj) throws IOException { - if (obj instanceof Buffer) { - writeBytes(((Buffer) obj).get()); - } else if (obj instanceof Byte) { + if (obj instanceof Byte) { writeByte((Byte) obj); } else if (obj instanceof Boolean) { writeBool((Boolean) obj);