public class WritableComparator extends Object implements RawComparator
WritableComparable
s.
This base implemenation uses the natural ordering. To define alternate
orderings, override compare(WritableComparable,WritableComparable)
.
One may optimize compare-intensive operations by overriding
compare(byte[],int,int,byte[],int,int)
. Static utility methods are
provided to assist in optimized implementations of this method.
限定符 | 构造器和说明 |
---|---|
protected |
WritableComparator(Class<? extends WritableComparable> keyClass)
Construct for a
WritableComparable implementation. |
protected |
WritableComparator(Class<? extends WritableComparable> keyClass,
boolean createInstances) |
限定符和类型 | 方法和说明 |
---|---|
int |
compare(byte[] b1,
int s1,
int l1,
byte[] b2,
int s2,
int l2)
Optimization hook.
|
int |
compare(Object a,
Object b) |
int |
compare(WritableComparable a,
WritableComparable b)
Compare two WritableComparables.
|
static int |
compareBytes(byte[] b1,
int s1,
int l1,
byte[] b2,
int s2,
int l2)
Lexicographic order of binary data.
|
static void |
define(Class c,
WritableComparator comparator)
Register an optimized comparator for a
WritableComparable
implementation. |
static WritableComparator |
get(Class<? extends WritableComparable> c)
Get a comparator for a
WritableComparable implementation. |
Class<? extends WritableComparable> |
getKeyClass()
Returns the WritableComparable implementation class.
|
static int |
hashBytes(byte[] bytes,
int length)
Compute hash for binary data.
|
static int |
hashBytes(byte[] bytes,
int offset,
int length)
Compute hash for binary data.
|
WritableComparable |
newKey()
Construct a new
WritableComparable instance. |
static double |
readDouble(byte[] bytes,
int start)
Parse a double from a byte array.
|
static float |
readFloat(byte[] bytes,
int start)
Parse a float from a byte array.
|
static int |
readInt(byte[] bytes,
int start)
Parse an integer from a byte array.
|
static long |
readLong(byte[] bytes,
int start)
Parse a long from a byte array.
|
static int |
readUnsignedShort(byte[] bytes,
int start)
Parse an unsigned short from a byte array.
|
static int |
readVInt(byte[] bytes,
int start)
Reads a zero-compressed encoded integer from a byte array and returns it.
|
static long |
readVLong(byte[] bytes,
int start)
Reads a zero-compressed encoded long from a byte array and returns it.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
equals
protected WritableComparator(Class<? extends WritableComparable> keyClass)
WritableComparable
implementation.protected WritableComparator(Class<? extends WritableComparable> keyClass, boolean createInstances)
public static WritableComparator get(Class<? extends WritableComparable> c)
WritableComparable
implementation.public static void define(Class c, WritableComparator comparator)
WritableComparable
implementation.public Class<? extends WritableComparable> getKeyClass()
public WritableComparable newKey()
WritableComparable
instance.public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2)
The default implementation reads the data into two WritableComparable
s (using Writable.readFields(DataInput)
, then calls compare(WritableComparable,WritableComparable)
.
compare
在接口中 RawComparator
public int compare(WritableComparable a, WritableComparable b)
The default implementation uses the natural ordering, calling Comparable.compareTo(Object)
.
public int compare(Object a, Object b)
compare
在接口中 Comparator
public static int compareBytes(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2)
public static int hashBytes(byte[] bytes, int offset, int length)
public static int hashBytes(byte[] bytes, int length)
public static int readUnsignedShort(byte[] bytes, int start)
public static int readInt(byte[] bytes, int start)
public static float readFloat(byte[] bytes, int start)
public static long readLong(byte[] bytes, int start)
public static double readDouble(byte[] bytes, int start)
public static long readVLong(byte[] bytes, int start) throws IOException
bytes
- byte array with decode longstart
- starting indexIOException
public static int readVInt(byte[] bytes, int start) throws IOException
bytes
- byte array with the encoded integerstart
- start indexIOException
Copyright © 2009 The Apache Software Foundation