HADOOP-11466. FastByteComparisons: do not use UNSAFE_COMPARER on the SPARC architecture because it is slower there (Suman Somasundar via Colin P. McCabe)
This commit is contained in:
parent
a0521bc83a
commit
ee7d22e90c
|
@ -737,6 +737,10 @@ Release 2.7.0 - UNRELEASED
|
||||||
HADOOP-11327. BloomFilter#not() omits the last bit, resulting in an
|
HADOOP-11327. BloomFilter#not() omits the last bit, resulting in an
|
||||||
incorrect filter (Eric Payne via jlowe)
|
incorrect filter (Eric Payne via jlowe)
|
||||||
|
|
||||||
|
HADOOP-11466. FastByteComparisons: do not use UNSAFE_COMPARER on the SPARC
|
||||||
|
architecture because it is slower there (Suman Somasundar via Colin P.
|
||||||
|
McCabe)
|
||||||
|
|
||||||
Release 2.6.0 - 2014-11-18
|
Release 2.6.0 - 2014-11-18
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -24,6 +24,9 @@ import java.security.PrivilegedAction;
|
||||||
|
|
||||||
import sun.misc.Unsafe;
|
import sun.misc.Unsafe;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import com.google.common.primitives.Longs;
|
import com.google.common.primitives.Longs;
|
||||||
import com.google.common.primitives.UnsignedBytes;
|
import com.google.common.primitives.UnsignedBytes;
|
||||||
|
|
||||||
|
@ -33,6 +36,7 @@ import com.google.common.primitives.UnsignedBytes;
|
||||||
* class to be able to compare arrays that start at non-zero offsets.
|
* class to be able to compare arrays that start at non-zero offsets.
|
||||||
*/
|
*/
|
||||||
abstract class FastByteComparisons {
|
abstract class FastByteComparisons {
|
||||||
|
static final Log LOG = LogFactory.getLog(FastByteComparisons.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lexicographically compare two byte arrays.
|
* Lexicographically compare two byte arrays.
|
||||||
|
@ -71,6 +75,13 @@ abstract class FastByteComparisons {
|
||||||
* implementation if unable to do so.
|
* implementation if unable to do so.
|
||||||
*/
|
*/
|
||||||
static Comparer<byte[]> getBestComparer() {
|
static Comparer<byte[]> getBestComparer() {
|
||||||
|
if (System.getProperty("os.arch").equals("sparc")) {
|
||||||
|
if (LOG.isTraceEnabled()) {
|
||||||
|
LOG.trace("Lexicographical comparer selected for "
|
||||||
|
+ "byte aligned system architecture");
|
||||||
|
}
|
||||||
|
return lexicographicalComparerJavaImpl();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Class<?> theClass = Class.forName(UNSAFE_COMPARER_NAME);
|
Class<?> theClass = Class.forName(UNSAFE_COMPARER_NAME);
|
||||||
|
|
||||||
|
@ -78,8 +89,16 @@ abstract class FastByteComparisons {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Comparer<byte[]> comparer =
|
Comparer<byte[]> comparer =
|
||||||
(Comparer<byte[]>) theClass.getEnumConstants()[0];
|
(Comparer<byte[]>) theClass.getEnumConstants()[0];
|
||||||
|
if (LOG.isTraceEnabled()) {
|
||||||
|
LOG.trace("Unsafe comparer selected for "
|
||||||
|
+ "byte unaligned system architecture");
|
||||||
|
}
|
||||||
return comparer;
|
return comparer;
|
||||||
} catch (Throwable t) { // ensure we really catch *everything*
|
} catch (Throwable t) { // ensure we really catch *everything*
|
||||||
|
if (LOG.isTraceEnabled()) {
|
||||||
|
LOG.trace(t.getMessage());
|
||||||
|
LOG.trace("Lexicographical comparer selected");
|
||||||
|
}
|
||||||
return lexicographicalComparerJavaImpl();
|
return lexicographicalComparerJavaImpl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,4 +253,4 @@ abstract class FastByteComparisons {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue