创建表时可以指定保存的版本数,最小版本数和存活时间
$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>