org.apache.hadoop.hbase
Class KeyValue.KeyComparator

java.lang.Object
  extended by org.apache.hadoop.hbase.KeyValue.KeyComparator
All Implemented Interfaces:
Comparator<byte[]>, KeyValue.SamePrefixComparator<byte[]>, org.apache.hadoop.io.RawComparator<byte[]>
Direct Known Subclasses:
KeyValue.MetaKeyComparator
Enclosing class:
KeyValue

public static class KeyValue.KeyComparator
extends Object
implements org.apache.hadoop.io.RawComparator<byte[]>, KeyValue.SamePrefixComparator<byte[]>

Compare key portion of a KeyValue.


Constructor Summary
KeyValue.KeyComparator()
           
 
Method Summary
 int compare(byte[] left, byte[] right)
           
 int compare(byte[] left, int loffset, int llength, byte[] right, int roffset, int rlength)
           
protected  int compareColumns(byte[] left, int loffset, int llength, int lfamilylength, byte[] right, int roffset, int rlength, int rfamilylength)
           
 int compareIgnoringPrefix(int commonPrefix, byte[] left, int loffset, int llength, byte[] right, int roffset, int rlength)
          Compare the two key-values, ignoring the prefix of the given length that is known to be the same between the two.
 int compareRows(byte[] left, int loffset, int llength, byte[] right, int roffset, int rlength)
           
 byte[] getShortMidpointKey(byte[] leftKey, byte[] rightKey)
          Generate a faked byte array if possible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

KeyValue.KeyComparator

public KeyValue.KeyComparator()
Method Detail

compare

public int compare(byte[] left,
                   int loffset,
                   int llength,
                   byte[] right,
                   int roffset,
                   int rlength)
Specified by:
compare in interface org.apache.hadoop.io.RawComparator<byte[]>

compareIgnoringPrefix

public int compareIgnoringPrefix(int commonPrefix,
                                 byte[] left,
                                 int loffset,
                                 int llength,
                                 byte[] right,
                                 int roffset,
                                 int rlength)
Compare the two key-values, ignoring the prefix of the given length that is known to be the same between the two.

Specified by:
compareIgnoringPrefix in interface KeyValue.SamePrefixComparator<byte[]>
Parameters:
commonPrefix - the prefix length to ignore

compare

public int compare(byte[] left,
                   byte[] right)
Specified by:
compare in interface Comparator<byte[]>

compareRows

public int compareRows(byte[] left,
                       int loffset,
                       int llength,
                       byte[] right,
                       int roffset,
                       int rlength)

getShortMidpointKey

public byte[] getShortMidpointKey(byte[] leftKey,
                                  byte[] rightKey)
Generate a faked byte array if possible. It aims to: 1)reduce key length, which expects to reduce HFile index memory footprint 2)replace TS field with LATEST_TIMESTAMP(to avoid seeking previous block) see HBASE-7845 for more details we need to ensure: leftKey < newKey <= rightKey

Parameters:
leftKey - the previous block's real stop key usually
rightKey - the current block's real start key usually
Returns:
newKey: the newly generated faked key

compareColumns

protected int compareColumns(byte[] left,
                             int loffset,
                             int llength,
                             int lfamilylength,
                             byte[] right,
                             int roffset,
                             int rlength,
                             int rfamilylength)


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.