0

我是 apache mahout 的新手。我正在尝试使用 Apache Mahout 的 FP 增长算法从 java 运行它。这是我使用的代码,

FPGrowth<String> fp = new FPGrowth<String>(); 
FileLineIterable file = new FileLineIterable(new File(FPInputFileName)); 
int minSupport = 2;
int maxHeapSize = 50;
Writer writer = null;
StringOutputConverter output = new StringOutputConverter(new SequenceFileOutputCollector<Text,TopKStringPatterns>(writer));
String pattern = " "; //currently understood as splitter
try{
        fp.generateTopKFrequentPatterns(new StringRecordIterator(file,pattern), fp.generateFList(new StringRecordIterator(file, pattern), minSupport), minSupport, maxHeapSize, null, output, null);
}catch(Exception err){
    err.printStackTrace();
}

我面临以下错误:

    java.lang.NullPointerException
at org.apache.mahout.fpm.pfpgrowth.fpgrowth.FPGrowth.growth(FPGrowth.java:331)
at org.apache.mahout.fpm.pfpgrowth.fpgrowth.FPGrowth.fpGrowth(FPGrowth.java:211)
at org.apache.mahout.fpm.pfpgrowth.fpgrowth.FPGrowth.generateTopKFrequentPatterns(FPGrowth.java:302)
at org.apache.mahout.fpm.pfpgrowth.fpgrowth.FPGrowth.generateTopKFrequentPatterns(FPGrowth.java:174)
at myProgram.main(myProgram.java:96)

如何解释这个?这是因为 writer 设置为 null 吗?请帮忙。

问候, psun

4

1 回答 1

0

该错误是因为我没有正确调用方法 generateTopKFrequentPatterns()。一旦我修改了调用,就没有错误了。

于 2012-11-29T05:22:03.983 回答