以下是Java
Kudu API清空
Kudu表的示例
代码:
```java
im
port org.apache.
kudu.client.*;
public class
KuduClearTable {
public static void main(String[] args) throws
KuduException {
// 定义
Kudu表信息
String masterAddr = "
kudu.master:7051";
String tableName = "example_table";
KuduClient client = new
KuduClient.
KuduClientBuilder(masterAddr).build();
KuduTable table = client.openTable(tableName);
// 定义
Kudu表扫描器,扫描全部数据
KuduScanner scanner = client.newScannerBuilder(table)
.build();
// 循环删除全部数据
while (scanner.hasMoreRows()) {
RowResultIterator results = scanner.nextRows();
while (results.hasNext()) {
RowResult result = results.next();
Delete delete = table.newDelete();
PartialRow row = delete.getRow();
for (ColumnSchema column : table.getSchema().getColumns()) {
row.addObject(column.getName(), result.getObject(column.getName()));
}
client.delete(delete);
}
}
// 关闭
Kudu表扫描器和客户端连接
scanner.close();
client.close();
}
}
```