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 中子元组的数量。