问题描述
我正在使用HBase API来访问Google Cloud Bigtable,但是每当我尝试删除列时:
I'm using the HBase API to access Google Cloud Bigtable, but whenever I try to delete a column:
Delete delete = new Delete(r.getRow());
delete.addColumn(CF, Bytes.toBytes(d.seqid()));
delete.addColumn(CF, COL_LEASE);
tasksTable.delete(delete);
我得到一个UnsupportedOperationException
:
java.lang.UnsupportedOperationException: Cannot delete single latest cell.
at com.google.cloud.bigtable.hbase.adapters.DeleteAdapter.throwIfUnsupportedPointDelete(DeleteAdapter.java:85)
at com.google.cloud.bigtable.hbase.adapters.DeleteAdapter.adapt(DeleteAdapter.java:141)
at com.google.cloud.bigtable.hbase.adapters.HBaseRequestAdapter.adapt(HBaseRequestAdapter.java:71)
at com.google.cloud.bigtable.hbase.BigtableTable.delete(BigtableTable.java:307)
at queue.BigTableRowBackedQueue.poll(BigTableRowBackedQueue.java:54)
我在在此处进行编码.
我可以从HBase Java客户端删除整个行,也可以使用HBase Shell删除单个列.
I can delete the entire row fine from the HBase Java client, and I can delete individual columns fine by using the HBase shell.
如何在不删除Java客户端中的行的情况下删除列?
How can I delete columns without removing the row in the Java client?
推荐答案
很抱歉给您带来麻烦. Bigtable和HBase在几个方面有所不同,这就是其中之一.
Sorry for your troubles. Bigtable and HBase differ in a couple of ways, and this is one of them.
Delete delete = new Delete(rowKey);
delete.addColumns(COLUMN_FAMILY, qual); // the 's' matters
table.delete(delete);
HBase的Delete.addColumn
仅从列中删除最新的单元格. Delete.addColumn_s_
表示删除所有单元格(即所有各种时间戳记).或者,您可以通过Delete.addColumn(byte[], byte[], long)
删除特定的单元格,其中long
是时间戳.
HBase's Delete.addColumn
deletes only the latest cell from the column. The Delete.addColumn_s_
means delete all cells (i.e. all the various timestamps). Alternatively, you can delete a specific cell via Delete.addColumn(byte[], byte[], long)
where the long
is a timestamp.
hbase shell删除使用 deleteColumns
,它映射到封面下的addColumns
.它还使用s
变体,这就是它起作用的原因.
The hbase shell delete uses deleteColumns
which maps to addColumns
under the cover. It also uses the s
variation, which is why it works.
供参考此处是我们完整的TestDelete套件,它可以识别您以@Category(KnownGap.class)
形式出现的用例,我们可以用来识别缺少HBase功能的差异在Bigtable客户端中.
For reference here is our complete TestDelete suite which identify the use case you present as @Category(KnownGap.class)
which we use to identify differences missing HBase features in the Bigtable client.
这篇关于如何使用HBase API删除Google Cloud Bigtable中单行的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!