大数据全系列 教程
1869个小节阅读:465.7k
408考研
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
xxxxxxxxxx
/**删除指定rowkey的某单元格数据
* 删除前查询:
*hbase(main):006:0> get 'itbaizhan:phone_log','15893647910_92233695046692028070231'
* COLUMN CELL
* basic:date timestamp=1638794274438, value=2050-03-30 00:52:53
* basic:dnum timestamp=1638794274438, value=19916554511
* basic:length timestamp=1638794274438, value=\x00\x00\x00a
* basic:type timestamp=1638794274438, value=\x00\x00\x00\x01
* 1 row(s)
* Took 0.7135 seconds
* 删除后查询
* hbase(main):007:0> get 'itbaizhan:phone_log','15893647910_92233695046692028070231'
* COLUMN CELL
* basic:date timestamp=1638794274438, value=2050-03-30 00:52:53
* basic:dnum timestamp=1638794274438, value=19916554511
* basic:type timestamp=1638794274438, value=\x00\x00\x00\x01
* 1 row(s)
*/
public void deleteCell() throws IOException {
Delete delete = new Delete(Bytes.toBytes("15893647910_92233695046692028070231"));
//指定具体的列
delete.addColumn(Bytes.toBytes("basic"),Bytes.toBytes("length"));
//执行删除操作
table.delete(delete);
}
/**添加单元格数据演示
* 添加前查询
*hbase(main):007:0> get 'itbaizhan:phone_log','15893647910_92233695046692028070231'
* COLUMN CELL
* basic:date timestamp=1638794274438, value=2050-03-30 00:52:53
* basic:dnum timestamp=1638794274438, value=19916554511
* basic:type timestamp=1638794274438, value=\x00\x00\x00\x01
* 1 row(s)
* Took 0.0342 seconds
* 添加后查询
* hbase(main):008:0> get 'itbaizhan:phone_log','15893647910_92233695046692028070231'
* COLUMN CELL
* basic:date timestamp=1638794274438, value=2050-03-30 00:52:53
* basic:dnum timestamp=1638794274438, value=19916554511
* basic:length timestamp=1638797386409, value=\x00\x00\x00c
* basic:type timestamp=1638794274438, value=\x00\x00\x00\x01
* 1 row(s)
* Took 0.0451 seconds
*/
public void insertCell() throws IOException {
Put put = new Put(Bytes.toBytes("15893647910_92233695046692028070231"));
put.addColumn(Bytes.toBytes("basic"),Bytes.toBytes("length"),Bytes.toBytes(99));
table.put(put);
}
/**删除行操作
* 删除前查询
* hbase(main):008:0> get 'itbaizhan:phone_log','15893647910_92233695046692028070231'
* COLUMN CELL
* basic:date timestamp=1638794274438, value=2050-03-30 00:52:53
* basic:dnum timestamp=1638794274438, value=19916554511
* basic:length timestamp=1638797386409, value=\x00\x00\x00c
* basic:type timestamp=1638794274438, value=\x00\x00\x00\x01
* 1 row(s)
* Took 0.0451 seconds
* 删除后查询
* hbase(main):009:0> get 'itbaizhan:phone_log','15893647910_92233695046692028070231'
* COLUMN CELL
* 0 row(s)
* Took 0.0219 seconds
* @throws IOException
*/
public void deleteRow() throws IOException {
Delete delete = new Delete(Bytes.toBytes("15893647910_92233695046692028070231"));
//执行删除操作
table.delete(delete);
}