Friday, December 27, 2013

Learning HBase

HBase MapReduce
http://hbase.apache.org/book/mapreduce.example.html

Hbase Filter
http://hbase.apache.org/book/client.filter.html

HBase Java Simple Example
http://bestlovejava.blogspot.com/2013/07/hbase-java-simple-example.html

scan      Scan a table; pass table name and optionally a dictionary of scanner
           specifications.  Scanner specifications may include one or more of
           the following: LIMIT, STARTROW, STOPROW, TIMESTAMP, or COLUMNS.  If
           no columns are specified, all columns will be scanned.  To scan all
           members of a column family, leave the qualifier empty as in
           'col_family:'.  Examples:

           hbase> scan '.META.'
           hbase> scan '.META.', {COLUMNS => 'info:regioninfo'}
           hbase> scan 't1', {COLUMNS => ['c1', 'c2'], LIMIT => 10, \
             STARTROW => 'xyz'}
 

scan 'mytable', {STARTROW => 'abc', ENDROW => 'abd'}

.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.Some examples:hbase> scan ‘.META.’
hbase> scan ‘.META.’, {COLUMNS => ‘info:regioninfo’}
hbase> scan ‘t1′, {COLUMNS => ['c1', 'c2'], LIMIT => 10, STARTROW => ‘xyz’}
hbase> scan ‘t1′, {COLUMNS => ‘c1′, TIMERANGE => [1303668804, 1303668904]}
hbase> scan ‘t1′, {FILTER => “(PrefixFilter (‘row2′) AND
(QualifierFilter (>=, ‘binary:xyz’))) AND (TimestampsFilter ( 123, 456))”}
hbase> scan ‘t1′, {FILTER =>
org.apache.hadoop.hbase.filter.ColumnPaginationFilter.new(1, 0)}
For experts, there is an additional option — CACHE_BLOCKS — whi

  hbase> scan '.META.', {COLUMNS => 'info:regioninfo'}
  hbase> scan 't1', {COLUMNS => ['c1', 'c2'], LIMIT => 10, STARTROW => 'xyz'}
  hbase> scan 't1', {FILTER => org.apache.hadoop.hbase.filter.ColumnPaginationFilter.new(1, 0)}
  hbase> scan 't1', {COLUMNS => 'c1', TIMERANGE => [1303668804, 1303668904]}

scan 'test', {COLUMNS => ['F'],FILTER => "(SingleColumnValueFilter('F','u',=,'regexstring:http:.*pdf',true,true)) AND (SingleColumnValueFilter('F','s',=,'binary:2',true,true))"}

http://bestlovejava.blogspot.com/2013/07/hbase-java-simple-example.html
HTablePool pool = new HTablePool(configuration, 1000);  
HTable table = (HTable) pool.getTable(tableName);  
Filter filter = new SingleColumnValueFilter(Bytes  
.toBytes("column1"), null, CompareOp.EQUAL, Bytes  
.toBytes("aaa")); // ??column1???aaa?????  
Scan s = new Scan();  
s.setFilter(filter);  
ResultScanner rs = table.getScanner(s);  

No comments:

Post a Comment