KeyValue Class key和value的区别

The KeyValue Class


参考Hbase权威指南 

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().

Rowkey之间的区别是什么呢?简而言之,row也就是rowkey,是我们放到put构造参数里面的东西。另一方面,key是之前提到的在他们行上的,一个cell的坐标,是byte array格式的。在实际生产中,你几乎不会用getKey(),你会更喜欢用getRow()


我的理解是,key是Hbase内部使用的,开发者一般使用row。key是坐标,value是值。如有偏差 欢迎指正

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值