HBase编程 API入门系列之delete.deleteColumn和delete.deleteColumns区别(客户端而言)(4)
心得,写在前面的话,也许,中间会要多次执行,连接超时,多试试就好了。
delete.deleteColumn和delete.deleteColumns区别是:
deleteColumn是删除某一个列簇里的最新时间戳版本。
delete.deleteColumns是删除某个列簇里的所有时间戳版本。

hbase(main):020:0> desc 'test_table'
Table test_table is ENABLED
test_table
COLUMN FAMILIES DESCRIPTION
{NAME => 'f', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS
=> 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}
1 row(s) in 0.2190 seconds
hbase(main):021:0> scan 'test_table'
ROW COLUMN+CELL
row_01 column=f:col, timestamp=1478102698687, value=maizi
row_01 column=f:name, timestamp=1478104345828, value=Andy
row_02 column=f:name, timestamp=1478104477628, value=Andy2
row_03 column=f:name, timestamp=1478104823358, value=Andy3
3 row(s) in 0.2270 seconds
hbase(main):022:0> scan 'test_table'
ROW COLUMN+CELL
row_01 column=f:col, timestamp=1478102698687, value=maizi
row_01 column=f:name, timestamp=1478104345828, value=Andy
row_02 column=f:name, timestamp=1478104477628, value=Andy2
row_03 column=f:name, timestamp=1478104823358, value=Andy3
3 row(s) in 0.1480 seconds
hbase(main):023:0> scan 'test_table',{VERSIONS=>3}
ROW COLUMN+CELL
row_01 column=f:col, timestamp=1478102698687, value=maizi
row_01 column=f:name, timestamp=1478104345828, value=Andy
row_02 column=f:name, timestamp=1478104477628, value=Andy2
row_03 column=f:name, timestamp=1478104823358, value=Andy3
3 row(s) in 0.1670 seconds
hbase(main):024:0>

package zhouls.bigdata.HbaseProject.Test1; import javax.xml.transform.Result; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.util.Bytes; public class HBaseTest {
public static void main(String[] args) throws Exception {
HTable table = new HTable(getConfig(),TableName.valueOf("test_table"));//表名是test_table
Put put = new Put(Bytes.toBytes("row_04"));//行键是row_04
put.add(Bytes.toBytes("f"),Bytes.toBytes("name"),Bytes.toBytes("Andy0"));//列簇是f,列修饰符是name,值是Andy0
// put.add(Bytes.toBytes("f2"),Bytes.toBytes("name"),Bytes.toBytes("Andy3"));//列簇是f2,列修饰符是name,值是Andy3
table.put(put);
table.close(); // Get get = new Get(Bytes.toBytes("row_04"));
// get.addColumn(Bytes.toBytes("f1"), Bytes.toBytes("age"));如现在这样,不指定,默认把所有的全拿出来
// org.apache.hadoop.hbase.client.Result rest = table.get(get);
// System.out.println(rest.toString());
// table.close(); // Delete delete = new Delete(Bytes.toBytes("row_2"));
// delete.deleteColumn(Bytes.toBytes("f1"), Bytes.toBytes("email"));
// delete.deleteColumn(Bytes.toBytes("f1"), Bytes.toBytes("name"));
// table.delete(delete);
// table.close(); // Delete delete = new Delete(Bytes.toBytes("row_03"));
// delete.deleteColumn(Bytes.toBytes("f"), Bytes.toBytes("name"));
// delete.deleteColumns(Bytes.toBytes("f"), Bytes.toBytes("name"));
// table.delete(delete);
// table.close();
} public static Configuration getConfig(){
Configuration configuration = new Configuration();
// conf.set("hbase.rootdir","hdfs:HadoopMaster:9000/hbase");
configuration.set("hbase.zookeeper.quorum", "HadoopMaster:2181,HadoopSlave1:2181,HadoopSlave2:2181");
return configuration;
}
}

hbase(main):038:0> scan 'test_table'
ROW COLUMN+CELL
row_01 column=f:col, timestamp=1478102698687, value=maizi
row_01 column=f:name, timestamp=1478104345828, value=Andy
row_02 column=f:name, timestamp=1478104477628, value=Andy2
row_03 column=f:name, timestamp=1478123664884, value=Andy3
3 row(s) in 0.1910 seconds
hbase(main):039:0> scan 'test_table'
ROW COLUMN+CELL
row_01 column=f:col, timestamp=1478102698687, value=maizi
row_01 column=f:name, timestamp=1478104345828, value=Andy
row_02 column=f:name, timestamp=1478104477628, value=Andy2
row_03 column=f:name, timestamp=1478123664884, value=Andy3
row_04 column=f:name, timestamp=1478123917775, value=Andy0
4 row(s) in 0.1310 seconds
delete.deleteColumn和delete.deleteColumns区别是:
deleteColumn是删除某一个列簇里的最新时间戳版本。
delete.deleteColumns是删除某个列簇里的所有时间戳版本。

package zhouls.bigdata.HbaseProject.Test1; import javax.xml.transform.Result; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.util.Bytes; public class HBaseTest {
public static void main(String[] args) throws Exception {
HTable table = new HTable(getConfig(),TableName.valueOf("test_table"));//表名是test_table
Put put = new Put(Bytes.toBytes("row_04"));//行键是row_04
put.add(Bytes.toBytes("f"),Bytes.toBytes("name"),Bytes.toBytes("Andy1"));//列簇是f,列修饰符是name,值是Andy0
// put.add(Bytes.toBytes("f2"),Bytes.toBytes("name"),Bytes.toBytes("Andy3"));//列簇是f2,列修饰符是name,值是Andy3
table.put(put);
table.close(); // Get get = new Get(Bytes.toBytes("row_04"));
// get.addColumn(Bytes.toBytes("f1"), Bytes.toBytes("age"));如现在这样,不指定,默认把所有的全拿出来
// org.apache.hadoop.hbase.client.Result rest = table.get(get);
// System.out.println(rest.toString());
// table.close(); // Delete delete = new Delete(Bytes.toBytes("row_2"));
// delete.deleteColumn(Bytes.toBytes("f1"), Bytes.toBytes("email"));
// delete.deleteColumn(Bytes.toBytes("f1"), Bytes.toBytes("name"));
// table.delete(delete);
// table.close(); // Delete delete = new Delete(Bytes.toBytes("row_03"));
// delete.deleteColumn(Bytes.toBytes("f"), Bytes.toBytes("name"));
// delete.deleteColumns(Bytes.toBytes("f"), Bytes.toBytes("name"));
// table.delete(delete);
// table.close();
} public static Configuration getConfig(){
Configuration configuration = new Configuration();
// conf.set("hbase.rootdir","hdfs:HadoopMaster:9000/hbase");
configuration.set("hbase.zookeeper.quorum", "HadoopMaster:2181,HadoopSlave1:2181,HadoopSlave2:2181");
return configuration;
}
}








delete.deleteColumn和delete.deleteColumns区别是:
deleteColumn是删除某一个列簇里的最新时间戳版本。
delete.deleteColumns是删除某个列簇里的所有时间戳版本。



HBase编程 API入门系列之delete.deleteColumn和delete.deleteColumns区别(客户端而言)(4)的更多相关文章
- HBase编程 API入门系列之delete(客户端而言)(3)
心得,写在前面的话,也许,中间会要多次执行,连接超时,多试试就好了. 前面的基础,如下 HBase编程 API入门系列之put(客户端而言)(1) HBase编程 API入门系列之get(客户端而言) ...
- HBase编程 API入门系列之create(管理端而言)(8)
大家,若是看过我前期的这篇博客的话,则 HBase编程 API入门系列之put(客户端而言)(1) 就知道,在这篇博文里,我是在HBase Shell里创建HBase表的. 这里,我带领大家,学习更高 ...
- HBase编程 API入门系列之HTable pool(6)
HTable是一个比较重的对此,比如加载配置文件,连接ZK,查询meta表等等,高并发的时候影响系统的性能,因此引入了“池”的概念. 引入“HBase里的连接池”的目的是: 为了更高的,提高程序的并发 ...
- HBase编程 API入门系列之get(客户端而言)(2)
心得,写在前面的话,也许,中间会要多次执行,连接超时,多试试就好了. 前面是基础,如下 HBase编程 API入门系列之put(客户端而言)(1) package zhouls.bigdata.Hba ...
- HBase编程 API入门系列之delete(管理端而言)(9)
大家,若是看过我前期的这篇博客的话,则 HBase编程 API入门之delete(客户端而言) 就知道,在这篇博文里,我是在客户端里删除HBase表的. 这里,我带领大家,学习更高级的,因为,在开发中 ...
- HBase编程 API入门系列之modify(管理端而言)(10)
这里,我带领大家,学习更高级的,因为,在开发中,尽量不能去服务器上修改表. 所以,在管理端来修改HBase表.采用线程池的方式(也是生产开发里首推的) package zhouls.bigdata.H ...
- HBase编程 API入门系列之scan(客户端而言)(5)
心得,写在前面的话,也许,中间会要多次执行,连接超时,多试试就好了. package zhouls.bigdata.HbaseProject.Test1; import javax.xml.trans ...
- HBase编程 API入门系列之工具Bytes类(7)
这是从程度开发层面来说,为了方便和提高开发人员. 这个工具Bytes类,有很多很多方法,帮助我们HBase编程开发人员,提高开发. 这里,我只赘述,很常用的! package zhouls.bigda ...
- HBase编程 API入门系列之put(客户端而言)(1)
心得,写在前面的话,也许,中间会要多次执行,连接超时,多试试就好了. [hadoop@HadoopSlave1 conf]$ cat regionservers HadoopMasterHadoopS ...
随机推荐
- 【sqli-labs】 less37 POST- Bypass MYSQL_real_escape_string (POST型绕过MYSQL_real_escape_string的注入)
POST版本的less36 uname=1&passwd=1%df' or 1#
- 微信小程序中的iPhone X适配问题
微信小程序中的iPhone X适配问题 小程序中下方的导航会被iPhone X下面的那条黑线盖住[微笑脸],所以要专门为了iPhone X做样式上的适配[微笑脸] wx.getSystemInfo({ ...
- 前端开发—HTML
HTML介绍 web服务的本质 import socket sk = socket.socket() sk.bind(("127.0.0.1", 8080)) sk.listen( ...
- eas之kdtable格式化
设置表.列.行或单元的格式化字符串 // 设置表table.getStyleAttributes().setNumberFormat(formatString); // 设置列column.getSt ...
- Java8自定义条件让集合分组
/** * 将一个指定类型对象的集合按照自定义的一个操作分组: 每组对应一个List.最终返回结果类型是:List<List<T>> * * @param <T> ...
- zabbix监控AIX DB2数据库
记一次工作中使用zabbix监控aix db2数据库的经历. 记忆要点: 1.使用自定义perl脚本: 2.由于zabbix用户权限的原因,无法调用db2用户获取数据库的数据,所以在zabbix配置文 ...
- 关于Java中返回零长度数组或空集合比较好,还是返回null这个问题的一些想法
近日在方法返回类型为List数据类型时,返回结果为空集合比较好,还是null比较好的问题上有点纠结. 我觉得应该统一返回空集合,这样可以不用进行空指针的判断,不然又多了一个产生bug的可能性.而有人认 ...
- d正则表达式相关
控件看Delphi正则表达式使用方法(TPerlRegEx)的介绍: 使用正则表达式获取Sql查询语句各项(表名.字段.条件.排序) 希望在线测试正则表达式 在线正则表达式测试 有许多常规表达式 希 ...
- Nginx学习总结(1)——Nginx入门简介
本文主要介绍一些Nginx的最基本功能以及简单配置,但不包括Nginx的安装部署以及实现原理.废话不多,直接开始. 1.静态HTTP服务器 首先,Nginx是一个HTTP服务器,可以将服务器上的静态文 ...
- (20)Spring Boot Servlet【从零开始学Spring Boot】
Web开发使用 Controller 基本上可以完成大部分需求,但是我们还可能会用到 Servlet.Filter.Listener.Interceptor 等等. 当使用Spring-Boot时,嵌 ...