HBase Client: Delete Method

Single Deletes

The variant of the delete() call that takes a single Delete instance is:


void delete(Delete delete) throws IOException

HBase中用来做删除操作的接口,通过构造一个Delete的实例,传给delete就OK了!


Just as with the get and put calls you have seen already, you will have to create aDelete instance and then adding details about the data you want to remove. The constructors are:


Delete(byte[] row)
Delete(byte[] row, long timestamp, RowLock rowLock)

两个基本的构造函数,row key是必须存在的,另外可以根据需要是否client提供rowLock。其他的细节使用下面的函数设定来缩小范围。


You need to provide the row you want to modify, and optionally provide a rowLock, an instance of RowLock to specify your own lock details, in case you want to modify the same row more than once subsequently. Otherwise you would be wise to narrow down what you want to remove from the given row, using one of the following methods:


Delete deleteFamily(byte[] family)
Delete deleteFamily(byte[] family, long timestamp)
Delete deleteColumns(byte[] family, byte[] qualifier)
Delete deleteColumns(byte[] family, byte[] qualifier, long timestamp)
Delete deleteColumn(byte[] family, byte[] qualifier)
Delete deleteColumn(byte[] family, byte[] qualifier, long timestamp)
void setTimestamp(long timestamp)

这里面的方法分为四类:1)deleteFamily 2)deleteColomns 3)deleteColumn 4)setTimestamp 

  • 不带timestamp表示删除column family里面所有版本的cells,而带timestamp表示只删除column family指定timestamp版本或者所有更老的版本的cells。
  • 不带timestamp表示删除column qualifier所有版本的cells,而带timestamp表示只删除指定timestamp版本或者更老版本的cells。
  • 不带timestamp表示删除最新版本的cell,而带timestamp表示删除指定timestamp的cell
  • 表示删除指定timestamp或者所有更老版本的cells

You do have a choice to narrow in on what to remove using four types of calls: first you can use the deleteFamily() methods to remove an entire column family, including all contained columns. You have the option to specify a timestamp that triggers more specific filtering of cell versions. If specified, the timestamp matches the same and all older versions of all columns.

The next type is deleteColumns(), which operates on exactly one column and deletes either all versions of that cell when no timestamp is given, or all matching and older versions when a timestamp is specified.t

The third type is similar, using deleteColumn(). They also operate on a specific, given column only, but either delete the most current, or the specified version, i.e., the one with the exact matching timestamp.


Finally there is just setTimestamp(), which is not considered when using any of the other three types of calls. But if you do not specify either a family or a column then this call can make the difference between deleting the entire row, or just all contained columns, in all column families, that match or have an older timestamp compared to the given one. Table 3.5, “Functionality matrix of the delete() calls”shows the functionality in a matrix to make the semantics more readable.

Table 3.5. Functionality matrix of the delete() calls

MethodDeletes without TimestampDeletes With Timestamp
noneEntire row, i.e., all columns, all versionsAll versions of all columns in all column families, whose timestamp is equal or older than the given timestamp
deleteColumn()Only the latest version of the given column, older versions are keptOnly exactly the specified version of the given column, with the matching timestamp. If non-existent then nothing is deleted.
deleteColumns()All versions of the given columnVersions equal or older than the given timestamp of the given column
deleteFamily()All columns (including all versions) of the given familyVersions equal or older than the given timestamp of all column of the given family


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值