org.apache.hadoop.hbase.client
Class Delete

java.lang.Object
  extended by org.apache.hadoop.hbase.client.Delete
All Implemented Interfaces:
Comparable<Row>, Row, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable<Row>

public class Delete
extends Object
implements org.apache.hadoop.io.Writable, Row, Comparable<Row>

Used to perform Delete operations on a single row.

To delete an entire row, instantiate a Delete object with the row to delete. To further define the scope of what to delete, perform additional methods as outlined below.

To delete specific families, execute deleteFamily for each family to delete.

To delete multiple versions of specific columns, execute deleteColumns for each column to delete.

To delete specific versions of specific columns, execute deleteColumn for each column version to delete.

Specifying timestamps, deleteFamily and deleteColumns will delete all versions with a timestamp less than or equal to that passed. If no timestamp is specified, an entry is added with a timestamp of 'now' where 'now' is the servers's System.currentTimeMillis(). Specifying a timestamp to the deleteColumn method will delete versions only with a timestamp equal to that specified. If no timestamp is passed to deleteColumn, internally, it figures the most recent cell's timestamp and adds a delete at that timestamp; i.e. it deletes the most recently added cell.

The timestamp passed to the constructor is used ONLY for delete of rows. For anything less -- a deleteColumn, deleteColumns or deleteFamily -- then you need to use the method overrides that take a timestamp. The constructor timestamp is not referenced.


Constructor Summary
Delete()
          Constructor for Writable.
Delete(byte[] row)
          Create a Delete operation for the specified row.
Delete(byte[] row, long timestamp, RowLock rowLock)
          Create a Delete operation for the specified row and timestamp, using an optional row lock.
Delete(Delete d)
           
 
Method Summary
 int compareTo(Row d)
           
 Delete deleteColumn(byte[] column)
          Deprecated. use deleteColumn(byte[], byte[]) instead
 Delete deleteColumn(byte[] family, byte[] qualifier)
          Delete the latest version of the specified column.
 Delete deleteColumn(byte[] family, byte[] qualifier, long timestamp)
          Delete the specified version of the specified column.
 Delete deleteColumns(byte[] family, byte[] qualifier)
          Delete all versions of the specified column.
 Delete deleteColumns(byte[] family, byte[] qualifier, long timestamp)
          Delete all versions of the specified column with a timestamp less than or equal to the specified timestamp.
 Delete deleteColumns(byte[] column, long timestamp)
          Deprecated. use deleteColumn(byte[], byte[], long) instead
 Delete deleteFamily(byte[] family)
          Delete all versions of all columns of the specified family.
 Delete deleteFamily(byte[] family, long timestamp)
          Delete all columns of the specified family with a timestamp less than or equal to the specified timestamp.
 Map<byte[],List<KeyValue>> getFamilyMap()
          Method for retrieving the delete's familyMap
 long getLockId()
          Method for retrieving the delete's lock ID.
 byte[] getRow()
          Method for retrieving the delete's row
 RowLock getRowLock()
          Method for retrieving the delete's RowLock
 long getTimeStamp()
          Method for retrieving the delete's timestamp
 boolean isEmpty()
          Method to check if the familyMap is empty
 void readFields(DataInput in)
           
 void setTimestamp(long timestamp)
          Set the timestamp of the delete.
 String toString()
           
 void write(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Delete

public Delete()
Constructor for Writable. DO NOT USE


Delete

public Delete(byte[] row)
Create a Delete operation for the specified row.

If no further operations are done, this will delete everything associated with the specified row (all versions of all columns in all families).

Parameters:
row - row key

Delete

public Delete(byte[] row,
              long timestamp,
              RowLock rowLock)
Create a Delete operation for the specified row and timestamp, using an optional row lock.

If no further operations are done, this will delete all columns in all families of the specified row with a timestamp less than or equal to the specified timestamp.

This timestamp is ONLY used for a delete row operation. If specifying families or columns, you must specify each timestamp individually.

Parameters:
row - row key
timestamp - maximum version timestamp (only for delete row)
rowLock - previously acquired row lock, or null

Delete

public Delete(Delete d)
Parameters:
d - Delete to clone.
Method Detail

compareTo

public int compareTo(Row d)
Specified by:
compareTo in interface Comparable<Row>

isEmpty

public boolean isEmpty()
Method to check if the familyMap is empty

Returns:
true if empty, false otherwise

deleteFamily

public Delete deleteFamily(byte[] family)
Delete all versions of all columns of the specified family.

Overrides previous calls to deleteColumn and deleteColumns for the specified family.

Parameters:
family - family name
Returns:
this for invocation chaining

deleteFamily

public Delete deleteFamily(byte[] family,
                           long timestamp)
Delete all columns of the specified family with a timestamp less than or equal to the specified timestamp.

Overrides previous calls to deleteColumn and deleteColumns for the specified family.

Parameters:
family - family name
timestamp - maximum version timestamp
Returns:
this for invocation chaining

deleteColumns

public Delete deleteColumns(byte[] family,
                            byte[] qualifier)
Delete all versions of the specified column.

Parameters:
family - family name
qualifier - column qualifier
Returns:
this for invocation chaining

deleteColumns

public Delete deleteColumns(byte[] family,
                            byte[] qualifier,
                            long timestamp)
Delete all versions of the specified column with a timestamp less than or equal to the specified timestamp.

Parameters:
family - family name
qualifier - column qualifier
timestamp - maximum version timestamp
Returns:
this for invocation chaining

deleteColumn

public Delete deleteColumn(byte[] family,
                           byte[] qualifier)
Delete the latest version of the specified column. This is an expensive call in that on the server-side, it first does a get to find the latest versions timestamp. Then it adds a delete using the fetched cells timestamp.

Parameters:
family - family name
qualifier - column qualifier
Returns:
this for invocation chaining

deleteColumn

public Delete deleteColumn(byte[] family,
                           byte[] qualifier,
                           long timestamp)
Delete the specified version of the specified column.

Parameters:
family - family name
qualifier - column qualifier
timestamp - version timestamp
Returns:
this for invocation chaining

getFamilyMap

public Map<byte[],List<KeyValue>> getFamilyMap()
Method for retrieving the delete's familyMap

Returns:
familyMap

getRow

public byte[] getRow()
Method for retrieving the delete's row

Specified by:
getRow in interface Row
Returns:
row

getRowLock

public RowLock getRowLock()
Method for retrieving the delete's RowLock

Returns:
RowLock

getLockId

public long getLockId()
Method for retrieving the delete's lock ID.

Returns:
The lock ID.

getTimeStamp

public long getTimeStamp()
Method for retrieving the delete's timestamp

Returns:
timestamp

setTimestamp

public void setTimestamp(long timestamp)
Set the timestamp of the delete.

Parameters:
timestamp -

toString

public String toString()
Overrides:
toString in class Object
Returns:
string

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException

deleteColumns

public Delete deleteColumns(byte[] column,
                            long timestamp)
Deprecated. use deleteColumn(byte[], byte[], long) instead

Delete all versions of the specified column, given in family:qualifier notation, and with a timestamp less than or equal to the specified timestamp.

Parameters:
column - colon-delimited family and qualifier
timestamp - maximum version timestamp
Returns:
this for invocation chaining

deleteColumn

public Delete deleteColumn(byte[] column)
Deprecated. use deleteColumn(byte[], byte[]) instead

Delete the latest version of the specified column, given in family:qualifier notation.

Parameters:
column - colon-delimited family and qualifier
Returns:
this for invocation chaining


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.