Reputation: 1356
I am trying to convert a Put
object to a KeyValue
objects.
How can I achieve that on HBase? I have looked at the source code but didn't found a way to do that.
My Put
object contains rowkey and 2 columns (A,B columns).
Thanks for helpers
Upvotes: 1
Views: 987
Reputation: 11609
Your Put with 2 columns is not a Key Value, but 2 Key Values.
Check this method in Put class:
KeyValue createPutKeyValue(byte[] family, byte[] qualifier, long ts, byte[] value) {
return new KeyValue(this.row, family, qualifier, ts, KeyValue.Type.Put, value);
}
KeyValue contains cell information - a key, column family with column, timestamp and data.
So for your case
List<KeyValue> keyValues = new ArrayList<>();
for (Map.Entry<byte[], List<Cell> entry : put.getFamilyCellMap()) {
byte[] cf = entry.getKey();
List<Cell> cells = entry.getValue();
for (Cell cell : cells) {
// get row, column, ts and value using Cell api
keyValues.add(new KeyValue(...));
}
}
Upvotes: 2