有关系实体在HBASE里面存放的方式
字段可以定义为前缀
"s" + show_id
"a" + album_id
"m" + name
在一个ROW里面根据字段名查询可以使用Column的各种Filter
HTable t = ...;
Scan s = ...;
s.setStartRow("pets");
s.setStopRow("pets");
// get all columns for my pet "fluffy".
Filter f = new ColumnRangeFilter(Bytes.toBytes("fluffy"), true,
Bytes.toBytes("fluffz"), false);
s.setFilter(f);
s.setBatch(20); // avoid getting all columns for the HBase row
ResultScanner rs = t.getScanner(s);
for (Result r = rs.next(); r != null; r = rs.next()) {
// r will now have all HBase columns that start with "fluffy",
// which would represent a single row
for (KeyValue kv : r.raw()) {
// each kv represent - the latest version of - a column
}
}
另外一个例子是存放用户的信息,每个用户为一条row
为了支持不同的排序方式,分了几个CF,id排序一个CF,日期排序一个CF
Attachments
-
tu1.JPG
(16.5 KB) -
added by liaojiaohe 14 years ago.
-
tu2.JPG
(9.7 KB) -
added by liaojiaohe 14 years ago.
-
tu3.JPG
(12.9 KB) -
added by liaojiaohe 14 years ago.
-
tu4.JPG
(17.2 KB) -
added by liaojiaohe 14 years ago.
-
tu5.JPG
(33.2 KB) -
added by liaojiaohe 14 years ago.
-
tu6.JPG
(16.9 KB) -
added by liaojiaohe 14 years ago.
![(please configure the [header_logo] section in trac.ini)](http://www1.pconline.com.cn/hr/2009/global/images/logo.gif)