org.apache.hadoop.hbase.client
Class HTable

java.lang.Object
  extended by org.apache.hadoop.hbase.client.HTable
Direct Known Subclasses:
TransactionalTable

public class HTable
extends Object

Used to communicate with a single HBase table


Nested Class Summary
protected  class HTable.ClientScanner
          Implements the scanner interface for the HBase client.
 
Field Summary
protected  int scannerCaching
           
protected  int scannerTimeout
           
 
Constructor Summary
HTable(byte[] tableName)
          Creates an object to access a HBase table
HTable(HBaseConfiguration conf, byte[] tableName)
          Creates an object to access a HBase table
HTable(HBaseConfiguration conf, String tableName)
          Creates an object to access a HBase table
HTable(String tableName)
          Creates an object to access a HBase table
 
Method Summary
 boolean checkAndSave(BatchUpdate batchUpdate, HbaseMapWritable<byte[],byte[]> expectedValues, RowLock rl)
          Atomically checks if a row's values match the expectedValues.
 void close()
          Release held resources
 void commit(BatchUpdate batchUpdate)
          Commit a BatchUpdate to the table.
 void commit(BatchUpdate batchUpdate, RowLock rl)
          Commit a BatchUpdate to the table using existing row lock.
 void commit(List<BatchUpdate> batchUpdates)
          Commit a List of BatchUpdate to the table.
 void deleteAll(byte[] row)
          Completely delete the row's cells.
 void deleteAll(byte[] row, byte[] column)
          Completely delete the row's cells.
 void deleteAll(byte[] row, byte[] column, long ts)
          Delete all cells that match the passed row and column and whose timestamp is equal-to or older than the passed timestamp.
 void deleteAll(byte[] row, byte[] column, long ts, RowLock rl)
          Delete all cells that match the passed row and column and whose timestamp is equal-to or older than the passed timestamp, using an existing row lock.
 void deleteAll(byte[] row, long ts)
          Completely delete the row's cells.
 void deleteAll(String row)
          Completely delete the row's cells.
 void deleteAll(String row, long ts)
          Completely delete the row's cells.
 void deleteAll(String row, String column)
          Delete all cells that match the passed row and column.
 void deleteAll(String row, String column, long ts)
          Delete all cells that match the passed row and column and whose timestamp is equal-to or older than the passed timestamp.
 void deleteAllByRegex(byte[] row, String colRegex, long ts)
          Delete all cells that match the passed row and column and whose timestamp is equal-to or older than the passed timestamp.
 void deleteAllByRegex(byte[] row, String colRegex, long ts, RowLock rl)
          Delete all cells that match the passed row and column and whose timestamp is equal-to or older than the passed timestamp, using an existing row lock.
 void deleteAllByRegex(String row, String colRegex)
          Delete all cells that match the passed row and column.
 void deleteAllByRegex(String row, String colRegex, long ts)
          Delete all cells that match the passed row and column and whose timestamp is equal-to or older than the passed timestamp.
 void deleteFamily(byte[] row, byte[] family)
          Delete all cells for a row with matching column family at all timestamps.
 void deleteFamily(byte[] row, byte[] family, long timestamp)
          Delete all cells for a row with matching column family with timestamps less than or equal to timestamp.
 void deleteFamily(byte[] row, byte[] family, long timestamp, RowLock rl)
          Delete all cells for a row with matching column family with timestamps less than or equal to timestamp, using existing row lock.
 void deleteFamily(String row, String family)
          Delete all cells for a row with matching column family at all timestamps.
 void deleteFamily(String row, String family, long timestamp)
          Delete all cells for a row with matching column family with timestamps less than or equal to timestamp.
 void deleteFamilyByRegex(byte[] row, String familyRegex)
          Delete all cells for a row with matching column family regex at all timestamps.
 void deleteFamilyByRegex(byte[] row, String familyRegex, long timestamp)
          Delete all cells for a row with matching column family regex with timestamps less than or equal to timestamp.
 void deleteFamilyByRegex(byte[] row, String familyRegex, long timestamp, RowLock r1)
          Delete all cells for a row with matching column family regex with timestamps less than or equal to timestamp, using existing row lock.
 void deleteFamilyByRegex(String row, String familyRegex)
          Delete all cells for a row with matching column family regex at all timestamps.
 void deleteFamilyByRegex(String row, String familyRegex, long timestamp)
          Delete all cells for a row with matching column family regex with timestamps less than or equal to timestamp.
 boolean exists(byte[] row)
          Test for the existence of a row in the table.
 boolean exists(byte[] row, byte[] column)
          Test for the existence of a row and column in the table.
 boolean exists(byte[] row, byte[] column, long timestamp)
          Test for the existence of a coordinate in the table.
 boolean exists(byte[] row, byte[] column, long timestamp, RowLock rl)
          Test for the existence of a coordinate in the table.
 void flushCommits()
          Commit to the table the buffer of BatchUpdate.
 Cell get(byte[] row, byte[] column)
          Get a single value for the specified row and column
 Cell[] get(byte[] row, byte[] column, int numVersions)
          Get the specified number of versions of the specified row and column
 Cell[] get(byte[] row, byte[] column, long timestamp, int numVersions)
          Get the specified number of versions of the specified row and column with the specified timestamp.
 Cell get(String row, String column)
          Get a single value for the specified row and column
 Cell[] get(String row, String column, int numVersions)
          Get a single value for the specified row and column
 Cell[] get(String row, String column, long timestamp, int numVersions)
          Get the specified number of versions of the specified row and column with the specified timestamp.
 RowResult getClosestRowBefore(byte[] row, byte[] columnFamily)
           
 HConnection getConnection()
          Used by unit tests and tools to do low-level manipulations.
 byte[][] getEndKeys()
          Gets the ending row key for every region in the currently open table
 HRegionLocation getRegionLocation(byte[] row)
          Find region location hosting passed row using cached info
 HRegionLocation getRegionLocation(String row)
          Find region location hosting passed row using cached info
 Map<HRegionInfo,HServerAddress> getRegionsInfo()
          Get all the regions and their address for this table
 RowResult getRow(byte[] row)
          Get all the data for the specified row at the latest timestamp
 RowResult getRow(byte[] row, byte[][] columns)
          Get selected columns for the specified row at the latest timestamp
 RowResult getRow(byte[] row, byte[][] columns, int numVersions)
          Get more than one version of selected columns for the specified row
 RowResult getRow(byte[] row, byte[][] columns, long ts)
          Get selected columns for the specified row at a specified timestamp
 RowResult getRow(byte[] row, byte[][] columns, long ts, int numVersions, RowLock rl)
          Get selected columns for the specified row at a specified timestamp using existing row lock.
 RowResult getRow(byte[] row, int numVersions)
          Get more than one version of all columns for the specified row
 RowResult getRow(byte[] row, long ts)
          Get all the data for the specified row at a specified timestamp
 RowResult getRow(byte[] row, long timestamp, int numVersions)
          Get more than one version of all columns for the specified row at a specified timestamp
 RowResult getRow(String row)
          Get all the data for the specified row at the latest timestamp
 RowResult getRow(String row, int numVersions)
          Get more than one version of all columns for the specified row
 RowResult getRow(String row, long ts)
          Get all the data for the specified row at a specified timestamp
 RowResult getRow(String row, long ts, int numVersions)
           
 RowResult getRow(String row, String[] columns)
          Get selected columns for the specified row at the latest timestamp
 RowResult getRow(String row, String[] columns, int numVersions)
          Get more than one version of selected columns for the specified row
 RowResult getRow(String row, String[] columns, long ts)
          Get selected columns for the specified row at a specified timestamp
 RowResult getRow(String row, String[] columns, long timestamp, int numVersions, RowLock rowLock)
           
 Scanner getScanner(byte[][] columns)
          Get a scanner on the current table starting at first row.
 Scanner getScanner(byte[][] columns, byte[] startRow)
          Get a scanner on the current table starting at the specified row.
 Scanner getScanner(byte[][] columns, byte[] startRow, byte[] stopRow)
          Get a scanner on the current table starting at the specified row and ending just before stopRow.
 Scanner getScanner(byte[][] columns, byte[] startRow, byte[] stopRow, long timestamp)
          Get a scanner on the current table starting at the specified row and ending just before stopRow.
 Scanner getScanner(byte[][] columns, byte[] startRow, long timestamp)
          Get a scanner on the current table starting at the specified row.
 Scanner getScanner(byte[][] columns, byte[] startRow, long timestamp, RowFilterInterface filter)
          Get a scanner on the current table starting at the specified row.
 Scanner getScanner(byte[][] columns, byte[] startRow, RowFilterInterface filter)
          Get a scanner on the current table starting at the specified row.
 Scanner getScanner(String[] columns)
          Get a scanner on the current table starting at first row.
 Scanner getScanner(String[] columns, String startRow)
          Get a scanner on the current table starting at the specified row.
 Scanner getScanner(String[] columns, String startRow, long timestamp, RowFilterInterface filter)
          Get a scanner on the current table starting at the specified row.
 Scanner getScanner(String[] columns, String startRow, String stopRow, long timestamp)
          Get a scanner on the current table starting at the specified row and ending just before stopRow.
 int getScannerCaching()
          Get the number of rows for caching that will be passed to scanners
 Pair<byte[][],byte[][]> getStartEndKeys()
          Gets the starting and ending row keys for every region in the currently open table
 byte[][] getStartKeys()
          Gets the starting row key for every region in the currently open table
 HTableDescriptor getTableDescriptor()
           
 byte[] getTableName()
           
 ArrayList<BatchUpdate> getWriteBuffer()
          Get the write buffer
 long getWriteBufferSize()
          Get the maximum size in bytes of the write buffer for this HTable
 long incrementColumnValue(byte[] row, byte[] column, long amount)
           
 boolean isAutoFlush()
          Get the value of autoFlush.
static boolean isTableEnabled(byte[] tableName)
           
static boolean isTableEnabled(HBaseConfiguration conf, byte[] tableName)
           
static boolean isTableEnabled(HBaseConfiguration conf, String tableName)
           
static boolean isTableEnabled(String tableName)
           
 RowLock lockRow(byte[] row)
          Obtain a row lock
 void setAutoFlush(boolean autoFlush)
          Set if this instanciation of HTable will autoFlush
 void setScannerCaching(int scannerCaching)
          Set the number of rows for caching that will be passed to scanners
 void setWriteBufferSize(long writeBufferSize)
          Set the size of the buffer in bytes
 void unlockRow(RowLock rl)
          Release a row lock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scannerTimeout

protected final int scannerTimeout

scannerCaching

protected int scannerCaching
Constructor Detail

HTable

public HTable(String tableName)
       throws IOException
Creates an object to access a HBase table

Parameters:
tableName - name of the table
Throws:
IOException

HTable

public HTable(byte[] tableName)
       throws IOException
Creates an object to access a HBase table

Parameters:
tableName - name of the table
Throws:
IOException

HTable

public HTable(HBaseConfiguration conf,
              String tableName)
       throws IOException
Creates an object to access a HBase table

Parameters:
conf - configuration object
tableName - name of the table
Throws:
IOException

HTable

public HTable(HBaseConfiguration conf,
              byte[] tableName)
       throws IOException
Creates an object to access a HBase table

Parameters:
conf - configuration object
tableName - name of the table
Throws:
IOException
Method Detail

isTableEnabled

public static boolean isTableEnabled(String tableName)
                              throws IOException
Parameters:
tableName - name of table to check
Returns:
true if table is on-line
Throws:
IOException

isTableEnabled

public static boolean isTableEnabled(byte[] tableName)
                              throws IOException
Parameters:
tableName - name of table to check
Returns:
true if table is on-line
Throws:
IOException

isTableEnabled

public static boolean isTableEnabled(HBaseConfiguration conf,
                                     String tableName)
                              throws IOException
Parameters:
conf - HBaseConfiguration object
tableName - name of table to check
Returns:
true if table is on-line
Throws:
IOException

isTableEnabled

public static boolean isTableEnabled(HBaseConfiguration conf,
                                     byte[] tableName)
                              throws IOException
Parameters:
conf - HBaseConfiguration object
tableName - name of table to check
Returns:
true if table is on-line
Throws:
IOException

getRegionLocation

public HRegionLocation getRegionLocation(String row)
                                  throws IOException
Find region location hosting passed row using cached info

Parameters:
row - Row to find.
Returns:
Location of row.
Throws:
IOException

getRegionLocation

public HRegionLocation getRegionLocation(byte[] row)
                                  throws IOException
Find region location hosting passed row using cached info

Parameters:
row - Row to find.
Returns:
Location of row.
Throws:
IOException

getTableName

public byte[] getTableName()
Returns:
the table name

getConnection

public HConnection getConnection()
Used by unit tests and tools to do low-level manipulations. Not for general use.

Returns:
An HConnection instance.

getScannerCaching

public int getScannerCaching()
Get the number of rows for caching that will be passed to scanners

Returns:
the number of rows for caching

setScannerCaching

public void setScannerCaching(int scannerCaching)
Set the number of rows for caching that will be passed to scanners

Parameters:
scannerCaching - the number of rows for caching

getTableDescriptor

public HTableDescriptor getTableDescriptor()
                                    throws IOException
Returns:
table metadata
Throws:
IOException

getStartKeys

public byte[][] getStartKeys()
                      throws IOException
Gets the starting row key for every region in the currently open table

Returns:
Array of region starting row keys
Throws:
IOException

getEndKeys

public byte[][] getEndKeys()
                    throws IOException
Gets the ending row key for every region in the currently open table

Returns:
Array of region ending row keys
Throws:
IOException

getStartEndKeys

public Pair<byte[][],byte[][]> getStartEndKeys()
                                        throws IOException
Gets the starting and ending row keys for every region in the currently open table

Returns:
Pair of arrays of region starting and ending row keys
Throws:
IOException

getRegionsInfo

public Map<HRegionInfo,HServerAddress> getRegionsInfo()
                                               throws IOException
Get all the regions and their address for this table

Returns:
A map of HRegionInfo with it's server address
Throws:
IOException

get

public Cell get(String row,
                String column)
         throws IOException
Get a single value for the specified row and column

Parameters:
row - row key
column - column name
Returns:
value for specified row/column
Throws:
IOException

get

public Cell[] get(String row,
                  String column,
                  int numVersions)
           throws IOException
Get a single value for the specified row and column

Parameters:
row - row key
column - column name
numVersions - - number of versions to retrieve
Returns:
value for specified row/column
Throws:
IOException

get

public Cell get(byte[] row,
                byte[] column)
         throws IOException
Get a single value for the specified row and column

Parameters:
row - row key
column - column name
Returns:
value for specified row/column
Throws:
IOException

get

public Cell[] get(byte[] row,
                  byte[] column,
                  int numVersions)
           throws IOException
Get the specified number of versions of the specified row and column

Parameters:
row - row key
column - column name
numVersions - number of versions to retrieve
Returns:
Array of Cells.
Throws:
IOException

get

public Cell[] get(String row,
                  String column,
                  long timestamp,
                  int numVersions)
           throws IOException
Get the specified number of versions of the specified row and column with the specified timestamp.

Parameters:
row - - row key
column - - column name
timestamp - - timestamp
numVersions - - number of versions to retrieve
Returns:
- array of values that match the above criteria
Throws:
IOException

get

public Cell[] get(byte[] row,
                  byte[] column,
                  long timestamp,
                  int numVersions)
           throws IOException
Get the specified number of versions of the specified row and column with the specified timestamp.

Parameters:
row - - row key
column - - column name
timestamp - - timestamp
numVersions - - number of versions to retrieve
Returns:
- array of values that match the above criteria
Throws:
IOException

getRow

public RowResult getRow(String row)
                 throws IOException
Get all the data for the specified row at the latest timestamp

Parameters:
row - row key
Returns:
RowResult is null if row does not exist.
Throws:
IOException

getRow

public RowResult getRow(byte[] row)
                 throws IOException
Get all the data for the specified row at the latest timestamp

Parameters:
row - row key
Returns:
RowResult is null if row does not exist.
Throws:
IOException

getRow

public RowResult getRow(String row,
                        int numVersions)
                 throws IOException
Get more than one version of all columns for the specified row

Parameters:
row - row key
numVersions - number of versions to return
Returns:
RowResult is null if row does not exist.
Throws:
IOException

getRow

public RowResult getRow(byte[] row,
                        int numVersions)
                 throws IOException
Get more than one version of all columns for the specified row

Parameters:
row - row key
numVersions - number of versions to return
Returns:
RowResult is null if row does not exist.
Throws:
IOException

getRow

public RowResult getRow(String row,
                        long ts)
                 throws IOException
Get all the data for the specified row at a specified timestamp

Parameters:
row - row key
ts - timestamp
Returns:
RowResult is null if row does not exist.
Throws:
IOException

getRow

public RowResult getRow(byte[] row,
                        long ts)
                 throws IOException
Get all the data for the specified row at a specified timestamp

Parameters:
row - row key
ts - timestamp
Returns:
RowResult is null if row does not exist.
Throws:
IOException

getRow

public RowResult getRow(String row,
                        long ts,
                        int numVersions)
                 throws IOException
Throws:
IOException

getRow

public RowResult getRow(byte[] row,
                        long timestamp,
                        int numVersions)
                 throws IOException
Get more than one version of all columns for the specified row at a specified timestamp

Parameters:
row - row key
timestamp - timestamp
numVersions - number of versions to return
Returns:
RowResult is null if row does not exist.
Throws:
IOException

getRow

public RowResult getRow(String row,
                        String[] columns)
                 throws IOException
Get selected columns for the specified row at the latest timestamp

Parameters:
row - row key
columns - Array of column names and families you want to retrieve.
Returns:
RowResult is null if row does not exist.
Throws:
IOException

getRow

public RowResult getRow(byte[] row,
                        byte[][] columns)
                 throws IOException
Get selected columns for the specified row at the latest timestamp

Parameters:
row - row key
columns - Array of column names and families you want to retrieve.
Returns:
RowResult is null if row does not exist.
Throws:
IOException

getRow

public RowResult getRow(String row,
                        String[] columns,
                        int numVersions)
                 throws IOException
Get more than one version of selected columns for the specified row

Parameters:
row - row key
columns - Array of column names and families you want to retrieve.
numVersions - number of versions to return
Returns:
RowResult is null if row does not exist.
Throws:
IOException

getRow

public RowResult getRow(byte[] row,
                        byte[][] columns,
                        int numVersions)
                 throws IOException
Get more than one version of selected columns for the specified row

Parameters:
row - row key
columns - Array of column names and families you want to retrieve.
numVersions - number of versions to return
Returns:
RowResult is null if row does not exist.
Throws:
IOException

getRow

public RowResult getRow(String row,
                        String[] columns,
                        long ts)
                 throws IOException
Get selected columns for the specified row at a specified timestamp

Parameters:
row - row key
columns - Array of column names and families you want to retrieve.
ts - timestamp
Returns:
RowResult is null if row does not exist.
Throws:
IOException

getRow

public RowResult getRow(byte[] row,
                        byte[][] columns,
                        long ts)
                 throws IOException
Get selected columns for the specified row at a specified timestamp

Parameters:
row - row key
columns - Array of column names and families you want to retrieve.
ts - timestamp
Returns:
RowResult is null if row does not exist.
Throws:
IOException

getRow

public RowResult getRow(String row,
                        String[] columns,
                        long timestamp,
                        int numVersions,
                        RowLock rowLock)
                 throws IOException
Throws:
IOException

getRow

public RowResult getRow(byte[] row,
                        byte[][] columns,
                        long ts,
                        int numVersions,
                        RowLock rl)
                 throws IOException
Get selected columns for the specified row at a specified timestamp using existing row lock.

Parameters:
row - row key
columns - Array of column names and families you want to retrieve.
ts - timestamp
rl - row lock
Returns:
RowResult is null if row does not exist.
Throws:
IOException

getClosestRowBefore

public RowResult getClosestRowBefore(byte[] row,
                                     byte[] columnFamily)
                              throws IOException
Throws:
IOException

getScanner

public Scanner getScanner(String[] columns)
                   throws IOException
Get a scanner on the current table starting at first row. Return the specified columns.

Parameters:
columns - 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: \+|^&*$[]]}{)(.
Returns:
scanner
Throws:
IOException

getScanner

public Scanner getScanner(String[] columns,
                          String startRow)
                   throws IOException
Get a scanner on the current table starting at the specified row. Return the specified columns.

Parameters:
columns - 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: \+|^&*$[]]}{)(.
startRow - starting row in table to scan
Returns:
scanner
Throws:
IOException

getScanner

public Scanner getScanner(byte[][] columns)
                   throws IOException
Get a scanner on the current table starting at first row. Return the specified columns.

Parameters:
columns - 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: \+|^&*$[]]}{)(.
Returns:
scanner
Throws:
IOException

getScanner

public Scanner getScanner(byte[][] columns,
                          byte[] startRow)
                   throws IOException
Get a scanner on the current table starting at the specified row. Return the specified columns.

Parameters:
columns - 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: \+|^&*$[]]}{)(.
startRow - starting row in table to scan
Returns:
scanner
Throws:
IOException

getScanner

public Scanner getScanner(byte[][] columns,
                          byte[] startRow,
                          long timestamp)
                   throws IOException
Get a scanner on the current table starting at the specified row. Return the specified columns.

Parameters:
columns - 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: \+|^&*$[]]}{)(.
startRow - starting row in table to scan
timestamp - only return results whose timestamp <= this value
Returns:
scanner
Throws:
IOException

getScanner

public Scanner getScanner(byte[][] columns,
                          byte[] startRow,
                          RowFilterInterface filter)
                   throws IOException
Get a scanner on the current table starting at the specified row. Return the specified columns.

Parameters:
columns - 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: \+|^&*$[]]}{)(.
startRow - starting row in table to scan
filter - a row filter using row-key regexp and/or column data filter.
Returns:
scanner
Throws:
IOException

getScanner

public Scanner getScanner(byte[][] columns,
                          byte[] startRow,
                          byte[] stopRow)
                   throws IOException
Get a scanner on the current table starting at the specified row and ending just before stopRow. Return the specified columns.

Parameters:
columns - 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: \+|^&*$[]]}{)(.
startRow - starting row in table to scan
stopRow - Row to stop scanning on. Once we hit this row we stop returning values; i.e. we return the row before this one but not the stopRow itself.
Returns:
scanner
Throws:
IOException

getScanner

public Scanner getScanner(String[] columns,
                          String startRow,
                          String stopRow,
                          long timestamp)
                   throws IOException
Get a scanner on the current table starting at the specified row and ending just before stopRow. Return the specified columns.

Parameters:
columns - 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: \+|^&*$[]]}{)(.
startRow - starting row in table to scan
stopRow - Row to stop scanning on. Once we hit this row we stop returning values; i.e. we return the row before this one but not the stopRow itself.
timestamp - only return results whose timestamp <= this value
Returns:
scanner
Throws:
IOException

getScanner

public Scanner getScanner(byte[][] columns,
                          byte[] startRow,
                          byte[] stopRow,
                          long timestamp)
                   throws IOException
Get a scanner on the current table starting at the specified row and ending just before stopRow. Return the specified columns.

Parameters:
columns - 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: \+|^&*$[]]}{)(.
startRow - starting row in table to scan
stopRow - Row to stop scanning on. Once we hit this row we stop returning values; i.e. we return the row before this one but not the stopRow itself.
timestamp - only return results whose timestamp <= this value
Returns:
scanner
Throws:
IOException

getScanner

public Scanner getScanner(String[] columns,
                          String startRow,
                          long timestamp,
                          RowFilterInterface filter)
                   throws IOException
Get a scanner on the current table starting at the specified row. Return the specified columns.

Parameters:
columns - 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: \+|^&*$[]]}{)(.
startRow - starting row in table to scan
timestamp - only return results whose timestamp <= this value
filter - a row filter using row-key regexp and/or column data filter.
Returns:
scanner
Throws:
IOException

getScanner

public Scanner getScanner(byte[][] columns,
                          byte[] startRow,
                          long timestamp,
                          RowFilterInterface filter)
                   throws IOException
Get a scanner on the current table starting at the specified row. Return the specified columns.

Parameters:
columns - 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: \+|^&*$[]]}{)(.
startRow - starting row in table to scan
timestamp - only return results whose timestamp <= this value
filter - a row filter using row-key regexp and/or column data filter.
Returns:
scanner
Throws:
IOException

deleteAll

public void deleteAll(byte[] row)
               throws IOException
Completely delete the row's cells.

Parameters:
row - Key of the row you want to completely delete.
Throws:
IOException

deleteAll

public void deleteAll(String row)
               throws IOException
Completely delete the row's cells.

Parameters:
row - Key of the row you want to completely delete.
Throws:
IOException

deleteAll

public void deleteAll(byte[] row,
                      byte[] column)
               throws IOException
Completely delete the row's cells.

Parameters:
row - Key of the row you want to completely delete.
column - column to be deleted
Throws:
IOException

deleteAll

public void deleteAll(byte[] row,
                      long ts)
               throws IOException
Completely delete the row's cells.

Parameters:
row - Key of the row you want to completely delete.
ts - Delete all cells of the same timestamp or older.
Throws:
IOException

deleteAll

public void deleteAll(String row,
                      long ts)
               throws IOException
Completely delete the row's cells.

Parameters:
row - Key of the row you want to completely delete.
ts - Delete all cells of the same timestamp or older.
Throws:
IOException

deleteAll

public void deleteAll(String row,
                      String column)
               throws IOException
Delete all cells that match the passed row and column.

Parameters:
row - Row to update
column - name of column whose value is to be deleted
Throws:
IOException

deleteAll

public void deleteAll(String row,
                      String column,
                      long ts)
               throws IOException
Delete all cells that match the passed row and column and whose timestamp is equal-to or older than the passed timestamp.

Parameters:
row - Row to update
column - name of column whose value is to be deleted
ts - Delete all cells of the same timestamp or older.
Throws:
IOException

deleteAll

public void deleteAll(byte[] row,
                      byte[] column,
                      long ts)
               throws IOException
Delete all cells that match the passed row and column and whose timestamp is equal-to or older than the passed timestamp.

Parameters:
row - Row to update
column - name of column whose value is to be deleted
ts - Delete all cells of the same timestamp or older.
Throws:
IOException

deleteAll

public void deleteAll(byte[] row,
                      byte[] column,
                      long ts,
                      RowLock rl)
               throws IOException
Delete all cells that match the passed row and column and whose timestamp is equal-to or older than the passed timestamp, using an existing row lock.

Parameters:
row - Row to update
column - name of column whose value is to be deleted
ts - Delete all cells of the same timestamp or older.
rl - Existing row lock
Throws:
IOException

deleteAllByRegex

public void deleteAllByRegex(String row,
                             String colRegex)
                      throws IOException
Delete all cells that match the passed row and column.

Parameters:
row - Row to update
colRegex - column regex expression
Throws:
IOException

deleteAllByRegex

public void deleteAllByRegex(String row,
                             String colRegex,
                             long ts)
                      throws IOException
Delete all cells that match the passed row and column and whose timestamp is equal-to or older than the passed timestamp.

Parameters:
row - Row to update
colRegex - Column Regex expression
ts - Delete all cells of the same timestamp or older.
Throws:
IOException

deleteAllByRegex

public void deleteAllByRegex(byte[] row,
                             String colRegex,
                             long ts)
                      throws IOException
Delete all cells that match the passed row and column and whose timestamp is equal-to or older than the passed timestamp.

Parameters:
row - Row to update
colRegex - Column Regex expression
ts - Delete all cells of the same timestamp or older.
Throws:
IOException

deleteAllByRegex

public void deleteAllByRegex(byte[] row,
                             String colRegex,
                             long ts,
                             RowLock rl)
                      throws IOException
Delete all cells that match the passed row and column and whose timestamp is equal-to or older than the passed timestamp, using an existing row lock.

Parameters:
row - Row to update
colRegex - Column regex expression
ts - Delete all cells of the same timestamp or older.
rl - Existing row lock
Throws:
IOException

deleteFamily

public void deleteFamily(String row,
                         String family)
                  throws IOException
Delete all cells for a row with matching column family at all timestamps.

Parameters:
row - The row to operate on
family - The column family to match
Throws:
IOException

deleteFamily

public void deleteFamily(byte[] row,
                         byte[] family)
                  throws IOException
Delete all cells for a row with matching column family at all timestamps.

Parameters:
row - The row to operate on
family - The column family to match
Throws:
IOException

deleteFamily

public void deleteFamily(String row,
                         String family,
                         long timestamp)
                  throws IOException
Delete all cells for a row with matching column family with timestamps less than or equal to timestamp.

Parameters:
row - The row to operate on
family - The column family to match
timestamp - Timestamp to match
Throws:
IOException

deleteFamily

public void deleteFamily(byte[] row,
                         byte[] family,
                         long timestamp)
                  throws IOException
Delete all cells for a row with matching column family with timestamps less than or equal to timestamp.

Parameters:
row - The row to operate on
family - The column family to match
timestamp - Timestamp to match
Throws:
IOException

deleteFamily

public void deleteFamily(byte[] row,
                         byte[] family,
                         long timestamp,
                         RowLock rl)
                  throws IOException
Delete all cells for a row with matching column family with timestamps less than or equal to timestamp, using existing row lock.

Parameters:
row - The row to operate on
family - The column family to match
timestamp - Timestamp to match
rl - Existing row lock
Throws:
IOException

deleteFamilyByRegex

public void deleteFamilyByRegex(String row,
                                String familyRegex)
                         throws IOException
Delete all cells for a row with matching column family regex at all timestamps.

Parameters:
row - The row to operate on
familyRegex - Column family regex
Throws:
IOException

deleteFamilyByRegex

public void deleteFamilyByRegex(byte[] row,
                                String familyRegex)
                         throws IOException
Delete all cells for a row with matching column family regex at all timestamps.

Parameters:
row - The row to operate on
familyRegex - Column family regex
Throws:
IOException

deleteFamilyByRegex

public void deleteFamilyByRegex(String row,
                                String familyRegex,
                                long timestamp)
                         throws IOException
Delete all cells for a row with matching column family regex with timestamps less than or equal to timestamp.

Parameters:
row - The row to operate on
familyRegex - Column family regex
timestamp - Timestamp to match
Throws:
IOException

deleteFamilyByRegex

public void deleteFamilyByRegex(byte[] row,
                                String familyRegex,
                                long timestamp)
                         throws IOException
Delete all cells for a row with matching column family regex with timestamps less than or equal to timestamp.

Parameters:
row - The row to operate on
familyRegex - Column family regex
timestamp - Timestamp to match
Throws:
IOException

deleteFamilyByRegex

public void deleteFamilyByRegex(byte[] row,
                                String familyRegex,
                                long timestamp,
                                RowLock r1)
                         throws IOException
Delete all cells for a row with matching column family regex with timestamps less than or equal to timestamp, using existing row lock.

Parameters:
row - The row to operate on
familyRegex - Column Family Regex
timestamp - Timestamp to match
r1 - Existing row lock
Throws:
IOException

exists

public boolean exists(byte[] row)
               throws IOException
Test for the existence of a row in the table.

Parameters:
row - The row
Returns:
true if the row exists, false otherwise
Throws:
IOException

exists

public boolean exists(byte[] row,
                      byte[] column)
               throws IOException
Test for the existence of a row and column in the table.

Parameters:
row - The row
column - The column
Returns:
true if the row exists, false otherwise
Throws:
IOException

exists

public boolean exists(byte[] row,
                      byte[] column,
                      long timestamp)
               throws IOException
Test for the existence of a coordinate in the table.

Parameters:
row - The row
column - The column
timestamp - The timestamp
Returns:
true if the specified coordinate exists
Throws:
IOException

exists

public boolean exists(byte[] row,
                      byte[] column,
                      long timestamp,
                      RowLock rl)
               throws IOException
Test for the existence of a coordinate in the table.

Parameters:
row - The row
column - The column
timestamp - The timestamp
rl - Existing row lock
Returns:
true if the specified coordinate exists
Throws:
IOException

commit

public void commit(BatchUpdate batchUpdate)
            throws IOException
Commit a BatchUpdate to the table. If autoFlush is false, the update is buffered

Parameters:
batchUpdate -
Throws:
IOException

commit

public void commit(BatchUpdate batchUpdate,
                   RowLock rl)
            throws IOException
Commit a BatchUpdate to the table using existing row lock. If autoFlush is false, the update is buffered

Parameters:
batchUpdate -
rl - Existing row lock
Throws:
IOException

commit

public void commit(List<BatchUpdate> batchUpdates)
            throws IOException
Commit a List of BatchUpdate to the table. If autoFlush is false, the updates are buffered

Parameters:
batchUpdates -
Throws:
IOException

checkAndSave

public boolean checkAndSave(BatchUpdate batchUpdate,
                            HbaseMapWritable<byte[],byte[]> expectedValues,
                            RowLock rl)
                     throws IOException
Atomically checks if a row's values match the expectedValues. If it does, it uses the batchUpdate to update the row.

Parameters:
batchUpdate - batchupdate to apply if check is successful
expectedValues - values to check
rl - rowlock
Throws:
IOException

flushCommits

public void flushCommits()
                  throws IOException
Commit to the table the buffer of BatchUpdate. Called automaticaly in the commit methods when autoFlush is true.

Throws:
IOException

close

public void close()
           throws IOException
Release held resources

Throws:
IOException

lockRow

public RowLock lockRow(byte[] row)
                throws IOException
Obtain a row lock

Parameters:
row - The row to lock
Returns:
rowLock RowLock containing row and lock id
Throws:
IOException

unlockRow

public void unlockRow(RowLock rl)
               throws IOException
Release a row lock

Parameters:
rl - The row lock to release
Throws:
IOException

isAutoFlush

public boolean isAutoFlush()
Get the value of autoFlush. If true, updates will not be buffered

Returns:
value of autoFlush

setAutoFlush

public void setAutoFlush(boolean autoFlush)
Set if this instanciation of HTable will autoFlush

Parameters:
autoFlush -

getWriteBufferSize

public long getWriteBufferSize()
Get the maximum size in bytes of the write buffer for this HTable

Returns:
the size of the write buffer in bytes

setWriteBufferSize

public void setWriteBufferSize(long writeBufferSize)
Set the size of the buffer in bytes

Parameters:
writeBufferSize -

getWriteBuffer

public ArrayList<BatchUpdate> getWriteBuffer()
Get the write buffer

Returns:
the current write buffer

incrementColumnValue

public long incrementColumnValue(byte[] row,
                                 byte[] column,
                                 long amount)
                          throws IOException
Throws:
IOException


Copyright © 2008 The Apache Software Foundation