org.apache.hadoop.hbase.regionserver
Class StoreFile

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

public class StoreFile
extends Object
implements HConstants

A Store data file. Stores usually have one or more of these files. They are produced by flushing the memstore to disk. To create, call getWriter(FileSystem, Path) and append data. Be sure to add any metadata before calling close on the Writer (Use the appendMetadata convenience methods). On close, a StoreFile is sitting in the Filesystem. To refer to it, create a StoreFile instance passing filesystem and path. To read, call getReader().

StoreFiles may also reference store files in another Store.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.HConstants
HConstants.Modify
 
Field Summary
 
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
 
Method Summary
static void appendMetadata(HFile.Writer w, long maxSequenceId, boolean mc)
          Writes metadata.
 void close()
           
 void delete()
          Delete this file
 BlockCache getBlockCache()
           
static BlockCache getBlockCache(HBaseConfiguration conf)
          Returns the block cache or null in case none should be used.
 long getMaxSequenceId()
           
 HFile.Reader getReader()
           
static HFile.Writer getWriter(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dir)
          Get a store file writer.
static HFile.Writer getWriter(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dir, int blocksize, Compression.Algorithm algorithm, KeyValue.KeyComparator c)
          Get a store file writer.
static boolean isReference(org.apache.hadoop.fs.Path p)
           
static boolean isReference(org.apache.hadoop.fs.Path p, Matcher m)
           
protected  HFile.Reader open()
          Opens reader on this store file.
static org.apache.hadoop.fs.Path rename(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path src, org.apache.hadoop.fs.Path tgt)
          Utility to help with rename.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

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.

isReference

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

getMaxSequenceId

public long getMaxSequenceId()
Returns:
This files maximum edit sequence id.

getBlockCache

public static BlockCache getBlockCache(HBaseConfiguration conf)
Returns the block cache or null in case none should be used.

Parameters:
conf - The current configuration.
Returns:
The block cache or null.

getBlockCache

public BlockCache getBlockCache()
Returns:
the blockcache

open

protected HFile.Reader open()
                     throws IOException
Opens reader on this store file. Called by Constructor.

Returns:
Reader for the store file.
Throws:
IOException
See Also:
close()

getReader

public HFile.Reader getReader()
Returns:
Current reader. Must call open first else returns null.

close

public void close()
           throws IOException
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

delete

public void delete()
            throws IOException
Delete this file

Throws:
IOException

rename

public static org.apache.hadoop.fs.Path rename(org.apache.hadoop.fs.FileSystem fs,
                                               org.apache.hadoop.fs.Path src,
                                               org.apache.hadoop.fs.Path tgt)
                                        throws IOException
Utility to help with rename.

Parameters:
fs -
src -
tgt -
Returns:
True if succeeded.
Throws:
IOException

getWriter

public static HFile.Writer getWriter(org.apache.hadoop.fs.FileSystem fs,
                                     org.apache.hadoop.fs.Path dir)
                              throws IOException
Get a store file writer. Client is responsible for closing file when done. If metadata, add BEFORE closing using appendMetadata(org.apache.hadoop.hbase.io.hfile.HFile.Writer, long).

Parameters:
fs -
dir - Path to family directory. Makes the directory if doesn't exist. Creates a file with a unique name in this directory.
Returns:
HFile.Writer
Throws:
IOException

getWriter

public static HFile.Writer getWriter(org.apache.hadoop.fs.FileSystem fs,
                                     org.apache.hadoop.fs.Path dir,
                                     int blocksize,
                                     Compression.Algorithm algorithm,
                                     KeyValue.KeyComparator c)
                              throws IOException
Get a store file writer. Client is responsible for closing file when done. If metadata, add BEFORE closing using appendMetadata(org.apache.hadoop.hbase.io.hfile.HFile.Writer, long).

Parameters:
fs -
dir - Path to family directory. Makes the directory if doesn't exist. Creates a file with a unique name in this directory.
blocksize -
algorithm - Pass null to get default.
c - Pass null to get default.
Returns:
HFile.Writer
Throws:
IOException

appendMetadata

public static void appendMetadata(HFile.Writer w,
                                  long maxSequenceId,
                                  boolean mc)
                           throws IOException
Writes metadata. Call before you call close on the passed w since its written as metadata to that file.

Parameters:
maxSequenceId - Maximum sequence id.
mc - True if this file is product of a major compaction
Throws:
IOException


Copyright © 2009 The Apache Software Foundation