The KeyValue Class
Note
话说,KeyValue类和它的自带比较器是被设计用来内部使用的。只有在很少的地方你才能通过API访问行数据,因为外部的copy操作时被避免的。他同样运行byte级别的比较,而不是更慢的class级别的比较。
在你的代码中,你可能不得不直接处理KeyValue类。因为你可能会回调,它包含和某一个坐标一样的数据。这个类提供了很多构造参数,如下:
KeyValue(byte[] row, int roffset, int rlength,
byte[] family, int foffset, int flength, byte[] qualifier,
int qoffset,
int qlength, long timestamp, Type type, byte[] value, int
voffset,
int vlength)
Page147
两个很有趣的需要知道的方法:
byte [] getRow()
byte [] getKey()
The question you may ask yourself is: what is the difference between
a row and a key? While you will learn about the difference in the
section called “Storage” let us suffice to say that the row is what we
referred to so far alternatively as row key, i.e. the row parameter of
the Put constructor. The key on the other hand is what was previously
introduced as the coordinates of a cell - in their raw, byte array format.
In practice you hardly have to use getKey() but will be more likely to
use getRow().
Row和key之间的区别是什么呢?简而言之,row也就是rowkey,是我们放到put构造参数里面的东西。另一方面,key是之前提到的在他们行上的,一个cell的坐标,是byte array格式的。在实际生产中,你几乎不会用getKey(),你会更喜欢用getRow()。
我的理解是,key是Hbase内部使用的,开发者一般使用row。key是坐标,value是值。如有偏差 欢迎指正