hbase shell使用filter

单个filter:

import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter
import org.apache.hadoop.hbase.filter.SubstringComparator
import org.apache.hadoop.hbase.util.Bytes
import org.apache.hadoop.hbase.filter.FilterList
import 'ict.gavin.IntSingleColumnValueFilter'   //注意加引号

filter=IntSingleColumnValueFilter.new(Bytes.toBytes('cf3'),Bytes.toBytes('dport'), CompareFilter::CompareOp.valueOf('EQUAL'),1)
scan 'hive_test_b', {FILTER=>filter, COLUMNS=>['cf3:dport']}



--------------------------------------------------------------------------------------

filterlist的情况:

import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter
import org.apache.hadoop.hbase.filter.SubstringComparator
import org.apache.hadoop.hbase.util.Bytes
import org.apache.hadoop.hbase.filter.FilterList


filter1 = SingleColumnValueFilter.new(
  Bytes.toBytes('c'),
  Bytes.toBytes('PDR'),
  CompareFilter::CompareOp.valueOf('EQUAL'),
  SubstringComparator.new('\\w')
)
filter1.setFilterIfMissing(true)
filter2 = SingleColumnValueFilter.new(
  Bytes.toBytes('c'),
  Bytes.toBytes('PDR'),
  CompareFilter::CompareOp.valueOf('EQUAL'),
  SubstringComparator.new('.+')
)
filter2.setFilterIfMissing(true)
filter3 = SingleColumnValueFilter.new(
  Bytes.toBytes('c'),
  Bytes.toBytes('PDR'),
  CompareFilter::CompareOp.valueOf('EQUAL'),
  SubstringComparator.new('.*')
)
filter3.setFilterIfMissing(true)
filterlist= FilterList.new(FilterList::Operator::MUST_PASS_ONE,[filter1, filter2,filter3])

scan 'BoardConfig',{FILTER=>filterlist,COLUMNS=>['o:URL','c:PDR']}

你可能感兴趣的:(filter)