将关键值放在 HBase 上

Put to Key Value on HBase

我正在尝试将 Put 对象转换为 KeyValue 对象。 我怎样才能在 HBase 上实现它?我查看了源代码,但没有找到一种方法来做到这一点。 我的 Put 对象包含 rowkey 和 2 列(A、B 列)。

感谢帮手

您的 2 列 Put 不是键值,而是 2 个键值。

在 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 包含单元格信息 - 键、包含列的列族、时间戳和数据。

所以对于你的情况

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