如何在HBASE中存放PIG袋?

时间:2015-06-11 09:54:49

标签: hbase apache-pig

我要做的是在HBASE

中为PIG创建嵌套数组

所以基本上我做了以下几点:

//Loading some address data
CITY = LOAD '/user/root/landingzone/ADRPCDCITY.csv' using PigStorage(';')
AS (dPOST_CODE:chararray, dCITY_CODE:chararray);

//Create the BAG by grouping postal code
B = GROUP CITY by dPOST_CODE;

//Store it in HBASE
STORE B INTO 'hbase://TEST_ADDRESS_VALIDATION'
       USING org.apache.pig.backend.hadoop.hbase.HBaseStorage(
       'f1: group, f1:CITY' );

我遇到的问题是BAG无法投放到HBASE地图类

java.lang.ClassCastException: org.apache.pig.data.InternalCachedBag cannot be cast to                                                    java.util.Map

非常感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

更好 我得到了一个我想分享的解决方案

CITY = LOAD '/user/root/landingzone/CITY_Test.csv' using PigStorage(';')
AS (POST_CODE:chararray, CITY_CODE:long, CITY_NAME:chararray);

A = FILTER CITY BY (POST_CODE) IS NOT NULL;

result = FOREACH A GENERATE POST_CODE, TOMAP(UPPER(CITY_NAME), CITY_CODE);

STORE result INTO 'CITY_ADDRESS_VALIDATION' USING org.apache.pig.backend.hadoop.hbase.HBaseStorage( 'f1' );

使用TOMAP并通过HbaseStorage保存它但不在那里分配地图,就可以了。