使用Apache Pig版本0.10.1.21(已报告),CentOS版本6.3(最终版),jdk1.6.0_31(Virtualbox上的Hortonworks Sandbox v1.2,3.5 GB RAM)
$ cat data.txt 11,11,22 33,34,35 47,0,21 33,6,51 56,6,11 11,25,67 $ cat GrpTest.pig A = LOAD 'data.txt' USING PigStorage(',') AS (f1:int,f2:int,f3:int); B = GROUP A BY f1; DESCRIBE B; DUMP B;
pig -x local GrpTest.pig
[Thread-12] WARN org.apache.hadoop.mapred.JobClient - No job jar file set. User classes may not be found. See JobConf(Class) or JobConf#setJar(String). [Thread-12] INFO org.apache.hadoop.mapreduce.lib.input.FileInputFormat - Total input paths to process : 1 [Thread-13] INFO org.apache.hadoop.mapred.Task - Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@19a9bea3 [Thread-13] INFO org.apache.hadoop.mapred.MapTask - io.sort.mb = 100 [Thread-13] WARN org.apache.hadoop.mapred.LocalJobRunner - job_local_0002 java.lang.OutOfMemoryError: Java heap space at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.(MapTask.java:949) at org.apache.hadoop.mapred.MapTask$NewOutputCollector. (MapTask.java:674) at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:756) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:370) at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:212) [main] ERROR org.apache.pig.tools.pigstats.PigStatsUtil - 1 map reduce job(s) failed! [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1066: Unable to open iterator for alias B
在Java堆空间:java.lang.OutOfMemoryError每次使用GROUP或加入在本地模式下执行的猪脚本时错误.在HDFS上以mapreduce模式执行脚本时没有错误.
问题1:如果数据样本很小并且本地模式应该使用比HDFS模式更少的资源,那么为什么会出现OutOfMemory错误?
问题2:是否有解决方案在本地模式下成功运行GROUP或JOIN的小型猪脚本?
解决方案:强制pig为java属性io.sort.mb分配更少的内存我在这里设置为10 MB,错误消失.不确定什么是最好的值,但至少,这允许在本地模式下练习猪语法
$ cat GrpTest.pig --avoid java.lang.OutOfMemoryError: Java heap space (execmode: -x local) set io.sort.mb 10; A = LOAD 'data.txt' USING PigStorage(',') AS (f1:int,f2:int,f3:int); B = GROUP A BY f1; DESCRIBE B; DUMP B;