使用pig将数据存储到Hbase

时间:2016-12-09 16:26:27

标签: java hbase apache-pig

我有一个包含架构的表

TOP: {businessid: bytearray,best_review::review_weight: double,best_review::REVIEWS_DATA::businessid: bytearray,best_review::REVIEWS_DATA::reviewid: bytearray,best_review::REVIEWS_DATA::stars: bytearray}

我想将它存储在Hbase表中,我使用以下命令

STORE TOP INTO 'hbase://master_data'USING org.apache.pig.backend.hadoop.hbase.HBaseStorage(
'master_info:best_review::review_weight, master_info:best_review::REVIEWS_DATA::reviewid, mastert_info:best_review::REVIEWS_DATA::stars '); 

我收到以下错误:

java.lang.Exception: java.io.IOException: java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
at org.apache.hadoop.mapred.LocalJobRunner$Job.runTasks(LocalJobRunner.java:462)
at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:529)Caused by: java.io.IOException: java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigGenericMapReduce$Reduce.runPipeline(PigGenericMapReduce.java:479)
at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigGenericMapReduce$Reduce.processOnePackageOutput(PigGenericMapReduce.java:442)
at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigGenericMapReduce$Reduce.reduce(PigGenericMapReduce.java:422)
at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigGenericMapReduce$Reduce.reduce(PigGenericMapReduce.java:269)
at org.apache.hadoop.mapreduce.Reducer.run(Reducer.java:171)
at org.apache.hadoop.mapred.ReduceTask.runNewReducer(ReduceTask.java:627)
at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:389)
at org.apache.hadoop.mapred.LocalJobRunner$Job$ReduceTaskRunnable.run(LocalJobRunner.java:319)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)Caused by: java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
at java.util.ArrayList.get(ArrayList.java:429)
at org.apache.pig.backend.hadoop.hbase.HBaseStorage.putNext(HBaseStorage.java:1003)
at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigOutputFormat$PigRecordWriter.write(PigOutputFormat.java:136)
at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigOutputFormat$PigRecordWriter.write(PigOutputFormat.java:95)
at org.apache.hadoop.mapred.ReduceTask$NewTrackingRecordWriter.write(ReduceTask.java:558)
at org.apache.hadoop.mapreduce.task.TaskInputOutputContextImpl.write(TaskInputOutputContextImpl.java:89)
at org.apache.hadoop.mapreduce.lib.reduce.WrappedReducer$Context.write(WrappedReducer.java:105)
at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigGenericMapReduce$Reduce.runPipeline(PigGenericMapReduce.java:477)

请告诉我如何运行存储命令。谢谢!

1 个答案:

答案 0 :(得分:0)

HBaseStorage的参数采用colFamily列表:空格分隔的列如

  

raw = LOAD' hbase:// SampleTable'          使用org.apache.pig.backend.hadoop.hbase.HBaseStorage(          ' info:first_name info:last_name friends:* info:*')

列列表参数中的每个列都是空格分隔的,显然有两个参数用逗号分隔。

我看到你在很多地方都有。你能验证一下吗