HBase里面一个很重要的数据结构
hbase.client.Result
其中有一个private KeyValue[] kvs =null
KeyValue wraps a byte array and takes offsets and lengths into passed array at where to start interpreting the content as KeyValue. The KeyValue format inside a byte array is: <keylength> <valuelength> <key> <value>
Key is further decomposed as:<rowlength> <row> <columnfamilylength> <columnfamily> <columnqualifier> <timestamp> <keytype>
当我们在客户端new HTable(conf, "testwy"), 会从meta文件搜索相关信息,并返回一个Result对象
当我们把此Result对象打印出来
keyvalues={testwy,,1356526985748.9c2583081c219f5331e7a80c5a63c244./info:regioninfo/1356526985844/Put/vlen=80/ts=0, testwy,,1356526985748.9c2583081c219f5331e7a80c5a63c244./info:server/1356526985935/Put/vlen=15/ts=0, testwy,,1356526985748.9c2583081c219f5331e7a80c5a63c244./info:serverstartcode/1356526985935/Put/vlen=8/ts=0}
其中有三个keyvalue,结构都是
row/family:qualifier/timestamp/Type/vlen=(length of value)/ts=(memstore time stamp)
HRegionInfo.readFields function can analyse the string with 'info:regioninfo', to get the endkey, offLine, regionName, regionNameStr etc. member value.
Put put = new Put(Bytes.toBytes("row1"));
put.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"), Bytes.toBytes("val1"));
对应的 KeyValue值
[0, 0, 0, 28, 0, 0, 0, 4, 0, 4, 114, 111, 119, 49, 7, 99, 111, 108, 102, 97, 109, 49, 113, 117, 97, 108, 49, 127, -1, -1, -1, -1, -1, -1, -1, 4, 118, 97, 108, 49]