org.apache.hadoop.hbase.regionserver
Class QueryMatcher

java.lang.Object
  extended by org.apache.hadoop.hbase.regionserver.QueryMatcher
Direct Known Subclasses:
ScanQueryMatcher

public class QueryMatcher
extends Object

This is the primary class used to process KeyValues during a Get or Scan operation.

It encapsulates the handling of the column and version input parameters to the query through a ColumnTracker.

Deletes are handled using the DeleteTracker.

All other query parameters are accessed from the client-specified Get.

The primary method used is match(org.apache.hadoop.hbase.KeyValue) with the current KeyValue. It will return a QueryMatcher.MatchCode , deletes, versions,


Field Summary
protected  ColumnTracker columns
          Keeps track of columns and versions
protected  DeleteTracker deletes
          Keeps track of deletes
protected  Filter filter
           
protected  long oldestStamp
          Oldest allowed version stamp for TTL enforcement
protected  byte[] row
          Row the query is on
protected  KeyValue startKey
          Key to seek to in memstore and StoreFiles
protected  TimeRange tr
          TimeRange the query is for
 
Constructor Summary
protected QueryMatcher()
           
  QueryMatcher(Get get, byte[] family, NavigableSet<byte[]> columns, long ttl, KeyValue.KeyComparator rowComparator, int maxVersions)
          Constructs a QueryMatcher for a Get.
  QueryMatcher(QueryMatcher matcher, byte[] row)
          Constructs a copy of an existing QueryMatcher with a new row.
 
Method Summary
 ColumnTracker getColumnTracker()
           
 DeleteTracker getDeleteTracker()
           
 long getOldestStamp()
           
 KeyValue.KeyComparator getRowComparator()
           
 ColumnCount getSeekColumn()
          If matcher returns SEEK_NEXT_COL you may be able to get a hint of the next column to seek to - call this.
 KeyValue getStartKey()
           
 TimeRange getTimeRange()
           
protected  boolean isDelete(byte type)
           
 boolean isDone()
           
protected  boolean isExpired(long timestamp)
           
 org.apache.hadoop.hbase.regionserver.QueryMatcher.MatchCode match(KeyValue kv)
          Main method for ColumnMatcher.
 void reset()
          Resets the current columns and deletes
 void setRow(byte[] row)
          Set current row
 void update()
          Called after reading each section (memstore, snapshot, storefiles).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

deletes

protected DeleteTracker deletes
Keeps track of deletes


columns

protected ColumnTracker columns
Keeps track of columns and versions


startKey

protected KeyValue startKey
Key to seek to in memstore and StoreFiles


row

protected byte[] row
Row the query is on


tr

protected TimeRange tr
TimeRange the query is for


oldestStamp

protected long oldestStamp
Oldest allowed version stamp for TTL enforcement


filter

protected Filter filter
Constructor Detail

QueryMatcher

public QueryMatcher(Get get,
                    byte[] family,
                    NavigableSet<byte[]> columns,
                    long ttl,
                    KeyValue.KeyComparator rowComparator,
                    int maxVersions)
Constructs a QueryMatcher for a Get.

Parameters:
get -
family -
columns -
ttl -
rowComparator -

QueryMatcher

protected QueryMatcher()

QueryMatcher

public QueryMatcher(QueryMatcher matcher,
                    byte[] row)
Constructs a copy of an existing QueryMatcher with a new row.

Parameters:
matcher -
row -
Method Detail

match

public org.apache.hadoop.hbase.regionserver.QueryMatcher.MatchCode match(KeyValue kv)
Main method for ColumnMatcher.

Determines whether the specified KeyValue should be included in the result or not.

Contains additional language to early-out of the current file or to return immediately.

Things to be checked:


isDelete

protected boolean isDelete(byte type)

isExpired

protected boolean isExpired(long timestamp)

getSeekColumn

public ColumnCount getSeekColumn()
If matcher returns SEEK_NEXT_COL you may be able to get a hint of the next column to seek to - call this. If it returns null, there is no hint.

Returns:
immediately after match returns SEEK_NEXT_COL - null if no hint, else the next column we want

update

public void update()
Called after reading each section (memstore, snapshot, storefiles).

This method will update the internal structures to be accurate for the next section.


reset

public void reset()
Resets the current columns and deletes


setRow

public void setRow(byte[] row)
Set current row

Parameters:
row -

getStartKey

public KeyValue getStartKey()
Returns:
the start key

getTimeRange

public TimeRange getTimeRange()
Returns:
the TimeRange

getOldestStamp

public long getOldestStamp()
Returns:
the oldest stamp

getRowComparator

public KeyValue.KeyComparator getRowComparator()
Returns:
current KeyComparator

getColumnTracker

public ColumnTracker getColumnTracker()
Returns:
ColumnTracker

getDeleteTracker

public DeleteTracker getDeleteTracker()
Returns:
DeleteTracker

isDone

public boolean isDone()
Returns:
true when done.


Copyright © 2010 The Apache Software Foundation