|
|
-
how to create a Result object with some null value?
bigdata 2013-02-27, 12:34
Now I want to test HBase with mock Result object.In the map(), we get value like this: byte[] date = value.getValue(Bytes.toBytes("f"), Bytes.toBytes("date")); Sometimes, the byte[] date will be null because of null value in hbase. Now I want to create fake HBase object by using :
new KeyValue( Bytes.toBytes(rowkey), Bytes.toBytes(family), Bytes.toBytes(qualifier), 1, Bytes.toBytes(value)); But I can't set value to null to create KeyValue object. Anybody knows how to simulate this situation?
-
Re: how to create a Result object with some null value?
Ted Yu 2013-02-27, 21:57
If you look at KeyValue, you would see the following:
public KeyValue(final byte[] row, final byte[] family,
final byte[] qualifier, final long timestamp, Type type) {
this(row, family, qualifier, timestamp, type, null);
} Note the last parameter, null, is for value.
Cheers
On Wed, Feb 27, 2013 at 4:34 AM, bigdata <[EMAIL PROTECTED]> wrote:
> Now I want to test HBase with mock Result object.In the map(), we get > value like this: > > > > > > > > > byte[] date = value.getValue(Bytes.toBytes("f"), > Bytes.toBytes("date")); > Sometimes, the byte[] date will be null because of null value in hbase. > Now I want to create fake HBase object by using : > > > > > > > > new KeyValue( > Bytes.toBytes(rowkey), > Bytes.toBytes(family), > Bytes.toBytes(qualifier), > 1, > Bytes.toBytes(value)); > But I can't set value to null to create KeyValue object. > Anybody knows how to simulate this situation? >
|
|