• hbase KEEP_DELETED_CELLS及版本问题


    创建表时可以指定保存的版本数,最小版本数和存活时间

    复制代码
    $hbase>create 'ns1:t3',{NAME=>'f1',VERSIONS=>5}
    //1.指定时间片精确查询
    $hbase>get ‘ns1:t3’,’row1’,{COLUMN=>’f1:name’,TIMESTAMP=>1234}
     
    //2. 指定时间区间精确查询,默认查询区域内最新版本值。
    // 区间查询是前包后不包.
    $hbase>get ‘ns1:t3’,’row1’,{COLUMN=>’f1:name’,TIMERANGE=>[ts1,ts2]}
     
    //3.指定版本数进行查询
    $hbase>get ‘ns1:t3’,’row1’,{COLUMN=>’f1:name’,TIMERANGE=>[ts1,ts2],VERSIONS=>4}
    复制代码

    KEEP_DELETED_CELLS:删除后是否保持数据

    建表时可以指定该参数

    1.KEEP_DELETED_CELLS为false

    复制代码

    hbase(main):013:0> desc 'test'
    Table test is ENABLED
    test
    COLUMN FAMILIES DESCRIPTION
    {NAME => 'e', BLOOMFILTER => 'ROW', VERSIONS => '2147483647', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCO
    DING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICAT
    ION_SCOPE => '0'}
    1 row(s) in 0.0370 seconds

    hbase(main):003:0> scan 'test',{RAW=>true,VERSIONS=>10}
    ROW                               COLUMN+CELL
     r1                               column=e:c1, timestamp=14, value=value
     r1                               column=e:c1, timestamp=12, value=value
     r1                               column=e:c1, timestamp=10, value=value
    1 row(s) in 0.1720 seconds

    hbase(main):004:0> delete 'test','r1','e:c1',11
    0 row(s) in 0.3320 seconds

    hbase(main):005:0> scan 'test',{RAW=>true,VERSIONS=>10}
    ROW                               COLUMN+CELL
     r1                               column=e:c1, timestamp=14, value=value
     r1                               column=e:c1, timestamp=12, value=value
     r1                               column=e:c1, timestamp=11, type=DeleteColumn
     r1                               column=e:c1, timestamp=10, value=value
    1 row(s) in 0.0370 seconds

    hbase(main):006:0> flush 'test'
    0 row(s) in 0.8070 seconds

    hbase(main):007:0> scan 'test',{RAW=>true,VERSIONS=>10}
    ROW                               COLUMN+CELL
     r1                               column=e:c1, timestamp=14, value=value
     r1                               column=e:c1, timestamp=12, value=value
     r1                               column=e:c1, timestamp=11, type=DeleteColumn
    1 row(s) in 0.0370 seconds

    hbase(main):008:0> major_compact 'test'
    0 row(s) in 0.1250 seconds

    hbase(main):009:0> scan 'test',{RAW=>true,VERSIONS=>10}
    ROW                               COLUMN+CELL
     r1                               column=e:c1, timestamp=14, value=value
     r1                               column=e:c1, timestamp=12, value=value
    1 row(s) in 0.0320 seconds

    复制代码

    2.KEEP_DELETED_CELLS为true

    复制代码
    hbase(main):016:0> desc 'ns1:test'
    Table ns1:test is ENABLED
    ns1:test
    COLUMN FAMILIES DESCRIPTION
    {NAME => 'e', BLOOMFILTER => 'ROW', VERSIONS => '2147483647', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'TRUE', DATA_BLOCK_ENCOD
    ING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATI
    ON_SCOPE => '0'}
    1 row(s) in 0.0450 seconds
    
    hbase(main):017:0> scan 'ns1:test'
    ROW                               COLUMN+CELL
    0 row(s) in 0.0200 seconds
    
    hbase(main):018:0> put 'ns1:test','row1','e:name','tom',10
    0 row(s) in 0.1200 seconds
    
    hbase(main):019:0> put 'ns1:test','row1','e:name','tom',12
    0 row(s) in 0.0160 seconds
    
    hbase(main):020:0> put 'ns1:test','row1','e:name','tom',14
    0 row(s) in 0.0240 seconds
    
    hbase(main):021:0> scan 'ns1:test'
    ROW                               COLUMN+CELL
     row1                             column=e:name, timestamp=14, value=tom
    1 row(s) in 0.0180 seconds
    
    hbase(main):022:0> scan 'ns1:test',{RAW=>true,VERSIONS=>10}
    ROW                               COLUMN+CELL
     row1                             column=e:name, timestamp=14, value=tom
     row1                             column=e:name, timestamp=12, value=tom
     row1                             column=e:name, timestamp=10, value=tom
    1 row(s) in 0.0530 seconds
    
    hbase(main):023:0> delete 'ns1:test','row1','e:name',11
    0 row(s) in 0.0870 seconds
    
    hbase(main):024:0> scan 'ns1:test',{RAW=>true,VERSIONS=>10}
    ROW                               COLUMN+CELL
     row1                             column=e:name, timestamp=14, value=tom
     row1                             column=e:name, timestamp=12, value=tom
     row1                             column=e:name, timestamp=11, type=DeleteColumn
     row1                             column=e:name, timestamp=10, value=tom
    1 row(s) in 0.1430 seconds
    
    hbase(main):025:0> flush 'ns1:test'
    0 row(s) in 0.4320 seconds
    
    hbase(main):026:0> scan 'ns1:test',{RAW=>true,VERSIONS=>10}
    ROW                               COLUMN+CELL
     row1                             column=e:name, timestamp=14, value=tom
     row1                             column=e:name, timestamp=12, value=tom
     row1                             column=e:name, timestamp=11, type=DeleteColumn
     row1                             column=e:name, timestamp=10, value=tom
    1 row(s) in 0.0340 seconds
    
    hbase(main):027:0> major_compact 'ns1:test'
    0 row(s) in 0.1890 seconds
    
    hbase(main):028:0> scan 'ns1:test',{RAW=>true,VERSIONS=>10}
    ROW                               COLUMN+CELL
     row1                             column=e:name, timestamp=14, value=tom
     row1                             column=e:name, timestamp=12, value=tom
     row1                             column=e:name, timestamp=11, type=DeleteColumn
     row1                             column=e:name, timestamp=10, value=tom
    1 row(s) in 0.0420 seconds
    
    hbase(main):029:0>
    复制代码
  • 相关阅读:
    数据库笔记(mysql)(1)
    微擎框架商业版 V2.1.2 去后门一键安装版+去除云平台+无附带模块
    资深架构师Sum的故事:正则!入门就是这样简单
    人脸识别+大数据再结合面相学,看相一看一个准!
    layui里面的layer模块弹窗,强制居中的方法!!!
    抖音获取视频点赞数、播放数、获取用户粉丝列表
    破解微擎安装,免费搭建微擎,免费破解微擎,微擎破解版本,最新版本V2.1.2,一键安装!!
    资深架构师Sum的故事:(Mysql)InnoDB下,存储过程中事务的处理
    小程序开发教程:wx.setTopBarText(OBJECT)
    微信web协议,群成员唯一uin,获取群成员唯一标识
  • 原文地址:https://www.cnblogs.com/gaohuajie/p/12917718.html
Copyright © 2020-2023  润新知