-
Hbase scan扫描全表,指定返回特定的列
scan ‘stu’,{COLUMNS => [‘base:weight’,‘base:height’]} -
Hbase TIMERANGE 扫描指定时间内数据,前闭后开
scan ‘stu’,{TIMERANGE=>[1588153968060,1588153968207]} -
Hbase 利用STARTROW STOPROW 扫描rowkey的范围
scan ‘stu’,{STARTROW=>‘c1_s1’,STOPROW=>‘c1_s3’} -
Hbase 翻转结果和时间组合排序 REVERSED
scan ‘stu’, {REVERSED => TRUE} -
Hbase 返回指标 ALL_METRICS or METRICS
scan ‘stu’,{ALL_METRICS => true}
6.Hbase 查询以指定开头的rowkey数据。
scan ‘stu’,{ROWPREFIXFILTER => ‘c1’}
scan ‘stu’,{FILTER => “PrefixFilter(‘c1’)”}
7.按列查找 QualifierFilter
scan ‘stu’,{FILTER => “(QualifierFilter (<,‘binary:name’)) AND (QualifierFilter (=,‘substring:jack’))”}
8.以指定列的前缀查找数据。ColumnPrefixFilter
scan ‘stu’,{FILTER=>“ColumnPrefixFilter(‘nam’) AND (ValueFilter(=,‘substring:1’) OR ValueFilter(=,‘substring:3’))”}
scan ‘stu’,{COLUMNS => [‘base:name’] , FILTER=>" (ValueFilter(=,‘substring:1’) OR ValueFilter(=,‘substring:3’))" }
-
按值查找,可以指定确定的值或者值的范围。ValueFilter
scan ‘stu’,{FILTER=>“ValueFilter(=,‘binary:jack’)”} -
RAW指导扫描器返回所有单元格(包括删除标记和未收集的已删除单元格)。此选项不能与请求特定列相结合。默认情况下禁用
scan ‘stu’,{RAW => true,VERSIONS => 2}
10.删除数据
delete ‘stu’,‘c1_s4’,‘base:name’
12.FirstKeyOnlyFilter
一个rowkey可以有多个version,同一个rowkey的同一个column也会有多个的值, 只拿出key中的第一个column的第一个version
KeyOnlyFilter: 只要key,不要value
scan ‘stu’,FILTER => “FirstKeyonlyFilter() AND ValueFilter(=,‘binary:jack2’) AND KeyonlyFilter()”
- 限制返回只要两列
scan ‘stu’, {LIMIT => 2}
14.引入Java类包
列分页过滤器:基于列进行分页,需要设置偏移量与返回数量。分页ColumnPaginationFilter
import org.apache.hadoop.hbase.filter.ColumnPaginationFilter
scan ‘stu’, {FILTER =>ColumnPaginationFilter.new(3, 1)}
- 正则表达式查询
import org.apache.hadoop.hbase.filter.RegexStringComparator
import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SubstringComparator
import org.apache.hadoop.hbase.filter.RowFilter
scan ‘stu’, {FILTER => RowFilter.new(CompareFilter::CompareOp.valueOf(‘EQUAL’),RegexStringComparator.new(’^cd+_[a-z]d+$’))}