Pig HBaseStorage - 如何从DataBag生成动态列名称和动态列数限定符?

时间:2014-04-06 21:41:39

标签: hadoop mapreduce apache-pig hbasestorage

A与B有1:M的关系。

A = LOAD ... AS (
    a_id:char
    ,...
);
B = LOAD ... AS (
    a_id:chararray
    ,b_id:chararray
    ,...
);
JOINED = JOIN A BY a_id, B BY a_id;
GROUPED = GROUP JOINED BY a::a_id;

这将创建一个具有以下架构的DataBag:

{group: chararray, JOINED: {(A:a_id, ..., B::a_id, B::b_id, ...)}}

例如:

(1, {(1, ..., 1, 1, ...)})
(2, {(2, ..., 2, 2, ...), (2, ..., 2,3, ...), (2, ...,2,4, ...)})
(3, {(3, ..., 3, 5, ...)})

对于这三行,这是相应的HBase结果的样子:

rowkey = 1, A:a_id=1, ... B:b1|a_id=1, B:b1|b_id:=1
rowkey = 2, A:a_id=2, ... B:b2|a_id=2, B:b2|b_id=2, ..., B:b3|a_id=2, B:b3|b_id=3, ..., B:b4|a_id=2, B:b4|b_id=4, ...
rowkey = 3, A:a_id=3, ..., B:b5|a_id=3, B:b5|b_id = 5

如何使用上述逻辑将此DataBag导入HBase?

为此,我需要生成动态列限定符名称,其数量取决于DataBag中的子数量。

0 个答案:

没有答案