HBASE-16705 Eliminate long to Long auto boxing in LongComparator. (binlijin)

This commit is contained in:
anoopsamjohn 2016-09-26 11:11:52 +05:30
parent b7e0e15787
commit da37fd9cdc
1 changed files with 17 additions and 17 deletions

View File

@ -20,8 +20,6 @@ package org.apache.hadoop.hbase.filter;
import java.nio.ByteBuffer;
import com.google.protobuf.InvalidProtocolBufferException;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
@ -29,30 +27,32 @@ import org.apache.hadoop.hbase.protobuf.generated.ComparatorProtos;
import org.apache.hadoop.hbase.util.ByteBufferUtils;
import org.apache.hadoop.hbase.util.Bytes;
import com.google.protobuf.InvalidProtocolBufferException;
/**
* A long comparator which numerical compares against the specified byte array
*/
@InterfaceAudience.Public
@InterfaceStability.Stable
public class LongComparator extends ByteArrayComparable {
private Long longValue;
private long longValue;
public LongComparator(long value) {
super(Bytes.toBytes(value));
this.longValue = value;
}
public LongComparator(long value) {
super(Bytes.toBytes(value));
this.longValue = value;
}
@Override
public int compareTo(byte[] value, int offset, int length) {
Long that = Bytes.toLong(value, offset, length);
return this.longValue.compareTo(that);
}
@Override
public int compareTo(byte[] value, int offset, int length) {
long that = Bytes.toLong(value, offset, length);
return Long.compare(longValue, that);
}
@Override
public int compareTo(ByteBuffer value, int offset, int length) {
Long that = ByteBufferUtils.toLong(value, offset);
return this.longValue.compareTo(that);
}
@Override
public int compareTo(ByteBuffer value, int offset, int length) {
long that = ByteBufferUtils.toLong(value, offset);
return Long.compare(longValue, that);
}
/**
* @return The comparator serialized using pb