Creating a table Create ' test1 ', ' lf ', ' SF ' Lf:column family of LONG values (binary value)--Sf:column family of STRING values imports According to 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 ' a user (Userx), at what time (TsX), as Rowkey on what product (VALUE:SKUXXX), what operations have been done as column names, for example, C1:click from homepage; C2:click from AD; S1:search from homepage; B1:buy query case whose value =sku188 scan ' test1 ', filter=> "valuefilter" (=, ' binary:sku188 ') "ROW COLU Mn+cell user1|ts2 column=sf:c1, timestamp=1409122354918, value=sku188 whose values contain the S Can ' 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 clicks through the AD (column for C2) value contains 88 of users scan ' test1 ', filter=> ' columnprefixfilter (' C2 ') and Valuefilter (=, ' substring:88 ') "ROW Column+cell user2|ts5 column=sf:c2, Times tamp=1409122355030, value=sku288 by Search in (column s) value contains 123 or 222 of users 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, time stamp=1409122355970, value=sku222 rowkey for 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=14091 22354954, value=sku123 FirsTkeyonlyfilter: A rowkey can have more than one version, the same column of the same rowkey will have multiple values, only the first version of the first column in the key, Keyonlyfilter: As long as the key , do not value scan ' test1 ', filter=> ' Firstkeyonlyfilter () and valuefilter (=, ' binary:sku188 ') and Keyonlyfilter () ROW Column+cell user1|ts2 column=sf:c1, timestamp=1409122354918, value= starting from User1|ts2, Find all rowkey with User1 at the beginning of 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 start with user1|ts2, find all rowkey with User2 to start scan ' test1 ', {start Row=> ' user1|ts2 ', stoprow=> ' user2 '} ROW Column+cell user1|ts2 : C1, timestamp=1409122354918, value=sku188 user1|ts3 column=sf:s1, timestamp=1409122354954, Value=sku12 3 Query Rowkey contains 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=s
F:S1, timestamp=1409122354954, value=sku123 query Rowkey contains 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 add a test data put ' test1 ', ' user2|err ', ' sf:s 1 ', ' sku999 ' query Rowkey inside with user, the newly added test data does not conform to regular expression rules, so the query does not come out 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=s KU1 user1|ts2 column=sf:c1, timestamp=1409122354918, value=sku188 user1|ts3, Column=s F: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 Add the test data put ' test1 ', ' user1|ts9 ', ' sf:b1 ', ' SKU1 ' B1 the column in the beginning and the value is SKU1 Scan ' test1 ', filter=> ' Columnprefixfilter (' B1 ') and valuefilter (=, ' binary:sku1 ') "ROW COLUMN +cell User1|ts9 column=sf:b1, ti mestamp=1409124908668, Value=sku1 Singlecolumnvaluefilter, B1 in the beginning of the column and the value is 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 use 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 (CONNECT ED) 2] ls/hbase/table [member, Test1, Hbase:meta, Hbase:namespace] [zk:hadoop000:2181 (CONNECTED) 3] Ls/hbase/table/te ST1 [] [zk:hadoop000:2181 (CONNECTED) 4] get/hbase/table/test1 master:60000}l$??
Lpbuf Czxid = 0x107 CTime = Wed Aug/14:52:21 HKT 2014 = mzxid 0x10b = mtime Wed/Aug (14:52:22) HKT = 2014 cversion = 0 Dataversion = 2 aclversion = 0 Ephemeralowner = 0x0 datalength = Numchildren = 0