|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.HRegion
public class HRegion
HRegion stores data for a certain region of a table. It stores all columns for each row. A given table consists of one or more HRegions.
We maintain multiple HStores for a single HRegion.
An HStore is a set of rows with some column data; together, they make up all the data for the rows.
Each HRegion has a 'startKey' and 'endKey'.
The first is inclusive, the second is exclusive (except for the final region) The endKey of region 0 is the same as startKey for region 1 (if it exists). The startKey for the first region is null. The endKey for the final region is null.
Locking at the HRegion level serves only one purpose: preventing the region from being closed (and consequently split) while other operations are ongoing. Each row level operation obtains both a row lock and a region read lock for the duration of the operation. While a scanner is being constructed, getScanner holds a read lock. If the scanner is successfully constructed, it holds a read lock until it is closed. A close takes out a write lock and consequently will block for ongoing operations and will block new operations from starting while the close is in progress.
An HRegion is defined by its table and its key extent.
It consists of at least one HStore. The number of HStores should be configurable, so that data which is accessed together is stored in the same HStore. Right now, we approximate that by building a single HStore for each column family. (This config info will be communicated via the tabledesc.)
The HTableDescriptor contains metainfo about the HRegion's table. regionName is a unique identifier for this HRegion. (startKey, endKey] defines the keyspace for this HRegion.
Field Summary | |
---|---|
protected long |
threadWakeFrequency
|
Constructor Summary | |
---|---|
HRegion(Path basedir,
HLog log,
FileSystem fs,
HBaseConfiguration conf,
HRegionInfo regionInfo,
Path initialFiles,
CacheFlushListener listener)
HRegion constructor. |
Method Summary | |
---|---|
void |
batchUpdate(long timestamp,
BatchUpdate b)
|
List<HStoreFile> |
close()
Close down this HRegion. |
void |
deleteAll(Text row,
long ts)
Delete all cells of the same age as the passed timestamp or older. |
void |
deleteAll(Text row,
Text column,
long ts)
Delete all cells of the same age as the passed timestamp or older. |
void |
deleteFamily(Text row,
Text family,
long timestamp)
Delete all cells for a row with matching column family with timestamps less than or equal to timestamp. |
byte[] |
get(Text row,
Text column)
Fetch a single data item. |
byte[][] |
get(Text row,
Text column,
int numVersions)
Fetch multiple versions of a single data item |
byte[][] |
get(Text row,
Text column,
long timestamp,
int numVersions)
Fetch multiple versions of a single data item, with timestamp. |
Map<Text,byte[]> |
getClosestRowBefore(Text row,
long ts)
Return all the data for the row that matches row exactly, or the one that immediately preceeds it, at or immediately before ts. |
Text |
getEndKey()
|
Map<Text,byte[]> |
getFull(Text row)
Fetch all the columns for the indicated row. |
Map<Text,byte[]> |
getFull(Text row,
long ts)
Fetch all the columns for the indicated row at a specified timestamp. |
long |
getLastFlushTime()
|
HLog |
getLog()
|
static Path |
getRegionDir(Path rootdir,
HRegionInfo info)
Computes the Path of the HRegion |
HRegionInfo |
getRegionInfo()
|
Text |
getRegionName()
|
HScannerInterface |
getScanner(Text[] cols,
Text firstRow,
long timestamp,
RowFilterInterface filter)
Return an iterator that scans over the HRegion, returning the indicated columns for only the rows that match the data filter. |
Text |
getStartKey()
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final long threadWakeFrequency
Constructor Detail |
---|
public HRegion(Path basedir, HLog log, FileSystem fs, HBaseConfiguration conf, HRegionInfo regionInfo, Path initialFiles, CacheFlushListener listener) throws IOException
log
- The HLog is the outbound log for any updates to the HRegion
(There's a single HLog for all the HRegions on a single HRegionServer.)
The log file is a logfile from the previous execution that's
custom-computed for this HRegion. The HRegionServer computes and sorts the
appropriate log info for this HRegion. If there is a previous log file
(implying that the HRegion has been written-to before), then read it from
the supplied path.basedir
- qualified path of directory where region should be located,
usually the table directory.fs
- is the filesystem.conf
- is global configuration settings.regionInfo
- - HRegionInfo that describes the regioninitialFiles
- If there are initial files (implying that the HRegion
is new), then read them from the supplied path.listener
- an object that implements CacheFlushListener or null
IOException
Method Detail |
---|
public HRegionInfo getRegionInfo()
public List<HStoreFile> close() throws IOException
This method could take some time to execute, so don't call it from a time-sensitive thread.
IOException
public Text getStartKey()
public Text getEndKey()
public Text getRegionName()
public HLog getLog()
public long getLastFlushTime()
public byte[] get(Text row, Text column) throws IOException
row
- column
-
IOException
public byte[][] get(Text row, Text column, int numVersions) throws IOException
row
- column
- numVersions
-
IOException
public byte[][] get(Text row, Text column, long timestamp, int numVersions) throws IOException
row
- column
- timestamp
- numVersions
-
IOException
public Map<Text,byte[]> getFull(Text row) throws IOException
row
-
IOException
public Map<Text,byte[]> getFull(Text row, long ts) throws IOException
row
- ts
-
IOException
public Map<Text,byte[]> getClosestRowBefore(Text row, long ts) throws IOException
row
- row keyts
-
IOException
public HScannerInterface getScanner(Text[] cols, Text firstRow, long timestamp, RowFilterInterface filter) throws IOException
cols
- columns to scan. If column name is a column family, all
columns of the specified column family are returned. Its also possible
to pass a regex in the column qualifier. A column qualifier is judged to
be a regex if it contains at least one of the following characters:
\+|^&*$[]]}{)(
.firstRow
- row which is the starting point of the scantimestamp
- only return rows whose timestamp is <= this valuefilter
- row filter
IOException
public void batchUpdate(long timestamp, BatchUpdate b) throws IOException
timestamp
- b
-
IOException
public void deleteAll(Text row, Text column, long ts) throws IOException
row
- column
- ts
- Delete all entries that have this timestamp or older
IOException
public void deleteAll(Text row, long ts) throws IOException
row
- ts
- Delete all entries that have this timestamp or older
IOException
public void deleteFamily(Text row, Text family, long timestamp) throws IOException
row
- The row to operate onfamily
- The column family to matchtimestamp
- Timestamp to match
IOException
public String toString()
toString
in class Object
public static Path getRegionDir(Path rootdir, HRegionInfo info)
rootdir
- qualified path of HBase root directoryinfo
- HRegionInfo for the region
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |