hbase> statushbase> status ‘simple’hbase> status ‘summary’hbase> status ‘detailed’hbase> versionhbase> versionhbase> whoamihbase> create_namespace '<SOMENAME>' #This is optional.hbase> create 'SOMENAME_t1', 'f1' #If table needs to be under Namespace. "_" is used by happbase(python connecteor) as prefix.hbase> create 't1', 'f1'hbase> create 't2', ['f1', 'f2'] #If multiple columnfamily are to be created.hbase> scan 't1'hbase> scan 't2', { COLUMNS=>'f2' } #will fetch all qualifier and their values from 'f2' column family of 't1' table.hbase> put 't1', '1', 'f1:name', 'Rohit'hbase> disable 't1' hbase> alter 't1', NAME=>'f2'hbase> enable 't1'hbase> drop 't1'hbase> disable_all '145.*'hbase> drop_all '145.*'hbase> alter 't1', {NAME=>'f1',VERSIONS=>'1'}#Create table with TTL & VERSIONS defined
hbase> create 'test_1',{NAME=>'cf1', VERSIONS=>1, TTL=>60}, {NAME=>'cf2', VERSIONS=>2, MIN_VERSIONS=>2 , TTL=>300 }hbase> put 'test_1', '1', 'cf1:a', 'a'hbase> put 'test_1', '1', 'cf2:b', 'b'hbase> put 'test_1', '2', 'cf1:a', '2a'hbase> put 'test_1', '2', 'cf2:b', '2b'hbase> put 'test_1', '2', 'cf2:b', '2b1'hbase> scan 'test_1', VERSIONS=>3----------------Working with FILTERS in SHELL------------
import org.apache.hadoop.hbase.filter.CompareFilterimport org.apache.hadoop.hbase.filter.SingleColumnValueFilterimport org.apache.hadoop.hbase.filter.SubstringComparatorimport org.apache.hadoop.hbase.util.Bytesimport org.apache.hadoop.hbase.filter.QualifierFilterimport org.apache.hadoop.hbase.filter.BinaryComparatorimport org.apache.hadoop.hbase.filter.RegexStringComparatorimport org.apache.hadoop.hbase.filter.RowFilterimport org.apache.hadoop.hbase.filter.FilterListimport org.apache.hadoop.hbase.filter.FirstKeyOnlyFilterimport java.util.ArrayListimport org.apache.hadoop.hbase.filter.TimestampsFilterimport org.apache.hadoop.hbase.filter.ColumnPaginationFilterimport org.apache.hadoop.hbase.filter.ValueFiltervf=ValueFilter.new(CompareFilter::CompareOp::EQUAL, SubstringComparator.new('INPUT'))scan 'input_feed', {FILTER=>vf} ##this filters from versions value aswellscan 'tblName', { FILTER=> QualifierFilter.new(CompareFilter::CompareOp::EQUAL, RegexStringComparator.new('pattern')) }rowFilter=RowFilter.new(CompareFilter::CompareOp::EQUAL, SubstringComparator.new('1448017920690'))firstQualFilter=FirstKeyOnlyFilter.new()flist=FilterList.new()flist.addFilter(rowFilter)flist.addFilter(firstQualFilter)scan 'tblName', { FILTER => flist }list=ArrayList.new()list.add(1444398443674)list.add(1444457737937)scan 'pgTpTbl', {FILTER=>TimestampsFilter.new(list)}cpf=ColumnPaginationFilter.new(10,5)flist=FilterList.new()flist.addFilter(rof)flist.addFilter(cpf)scan 'tblName', {FILTER=>flist}----------------Working with FILTERS in SHELL------------
----------------------QUERY TABLE FOR LARGE NUMBER OF QUALIFIER IN ROWKEYS
hbase shell <<q > OUTPUT_FILE_NAMEimport org.apache.hadoop.hbase.filter.CompareFilterimport org.apache.hadoop.hbase.filter.SubstringComparatorimport org.apache.hadoop.hbase.util.Bytesimport org.apache.hadoop.hbase.filter.RowFilterimport org.apache.hadoop.io.MD5Hashimport org.apache.hadoop.hbase.filter.ColumnPaginationFilterimport org.apache.hadoop.hbase.util.Bytesimport org.apache.hadoop.hbase.filter.FilterListimport java.util.ArrayListimport org.apache.hadoop.hbase.filter.ColumnPaginationFilterfor i in 0..10 rf=RowFilter.new(CompareFilter::CompareOp::EQUAL, SubstringComparator.new('ROWKEY_PREFIX')) cpf=ColumnPaginationFilter.new(50000, (i * 50000) ) flist=FilterList.new() flist.addFilter(rf) flist.addFilter(cpf) scan 'TABLE', {FILTER=>flist}endqThe filter can be specified in two ways:
1. Using a filterString - more information on this is available in the
Filter Language document attached to the HBASE-4176 JIRA
2. Using the entire package name of the filter.
Note: package names can be avoided by just writing entire filter expression within double quotes.
co-processors in hbase, mapreduce, sources:1,