如何使用 cbt 从 BigTable 中删除带有前缀键的行范围

Fuy*_*Liu 3 bigtable google-cloud-bigtable cbt

看起来我可以用 cbt 读取带有前缀键的行

cbt -project someproject -instance someinstance read sometable prefix=abc
Run Code Online (Sandbox Code Playgroud)

但是我如何使用 cbtcommand 删除上述命令选择的那些行呢?

pes*_*ato 6

为了能够仅使用 来执行此操作cbt,您需要解析 read 命令的输出并迭代每个结果,对特定行执行 deleterow 命令。

\n\n

或者,您可以使用Bigtable\xe2\x80\x99s 客户端库之一,这会快得多。

\n\n

与 Java 客户端一样,您也会在其他客户端中找到相同的功能,例如C# 客户端库的DropRowRangeRequest 类

\n\n

编辑:要仅使用 cbt 删除几行,您可以使用如下内容:

\n\n
for x in `cbt -project my-project -instance my-instace read my-table prefix=abc | grep "abc"`; do \n  cbt -project my-project -instance my-instace deleterow my-table $x;\ndone\n
Run Code Online (Sandbox Code Playgroud)\n

  • @FuyangLiu 这是我一直在使用的 `xargs` 变体 `cbt -instance my-instance read my-table prefix=abc | grep '^abc' | grep '^abc' | xargs -I '{}' cbt -instance my-instance deleterow my-table {}` (4认同)