piglatin:java.lang.outofmemoryerror:超出gc开销限制

eoigrqb6  于 2021-06-24  发布在  Pig
关注(0)|答案(1)|浏览(353)

我对Pig拉丁语很陌生,我在做作业的时候试着理解Pig拉丁语,我以前用map reduce做过。我得到了gc开销错误,ps:我的输入只是10行简单的csv文件。
我正在尝试将csv格式转换为arff。
我的自定义项:

public class CSV2ARFF extends EvalFunc<String> {
private String arffDataString;
private String arffHeaderString;

public String exec(Tuple input) throws IOException {
    if (input == null || input.size() == 0)
        return null;
    try{
            System.out.println(">>> " + input.get(0).toString());
            // csv to instances
            ByteArrayInputStream inputStream = new ByteArrayInputStream(input.get(0).toString().getBytes("UTF-8"));
            CSVLoader loader = new CSVLoader();             
            loader.setSource(inputStream);
            Instances data = loader.getDataSet(); //**Line #30**
            //convert into arff
            ArffSaver arff = new ArffSaver();               
            arff.setInstances(data);                
            this.arffDataString = arff.getInstances().toString();               
            Instances arffdata = arff.getInstances();
            // header
            Instances header = new Instances(arffdata, 0);
            this.arffHeaderString = header.toString();
            this.arffDataString = this.arffDataString.substring(this.arffHeaderString.length());

            return arffDataString;

    }catch(Exception e){
        System.err.println("CSV2ARFF: failed to proces input; error - " + e.getMessage());
        return null;
    }
}

}
我的剧本。Pig

REGISTER ./csv2arff.jar;
REGISTER ./weka.jar;

csvraw = LOAD 'sample' USING PigStorage('\n') as (c);

arffraws = FOREACH csvraw GENERATE pighw2java.CSV2ARFF(c);

--output

STORE arffraws INTO 'output' using PigStorage();

错误

java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.nio.CharBuffer.wrap(CharBuffer.java:369)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:310)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:154)
at java.io.BufferedReader.read(BufferedReader.java:175)
at java.io.StreamTokenizer.read(StreamTokenizer.java:500)
at java.io.StreamTokenizer.nextToken(StreamTokenizer.java:544)
at weka.core.converters.ConverterUtils.getToken(ConverterUtils.java:888)
at weka.core.converters.CSVLoader.readHeader(CSVLoader.java:937)
at weka.core.converters.CSVLoader.readStructure(CSVLoader.java:578)
at weka.core.converters.CSVLoader.getStructure(CSVLoader.java:563)
at weka.core.converters.CSVLoader.getDataSet(CSVLoader.java:596)
at pighw2java.CSV2ARFF.exec(CSV2ARFF.java:30)
at pighw2java.CSV2ARFF.exec(CSV2ARFF.java:1)
laawzig2

laawzig21#

我也遇到过类似的情况。在本地模式下运行清管器导致此错误(pig-x local)。当我在map reduce模式下运行相同的查询时,它得到了解析(pig)。
希望有帮助。

相关问题