org.apache.hadoop.hbase.regionserver
Class HStore

java.lang.Object
  extended by org.apache.hadoop.hbase.regionserver.HStore
All Implemented Interfaces:
HConstants

public class HStore
extends Object
implements HConstants

HStore maintains a bunch of data files. It is responsible for maintaining the memory/file hierarchy and for periodic flushes to disk and compacting edits to the file. Locking and transactions are handled at a higher level. This API should not be called directly by any writer, but rather by an HRegion manager.


Field Summary
protected  org.apache.hadoop.hbase.regionserver.Memcache memcache
           
protected  long ttl
           
 
Fields inherited from interface org.apache.hadoop.hbase.HConstants
ALL_META_COLUMNS, ALL_VERSIONS, COL_REGIONINFO, COL_REGIONINFO_ARRAY, COL_SERVER, COL_SPLITA, COL_SPLITB, COL_STARTCODE, COLUMN_FAMILY, COLUMN_FAMILY_ARRAY, COLUMN_FAMILY_HISTORIAN, COLUMN_FAMILY_HISTORIAN_STR, COLUMN_FAMILY_STR, DEFAULT_CLIENT_RETRIES, DEFAULT_HOST, DEFAULT_MASTER_ADDRESS, DEFAULT_MASTER_INFOPORT, DEFAULT_MASTER_PORT, DEFAULT_MAX_FILE_SIZE, DEFAULT_REGION_SERVER_CLASS, DEFAULT_REGIONSERVER_ADDRESS, DEFAULT_REGIONSERVER_INFOPORT, DEFAULT_SIZE_RESERVATION_BLOCK, EMPTY_BYTE_ARRAY, EMPTY_END_ROW, EMPTY_START_ROW, FILE_SYSTEM_VERSION, FOREVER, HBASE_CLIENT_RETRIES_NUMBER_KEY, HBASE_DIR, HREGION_LOGDIR_NAME, HREGION_OLDLOGFILE_NAME, IN_MEMORY, LAST_ROW, LATEST_TIMESTAMP, MAJOR_COMPACTION_PERIOD, MASTER_ADDRESS, META_ROW_DELIMITER, META_TABLE_NAME, NAME, NINES, REGION_SERVER_CLASS, REGION_SERVER_IMPL, REGIONSERVER_ADDRESS, RETRY_BACKOFF, ROOT_TABLE_NAME, THREAD_WAKE_FREQUENCY, UTF8_ENCODING, VERSION_FILE_NAME, VERSIONS, ZERO_L, ZEROES
 
Constructor Summary
protected HStore(org.apache.hadoop.fs.Path basedir, HRegionInfo info, HColumnDescriptor family, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path reconstructionLog, HBaseConfiguration conf, org.apache.hadoop.util.Progressable reporter)
          An HStore is a set of zero or more MapFiles, which stretch backwards over time.
 
Method Summary
protected  long add(HStoreKey key, byte[] value)
          Adds a value to the memcache
protected  List<HStoreKey> getKeys(HStoreKey origin, int versions, long now)
          Get versions of keys matching the origin key's row/column/timestamp and those of an older vintage.
 org.apache.hadoop.io.MapFile.Reader[] getReaders()
           
protected  InternalScanner getScanner(long timestamp, byte[][] targetCols, byte[] firstRow, RowFilterInterface filter)
          Return a scanner for both the memcache and the HStore files
 long getSize()
           
static boolean isReference(org.apache.hadoop.fs.Path p)
           
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

memcache

protected final org.apache.hadoop.hbase.regionserver.Memcache memcache

ttl

protected long ttl
Constructor Detail

HStore

protected HStore(org.apache.hadoop.fs.Path basedir,
                 HRegionInfo info,
                 HColumnDescriptor family,
                 org.apache.hadoop.fs.FileSystem fs,
                 org.apache.hadoop.fs.Path reconstructionLog,
                 HBaseConfiguration conf,
                 org.apache.hadoop.util.Progressable reporter)
          throws IOException
An HStore is a set of zero or more MapFiles, which stretch backwards over time. A given HStore is responsible for a certain set of columns for a row in the HRegion.

The HRegion starts writing to its set of HStores when the HRegion's memcache is flushed. This results in a round of new MapFiles, one for each HStore.

There's no reason to consider append-logging at this level; all logging and locking is handled at the HRegion level. HStore just provides services to manage sets of MapFiles. One of the most important of those services is MapFile-compaction services.

The only thing having to do with logs that HStore needs to deal with is the reconstructionLog. This is a segment of an HRegion's log that might NOT be present upon startup. If the param is NULL, there's nothing to do. If the param is non-NULL, we need to process the log to reconstruct a TreeMap that might not have been written to disk before the process died.

It's assumed that after this constructor returns, the reconstructionLog file will be deleted (by whoever has instantiated the HStore).

Parameters:
basedir - qualified path under which the region directory lives
info - HRegionInfo for this region
family - HColumnDescriptor for this column
fs - file system object
reconstructionLog - existing log file to apply if any
conf - configuration object
reporter - Call on a period so hosting server can report we're making progress to master -- otherwise master might think region deploy failed. Can be null.
Throws:
IOException
Method Detail

add

protected long add(HStoreKey key,
                   byte[] value)
Adds a value to the memcache

Parameters:
key -
value -
Returns:
memcache size delta

getReaders

public org.apache.hadoop.io.MapFile.Reader[] getReaders()
Returns:
Array of readers ordered oldest to newest.

getKeys

protected List<HStoreKey> getKeys(HStoreKey origin,
                                  int versions,
                                  long now)
                           throws IOException
Get versions of keys matching the origin key's row/column/timestamp and those of an older vintage.

Parameters:
origin - Where to start searching.
versions - How many versions to return. Pass HConstants.ALL_VERSIONS to retrieve all.
now -
Returns:
Matching keys.
Throws:
IOException

getSize

public long getSize()
Returns:
aggregate size of HStore

getScanner

protected InternalScanner getScanner(long timestamp,
                                     byte[][] targetCols,
                                     byte[] firstRow,
                                     RowFilterInterface filter)
                              throws IOException
Return a scanner for both the memcache and the HStore files

Throws:
IOException

toString

public String toString()

Overrides:
toString in class Object

isReference

public static boolean isReference(org.apache.hadoop.fs.Path p)
Parameters:
p - Path to check.
Returns:
True if the path has format of a HStoreFile reference.


Copyright © 2008 The Apache Software Foundation