简体   繁体   English

如何使用HBase API删除Google Cloud Bigtable中单行的列

[英]How to delete a column of a single row in Google Cloud Bigtable with HBase API

I'm using the HBase API to access Google Cloud Bigtable, but whenever I try to delete a column: 我正在使用HBase API访问Google Cloud Bigtable,但每当我尝试删除列时:

Delete delete = new Delete(r.getRow());
delete.addColumn(CF, Bytes.toBytes(d.seqid()));
delete.addColumn(CF, COL_LEASE);
tasksTable.delete(delete);

I'm getting an UnsupportedOperationException : 我收到了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)

I saw in the code it occurs here . 我在代码中看到它出现在这里

I can delete the entire row fine from the HBase Java client, and I can delete individual columns fine by using the HBase shell. 我可以从HBase Java客户端中删除整行,并且可以使用HBase shell删除单个列。

How can I delete columns without removing the row in the Java client? 如何在不删除Java客户端中的行的情况下删除列?

Sorry for your troubles. 对不起您的麻烦。 Bigtable and HBase differ in a couple of ways, and this is one of them. Bigtable和HBase在几个方面有所不同,这就是其中之一。

Delete delete = new Delete(rowKey);
delete.addColumns(COLUMN_FAMILY, qual); // the 's' matters
table.delete(delete);

HBase's Delete.addColumn deletes only the latest cell from the column. HBase的Delete.addColumn仅删除列中的最新单元格。 The Delete.addColumn_s_ means delete all cells (ie all the various timestamps). Delete.addColumn_s_表示删除所有单元格(即所有不同的时间戳)。 Alternatively, you can delete a specific cell via Delete.addColumn(byte[], byte[], long) where the long is a timestamp. 或者,您可以通过Delete.addColumn(byte[], byte[], long)删除特定单元格Delete.addColumn(byte[], byte[], long)其中long是时间戳。

The hbase shell delete uses deleteColumns which maps to addColumns under the cover. hbase shell delete 使用 deleteColumns映射到封面下的addColumns It also uses the s variation, which is why it works. 它也使用s变体,这就是它工作的原因。

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. 这里是我们完整的TestDelete套件,用于标识您作为@Category(KnownGap.class)呈现的用例,我们使用它来识别Bigtable客户端中缺少HBase功能的差异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM