Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use cbt to delete range of rows with a prefix key from BigTable?

Looks like I can read rows with a prefixed key using cbt like so:

cbt -project someproject -instance someinstance read sometable prefix=abc

But how can I use the cbt command to delete those rows as selected by the above command?

like image 904
Fuyang Liu Avatar asked Oct 24 '25 05:10

Fuyang Liu


1 Answers

To be able to do this using only cbt, you would to parse the output of the read command and iterate through each result executing the deleterow command for the specific rows.

Alternatively, you could use one of the Bigtable’s Client Libraries which would be much faster.

Like in the Java client, you will find this same functionality in the other clients as well, like in the DropRowRangeRequest class for the C# Client Library.

EDIT: To delete a few rows using only cbt you could use something like this:

for x in `cbt -project my-project -instance my-instance read my-table prefix=abc | grep "abc"`; do 
  cbt -project my-project -instance my-instance deleterow my-table $x;
done
like image 184
pessolato Avatar answered Oct 26 '25 23:10

pessolato



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!