org.apache.hadoop.hbase.regionserver
Class HStoreFile

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

public class HStoreFile
extends Object
implements HConstants

A HStore data file. HStores usually have one or more of these files. They are produced by flushing the memcache to disk.

Each HStore maintains a bunch of different data files. The filename is a mix of the parent dir, the region name, the column name, and a file identifier. The name may also be a reference to a store file located elsewhere. This class handles all that path-building stuff for you.

An HStoreFile usually tracks 4 things: its parent dir, the region identifier, the column family, and the file identifier. If you know those four things, you know how to obtain the right HStoreFile. HStoreFiles may also reference store files in another region serving either from the top-half of the remote file or from the bottom-half. Such references are made fast splitting regions.

Plain HStoreFiles are named for a randomly generated id as in: 1278437856009925445 A file by this name is made in both the mapfiles and info subdirectories of a HStore columnfamily directoy: E.g. If the column family is 'anchor:', then under the region directory there is a subdirectory named 'anchor' within which is a 'mapfiles' and 'info' subdirectory. In each will be found a file named something like 1278437856009925445, one to hold the data in 'mapfiles' and one under 'info' that holds the sequence id for this store file.

References to store files located over in some other region look like this: 1278437856009925445.hbaserepository,qAReLZD-OyQORZWq_vqR1k==,959247014679548184: i.e. an id followed by the name of the referenced region. The data ('mapfiles') of HStoreFile references are empty. The accompanying info file contains the midkey, the id of the remote store we're referencing and whether we're to serve the top or bottom region of the remote store file. Note, a region is not splitable if it has instances of store file references (References are cleaned up by compactions).

When merging or splitting HRegions, we might want to modify one of the params for an HStoreFile (effectively moving it elsewhere).


Field Summary
 
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, MAX_ROW_LENGTH, META_ROW_DELIMITER, META_TABLE_NAME, MODIFY_CLOSE_REGION, MODIFY_TABLE_COMPACT, MODIFY_TABLE_FLUSH, MODIFY_TABLE_MAJOR_COMPACT, MODIFY_TABLE_SET_HTD, MODIFY_TABLE_SPLIT, NAME, NINES, REGION_SERVER_CLASS, REGION_SERVER_IMPL, REGIONSERVER_ADDRESS, RETRY_BACKOFF, ROOT_TABLE_NAME, THREAD_WAKE_FREQUENCY, UTF8_ENCODING, VERSION_FILE_NAME, VERSIONS, WEEK_IN_SECONDS, ZERO_L, ZEROES
 
Method Summary
 void delete()
          Delete store map files.
static org.apache.hadoop.fs.Path getFilterDir(org.apache.hadoop.fs.Path dir, int encodedRegionName, byte[] f)
          Deprecated. 
static org.apache.hadoop.fs.Path getInfoDir(org.apache.hadoop.fs.Path dir, int encodedRegionName, byte[] f)
           
static org.apache.hadoop.fs.Path getMapDir(org.apache.hadoop.fs.Path dir, int encodedRegionName, byte[] f)
           
 BloomFilterMapFile.Reader getReader(org.apache.hadoop.fs.FileSystem fs, boolean bloomFilter, boolean blockCacheEnabled)
          Get reader for the store file map file.
 MapFile.Writer getWriter(org.apache.hadoop.fs.FileSystem fs, SequenceFile.CompressionType compression, boolean bloomFilter, int nrows)
          Get a store file writer.
 long indexLength()
           
 boolean isMajorCompaction()
           
 long length()
           
 boolean rename(org.apache.hadoop.fs.FileSystem fs, HStoreFile hsf)
          Renames the mapfiles and info directories under the passed hsf directory.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

delete

public void delete()
            throws IOException
Delete store map files.

Throws:
IOException

rename

public boolean rename(org.apache.hadoop.fs.FileSystem fs,
                      HStoreFile hsf)
               throws IOException
Renames the mapfiles and info directories under the passed hsf directory.

Parameters:
fs -
hsf -
Returns:
True if succeeded.
Throws:
IOException

getReader

public BloomFilterMapFile.Reader getReader(org.apache.hadoop.fs.FileSystem fs,
                                           boolean bloomFilter,
                                           boolean blockCacheEnabled)
                                    throws IOException
Get reader for the store file map file. Client is responsible for closing file when done.

Parameters:
fs -
bloomFilter - If true, a bloom filter exists
blockCacheEnabled - If true, MapFile blocks should be cached.
Returns:
BloomFilterMapFile.Reader
Throws:
IOException

getWriter

public MapFile.Writer getWriter(org.apache.hadoop.fs.FileSystem fs,
                                SequenceFile.CompressionType compression,
                                boolean bloomFilter,
                                int nrows)
                         throws IOException
Get a store file writer. Client is responsible for closing file when done.

Parameters:
fs -
compression - Pass SequenceFile.CompressionType.NONE for none.
bloomFilter - If true, create a bloom filter
nrows - number of rows expected. Required if bloomFilter is true.
Returns:
MapFile.Writer
Throws:
IOException

length

public long length()
            throws IOException
Returns:
Length of the store map file. If a reference, size is approximation.
Throws:
IOException

indexLength

public long indexLength()
                 throws IOException
Returns:
Length of the store map file index.
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

isMajorCompaction

public boolean isMajorCompaction()
Returns:
True if this file was made by a major compaction.

getMapDir

public static org.apache.hadoop.fs.Path getMapDir(org.apache.hadoop.fs.Path dir,
                                                  int encodedRegionName,
                                                  byte[] f)
Parameters:
dir - Base directory
encodedRegionName - Encoding of region name.
f - Column family.
Returns:
path for map file directory

getInfoDir

public static org.apache.hadoop.fs.Path getInfoDir(org.apache.hadoop.fs.Path dir,
                                                   int encodedRegionName,
                                                   byte[] f)
Parameters:
dir - Base directory
encodedRegionName - Encoding of region name.
f - Column family.
Returns:
the info directory path

getFilterDir

@Deprecated
public static org.apache.hadoop.fs.Path getFilterDir(org.apache.hadoop.fs.Path dir,
                                                                int encodedRegionName,
                                                                byte[] f)
Deprecated. 

Parameters:
dir - Base directory
encodedRegionName - Encoding of region name.
f - Column family.
Returns:
the bloom filter directory path


Copyright © 2008 The Apache Software Foundation