我正在使用mapreduce将数据插入我的hbase表。因为我不能插入图像,所以我只描述我的hbase表如下:
{
"rowkey1": {
File: {
source: "path to file"
}
Features: {
feature1: "value 1"
feature1: "value 2"
}
}
......
}
在map函数中,我将得到的所有值都是:“path to file”、“value 1”、“value 2”插入到“rowkey1”。
但这里的问题是,我们只能在同一时间为1个限定符的1个族输入1个值。
public void map(Text key, BytesWritable bytes, Context context)throws IOException {
Put put = new Put(key.getBytes());
put.add(family, qualifier, bytes.getBytes());
try {
context.write(new ImmutableBytesWritable(key.getBytes()), put);
} catch (InterruptedException e) {
e.printStackTrace();
}
所以我的问题是,是否有任何方法可以同时将这些值插入hbase表。
谢谢
1条答案
按热度按时间qlvxas9a1#
你就不能这样做吗。
你能做到的
context.write()
一次内多次map
迭代。如果每次迭代的次数map
非常大,可能效率不高(在这种情况下,考虑不同的设计或方法)如果我对你的问题理解不正确,请随时纠正我。