create 'test1', 'lf', 'sf'
lf: column family of LONG values (binary value)
-- sf: column family of STRING values
put 'test1', 'user1|ts1', 'sf:c1', 'sku1'
put 'test1', 'user1|ts2', 'sf:c1', 'sku188'
put 'test1', 'user1|ts3', 'sf:s1', 'sku123'
put 'test1', 'user2|ts4', 'sf:c1', 'sku2'
put 'test1', 'user2|ts5', 'sf:c2', 'sku288'
put 'test1', 'user2|ts6', 'sf:s1', 'sku222'
(userX), (tsX), rowkey
(value:skuXXX), , ,c1: click from homepage; c2: click from ad; s1: search from homepage; b1: buy
=sku188
scan 'test1', FILTER=>"ValueFilter(=,'binary:sku188')"
ROW COLUMN+CELL
user1|ts2 column=sf:c1, timestamp=1409122354918, value=sku188
88
scan 'test1', FILTER=>"ValueFilter(=,'substring:88')"
ROW COLUMN+CELL
user1|ts2 column=sf:c1, timestamp=1409122354918, value=sku188
user2|ts5 column=sf:c2, timestamp=1409122355030, value=sku288
(column c2) 88
scan 'test1', FILTER=>"ColumnPrefixFilter('c2') AND ValueFilter(=,'substring:88')"
ROW COLUMN+CELL
user2|ts5 column=sf:c2, timestamp=1409122355030, value=sku288
(column s) 123 222
scan 'test1', FILTER=>"ColumnPrefixFilter('s') AND ( ValueFilter(=,'substring:123') OR ValueFilter(=,'substring:222') )"
ROW COLUMN+CELL
user1|ts3 column=sf:s1, timestamp=1409122354954, value=sku123
user2|ts6 column=sf:s1, timestamp=1409122355970, value=sku222
rowkey user1
scan 'test1', FILTER => "PrefixFilter ('user1')"
ROW COLUMN+CELL
user1|ts1 column=sf:c1, timestamp=1409122354868, value=sku1
user1|ts2 column=sf:c1, timestamp=1409122354918, value=sku188
user1|ts3 column=sf:s1, timestamp=1409122354954, value=sku123
FirstKeyOnlyFilter: rowkey version, rowkey column , key column version
KeyOnlyFilter: key, value
scan 'test1', FILTER=>"FirstKeyOnlyFilter() AND ValueFilter(=,'binary:sku188') AND KeyOnlyFilter()"
ROW COLUMN+CELL
user1|ts2 column=sf:c1, timestamp=1409122354918, value=
user1|ts2 , rowkey user1
scan 'test1', {STARTROW=>'user1|ts2', FILTER => "PrefixFilter ('user1')"}
ROW COLUMN+CELL
user1|ts2 column=sf:c1, timestamp=1409122354918, value=sku188
user1|ts3 column=sf:s1, timestamp=1409122354954, value=sku123
user1|ts2 , rowkey user2
scan 'test1', {STARTROW=>'user1|ts2', STOPROW=>'user2'}
ROW COLUMN+CELL
user1|ts2 column=sf:c1, timestamp=1409122354918, value=sku188
user1|ts3 column=sf:s1, timestamp=1409122354954, value=sku123
rowkey ts3
import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SubstringComparator
import org.apache.hadoop.hbase.filter.RowFilter
scan 'test1', {FILTER => RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'), SubstringComparator.new('ts3'))}
ROW COLUMN+CELL
user1|ts3 column=sf:s1, timestamp=1409122354954, value=sku123
rowkey ts
import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SubstringComparator
import org.apache.hadoop.hbase.filter.RowFilter
scan 'test1', {FILTER => RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'), SubstringComparator.new('ts'))}
ROW COLUMN+CELL
user1|ts1 column=sf:c1, timestamp=1409122354868, value=sku1
user1|ts2 column=sf:c1, timestamp=1409122354918, value=sku188
user1|ts3 column=sf:s1, timestamp=1409122354954, value=sku123
user2|ts4 column=sf:c1, timestamp=1409122354998, value=sku2
user2|ts5 column=sf:c2, timestamp=1409122355030, value=sku288
user2|ts6 column=sf:s1, timestamp=1409122355970, value=sku222
put 'test1', 'user2|err', 'sf:s1', 'sku999'
rowkey user , ,
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 'test1', {FILTER => RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'),RegexStringComparator.new('^user\d+\|ts\d+$'))}
ROW COLUMN+CELL
user1|ts1 column=sf:c1, timestamp=1409122354868, value=sku1
user1|ts2 column=sf:c1, timestamp=1409122354918, value=sku188
user1|ts3 column=sf:s1, timestamp=1409122354954, value=sku123
user2|ts4 column=sf:c1, timestamp=1409122354998, value=sku2
user2|ts5 column=sf:c2, timestamp=1409122355030, value=sku288
user2|ts6 column=sf:s1, timestamp=1409122355970, value=sku222
put 'test1', 'user1|ts9', 'sf:b1', 'sku1'
b1 sku1
scan 'test1', FILTER=>"ColumnPrefixFilter('b1') AND ValueFilter(=,'binary:sku1')"
ROW COLUMN+CELL
user1|ts9 column=sf:b1, timestamp=1409124908668, value=sku1
SingleColumnValueFilter ,b1 sku1
import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter
import org.apache.hadoop.hbase.filter.SubstringComparator
scan 'test1', {COLUMNS => 'sf:b1', FILTER => SingleColumnValueFilter.new(Bytes.toBytes('sf'), Bytes.toBytes('b1'), CompareFilter::CompareOp.valueOf('EQUAL'), Bytes.toBytes('sku1'))}
ROW COLUMN+CELL
user1|ts9 column=sf:b1, timestamp=1409124908668, value=sku1
hbase zkcli
hbase zkcli
ls /
[hbase, zookeeper]
[zk: hadoop000:2181(CONNECTED) 1] ls /hbase
[meta-region-server, backup-masters, table, draining, region-in-transition, running, table-lock, master, namespace, hbaseid, online-snapshot, replication, splitWAL, recovering-regions, rs]
[zk: hadoop000:2181(CONNECTED) 2] ls /hbase/table
[member, test1, hbase:meta, hbase:namespace]
[zk: hadoop000:2181(CONNECTED) 3] ls /hbase/table/test1
[]
[zk: hadoop000:2181(CONNECTED) 4] get /hbase/table/test1
?master:60000}l$??lPBUF
cZxid = 0x107
ctime = Wed Aug 27 14:52:21 HKT 2014
mZxid = 0x10b
mtime = Wed Aug 27 14:52:22 HKT 2014
pZxid = 0x107
cversion = 0
dataVersion = 2
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 31
numChildren = 0