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 java.nio.ByteBuffer;
import com.google.protobuf.InvalidProtocolBufferException;
import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.hbase.exceptions.DeserializationException; import org.apache.hadoop.hbase.exceptions.DeserializationException;
@ -29,13 +27,15 @@ import org.apache.hadoop.hbase.protobuf.generated.ComparatorProtos;
import org.apache.hadoop.hbase.util.ByteBufferUtils; import org.apache.hadoop.hbase.util.ByteBufferUtils;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import com.google.protobuf.InvalidProtocolBufferException;
/** /**
* A long comparator which numerical compares against the specified byte array * A long comparator which numerical compares against the specified byte array
*/ */
@InterfaceAudience.Public @InterfaceAudience.Public
@InterfaceStability.Stable @InterfaceStability.Stable
public class LongComparator extends ByteArrayComparable { public class LongComparator extends ByteArrayComparable {
private Long longValue; private long longValue;
public LongComparator(long value) { public LongComparator(long value) {
super(Bytes.toBytes(value)); super(Bytes.toBytes(value));
@ -44,14 +44,14 @@ public class LongComparator extends ByteArrayComparable {
@Override @Override
public int compareTo(byte[] value, int offset, int length) { public int compareTo(byte[] value, int offset, int length) {
Long that = Bytes.toLong(value, offset, length); long that = Bytes.toLong(value, offset, length);
return this.longValue.compareTo(that); return Long.compare(longValue, that);
} }
@Override @Override
public int compareTo(ByteBuffer value, int offset, int length) { public int compareTo(ByteBuffer value, int offset, int length) {
Long that = ByteBufferUtils.toLong(value, offset); long that = ByteBufferUtils.toLong(value, offset);
return this.longValue.compareTo(that); return Long.compare(longValue, that);
} }
/** /**