diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/ByteWritable.java ql/src/java/org/apache/hadoop/hive/ql/exec/ByteWritable.java index d8136bd..8662245 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/ByteWritable.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/ByteWritable.java @@ -27,8 +27,10 @@ /** * ByteWritable. - * + * Looks like this has been phased out in favor of org.apache.hadoop.hive.serde2.io.ByteWritable. + * This class should eventually be removed. */ +@Deprecated public class ByteWritable implements WritableComparable { private int value; diff --git serde/src/java/org/apache/hadoop/hive/serde2/io/ByteWritable.java serde/src/java/org/apache/hadoop/hive/serde2/io/ByteWritable.java index d2aae53..50fae55 100644 --- serde/src/java/org/apache/hadoop/hive/serde2/io/ByteWritable.java +++ serde/src/java/org/apache/hadoop/hive/serde2/io/ByteWritable.java @@ -26,75 +26,18 @@ /** * ByteWritable. - * + * This class was created before the Hadoop version of this class was available, and needs to + * be kept around for backward compatibility of third-party UDFs/SerDes. We should consider + * removing this class in favor of directly using the Hadoop one in the next major release. */ -public class ByteWritable implements WritableComparable { - private byte value; - - public void write(DataOutput out) throws IOException { - out.writeByte(value); - } - - public void readFields(DataInput in) throws IOException { - value = in.readByte(); - } +public class ByteWritable extends org.apache.hadoop.io.ByteWritable { public ByteWritable(byte b) { - value = b; + super(b); } public ByteWritable() { - value = 0; - } - - public void set(byte value) { - this.value = value; - } - - public byte get() { - return value; - } - - /** Compares two ByteWritables. */ - public int compareTo(Object o) { - int thisValue = value; - int thatValue = ((ByteWritable) o).value; - return thisValue - thatValue; - } - - @Override - public boolean equals(Object o) { - if (o == null || o.getClass() != ByteWritable.class) { - return false; - } - return get() == ((ByteWritable) o).get(); - } - - @Override - public int hashCode() { - return value; - } - - @Override - public String toString() { - return String.valueOf(get()); - } - - /** A Comparator optimized for BytesWritable. */ - public static class Comparator extends WritableComparator { - public Comparator() { - super(ByteWritable.class); - } - - /** - * Compare the buffers in serialized form. - */ - @Override - public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) { - int a1 = b1[s1]; - int a2 = b2[s2]; - return a1 - a2; - } + super(); } static { // register this comparator diff --git serde/src/java/org/apache/hadoop/hive/serde2/io/DoubleWritable.java serde/src/java/org/apache/hadoop/hive/serde2/io/DoubleWritable.java index f3a2b1a..3dc1f85 100644 --- serde/src/java/org/apache/hadoop/hive/serde2/io/DoubleWritable.java +++ serde/src/java/org/apache/hadoop/hive/serde2/io/DoubleWritable.java @@ -31,75 +31,18 @@ /** * Writable for Double values. + * This class was created before the Hadoop version of this class was available, and needs to + * be kept around for backward compatibility of third-party UDFs/SerDes. We should consider + * removing this class in favor of directly using the Hadoop one in the next major release. */ -public class DoubleWritable implements WritableComparable { - - private double value = 0.0; +public class DoubleWritable extends org.apache.hadoop.io.DoubleWritable { public DoubleWritable() { - + super(); } 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 o is a DoubleWritable with the same value. - */ - @Override - public boolean equals(Object o) { - if (!(o instanceof DoubleWritable)) { - return false; - } - DoubleWritable other = (DoubleWritable) o; - return value == other.value; - } - - @Override - public int hashCode() { - long v = Double.doubleToLongBits(value); - return (int) (v ^ (v >>> 32)); - } - - public int compareTo(Object o) { - DoubleWritable other = (DoubleWritable) o; - return (value < other.value ? -1 : (value == other.value ? 0 : 1)); - } - - @Override - public String toString() { - return Double.toString(value); - } - - /** A Comparator optimized for DoubleWritable. */ - public static class Comparator extends WritableComparator { - public Comparator() { - super(DoubleWritable.class); - } - - @Override - 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)); - } + super(value); } static { // register this comparator