hbase> status
hbase> status ‘simple’
hbase> status ‘summary’
hbase> status ‘detailed’
hbase> version
hbase> version
hbase> whoami
hbase> 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.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.QualifierFilter
import org.apache.hadoop.hbase.filter.BinaryComparator
import org.apache.hadoop.hbase.filter.RegexStringComparator
import org.apache.hadoop.hbase.filter.RowFilter
import org.apache.hadoop.hbase.filter.FilterList
import org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter
import java.util.ArrayList
import org.apache.hadoop.hbase.filter.TimestampsFilter
import org.apache.hadoop.hbase.filter.ColumnPaginationFilter
import org.apache.hadoop.hbase.filter.ValueFilter
vf=ValueFilter.new(CompareFilter::CompareOp::EQUAL, SubstringComparator.new('INPUT'))
scan 'input_feed', {FILTER=>vf} ##this filters from versions value aswell
scan '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_NAME
import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SubstringComparator
import org.apache.hadoop.hbase.util.Bytes
import org.apache.hadoop.hbase.filter.RowFilter
import org.apache.hadoop.io.MD5Hash
import org.apache.hadoop.hbase.filter.ColumnPaginationFilter
import org.apache.hadoop.hbase.util.Bytes
import org.apache.hadoop.hbase.filter.FilterList
import java.util.ArrayList
import org.apache.hadoop.hbase.filter.ColumnPaginationFilter
for 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}
end
q
The 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,