org.apache.hadoop.hbase.regionserver
Class Store

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

public class Store
extends Object
implements HConstants, HeapSize

A Store holds a column family in a Region. Its a memstore and a set of zero or more StoreFiles, which stretch backwards over time.

There's no reason to consider append-logging at this level; all logging and locking is handled at the HRegion level. Store just provides services to manage sets of StoreFiles. One of the most important of those services is compaction services where files are aggregated once they pass a configurable threshold.

The only thing having to do with logs that Store 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 Store).

Locking and transactions are handled at a higher level. This API should not be called directly but by an HRegion manager.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.HConstants
HConstants.Modify
 
Field Summary
static long DEEP_OVERHEAD
           
static long FIXED_OVERHEAD
           
protected  MemStore memstore
          Comparator that looks at columns and compares their family portions.
protected  long ttl
           
 
Fields inherited from interface org.apache.hadoop.hbase.HConstants
ALL_VERSIONS, CATALOG_FAMILY, CATALOG_FAMILY_STR, CATALOG_HISTORIAN_FAMILY, CLUSTER_DISTRIBUTED, CLUSTER_IS_DISTRIBUTED, CLUSTER_IS_LOCAL, DEFAULT_HOST, DEFAULT_MASTER_INFOPORT, DEFAULT_MASTER_PORT, DEFAULT_MAX_FILE_SIZE, DEFAULT_REGION_SERVER_CLASS, DEFAULT_REGIONSERVER_INFOPORT, DEFAULT_REGIONSERVER_PORT, DEFAULT_SIZE_RESERVATION_BLOCK, DEFAULT_ZOOKEEPER_PAUSE, DEFAULT_ZOOKEEPER_RETRIES, EMPTY_BYTE_ARRAY, EMPTY_END_ROW, EMPTY_START_ROW, FILE_SYSTEM_VERSION, FOREVER, HBASE_CLIENT_RETRIES_NUMBER_KEY, HBASE_DIR, HREGION_COMPACTIONDIR_NAME, HREGION_LOGDIR_NAME, HREGION_OLDLOGFILE_NAME, IN_MEMORY, LAST_ROW, LATEST_TIMESTAMP, LATEST_TIMESTAMP_BYTES, MAJOR_COMPACTION_PERIOD, MASTER_PORT, MAX_ROW_LENGTH, MAXIMUM_VALUE_LENGTH, META_ROW_DELIMITER, META_TABLE_NAME, NAME, NINES, REGION_SERVER_CLASS, REGION_SERVER_IMPL, REGIONINFO_QUALIFIER, REGIONSERVER_PORT, RETRY_BACKOFF, ROOT_TABLE_NAME, SERVER_QUALIFIER, SPLITA_QUALIFIER, SPLITB_QUALIFIER, STARTCODE_QUALIFIER, THREAD_WAKE_FREQUENCY, UTF8_ENCODING, VERSION_FILE_NAME, VERSIONS, WEEK_IN_SECONDS, ZERO_L, ZEROES, ZOOKEEPER_CONFIG_NAME, ZOOKEEPER_PAUSE, ZOOKEEPER_QUORUM, ZOOKEEPER_RETRIES
 
Constructor Summary
protected Store(org.apache.hadoop.fs.Path basedir, HRegion region, HColumnDescriptor family, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path reconstructionLog, HBaseConfiguration conf, org.apache.hadoop.util.Progressable reporter)
          Constructor
 
Method Summary
protected  long add(KeyValue kv)
          Adds a value to the memstore
protected  long delete(KeyValue kv)
          Adds a value to the memstore
 void get(Get get, NavigableSet<byte[]> columns, List<KeyValue> result)
          Retrieve results from this store given the specified Get parameters.
 int getNumberOfstorefiles()
           
protected  KeyValueScanner getScanner(Scan scan, NavigableSet<byte[]> targetCols)
          Return a scanner for both the memstore and the HStore files
 long getSize()
           
static org.apache.hadoop.fs.Path getStoreHomedir(org.apache.hadoop.fs.Path tabledir, int encodedName, byte[] family)
           
 boolean hasTooManyStoreFiles()
          See if there's too much store files in this store
 long heapSize()
           
 String toString()
           
 long updateColumnValue(byte[] row, byte[] f, byte[] qualifier, long newValue)
          Increments the value for the given row/family/qualifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

memstore

protected final MemStore memstore
Comparator that looks at columns and compares their family portions. Presumes columns have already been checked for presence of delimiter. If no delimiter present, presume the buffer holds a store name so no need of a delimiter.


ttl

protected long ttl

FIXED_OVERHEAD

public static final long FIXED_OVERHEAD

DEEP_OVERHEAD

public static final long DEEP_OVERHEAD
Constructor Detail

Store

protected Store(org.apache.hadoop.fs.Path basedir,
                HRegion region,
                HColumnDescriptor family,
                org.apache.hadoop.fs.FileSystem fs,
                org.apache.hadoop.fs.Path reconstructionLog,
                HBaseConfiguration conf,
                org.apache.hadoop.util.Progressable reporter)
         throws IOException
Constructor

Parameters:
basedir - qualified path under which the region directory lives; generally the table subdirectory
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

getStoreHomedir

public static org.apache.hadoop.fs.Path getStoreHomedir(org.apache.hadoop.fs.Path tabledir,
                                                        int encodedName,
                                                        byte[] family)
Parameters:
tabledir -
encodedName - Encoded region name.
family -
Returns:
Path to family/Store home directory.

add

protected long add(KeyValue kv)
Adds a value to the memstore

Parameters:
kv -
Returns:
memstore size delta

delete

protected long delete(KeyValue kv)
Adds a value to the memstore

Parameters:
kv -
Returns:
memstore size delta

getNumberOfstorefiles

public int getNumberOfstorefiles()
Returns:
the number of files in this store

getSize

public long getSize()
Returns:
aggregate size of HStore

getScanner

protected KeyValueScanner getScanner(Scan scan,
                                     NavigableSet<byte[]> targetCols)
Return a scanner for both the memstore and the HStore files


toString

public String toString()
Overrides:
toString in class Object

get

public void get(Get get,
                NavigableSet<byte[]> columns,
                List<KeyValue> result)
         throws IOException
Retrieve results from this store given the specified Get parameters.

Parameters:
get - Get operation
columns - List of columns to match, can be empty (not null)
result - List to add results to
Throws:
IOException

updateColumnValue

public long updateColumnValue(byte[] row,
                              byte[] f,
                              byte[] qualifier,
                              long newValue)
                       throws IOException
Increments the value for the given row/family/qualifier

Parameters:
row -
f -
qualifier -
newValue - the new value to set into memstore
Returns:
memstore size delta
Throws:
IOException

hasTooManyStoreFiles

public boolean hasTooManyStoreFiles()
See if there's too much store files in this store

Returns:
true if number of store files is greater than the number defined in compactionThreshold

heapSize

public long heapSize()
Specified by:
heapSize in interface HeapSize
Returns:
Approximate 'exclusive deep size' of implementing object. Includes count of payload and hosting object sizings.


Copyright © 2009 The Apache Software Foundation