こんにちは私はのLucene Javaライブラリを含む自分のアプリケーションに問題があると私はここに私のAndroidのプログラムがエラーのOutOfMemory
は/エラーコンソールのサンプル
ERRORある丁度エラーが何であるかを知らない連中を与え続けるのはなぜAndroidRuntime(25909):java.lang.OutOfMemoryError:(ヒープサイズ= 32775KB、割り当て済み= 30112KB、ビットマップサイズ= 0KB) ERROR/AndroidRuntime(25909):org.apache.lucene.index.FreqProxTermsWriterPerField $ FreqProxPostingsArray(FreqProxTermsWriterPerField。 java:193) ERROR/AndroidRuntime(25909):org.apache.lucene.index.FreqProxTermsWriterPerField $ FreqProxPostingsArray.newInstance(FreqProxTermsWrit (25909):org.apache.lucene.index.ParallelPostingsArray.grow(ParallelPostingsArray.java:48) ERROR/AndroidRuntime(25909):org.apache.lucene.index。 (HashPerField.java:440) ERROR/AndroidRuntime(25909):org.apache.lucene.index.TermsHashPerField.add(TermsHashPerField.java:440)ERROR/AndroidRuntime(25909):org.apache。 lucene.index.DocInverterPerField.processFields(DocInverterPerField.java:172) ERROR/AndroidRuntime(25909):org.apache.lucene.index.DocFieldProcessorPerThread.processDocument(DocFieldProcessorPerThread.java:278) ERROR/AndroidRuntime(25909)で、:でorg.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:766) ERROR/AndroidRuntime(25909):at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:2067) ERROR/AndroidRuntime(25909):org.apache.lucene.index.IndexWriter.addDocumentで(IndexWriter.java:2041)
とそれは、インデックス作成者のフィールドと私はそれが何であるかわからないと言います
あなたは私を助けることができますか?病気お返事を
に感謝し、ここに私のコード
public class CalculateWeightPage {
protected static Crawlers crawlers;
protected static StopWordsAndStemmer stemmer;
protected static CountWords countWords;
protected static StringSplitter splitter;
protected static ShortingStringArray shortingStringArray;
public static String[][] calulateRelevancePage(String[][] wkt,String urlPage) {
// 1.1.Defining parameters
int p = 0;
int count = 0;
int count2 = 0;
String title = "";
String body = "";
int titleFreq = 0;
int bodyFreq = 0;
String[][] wkp = null ;
int newTf = 0;
int y = 0;
int counter = 0;
try {
// 1.2.Extracting the text body and title from webPage
Map bodyTitle = crawlers.extractBodyAndTitle(urlPage);
if(bodyTitle.containsKey("title")){
title = stemmer.removeStopWordsAndStem(((String) bodyTitle.get("title")).toLowerCase());
body = stemmer.removeStopWordsAndStem(((String) bodyTitle.get("body")).toLowerCase());
// 1.4.Making a list containing unique words from text title and body
List bodyTitleUnique = splitter.StringUnique(body);
int sizeList = bodyTitleUnique.size();
wkp = new String[sizeList][2];
// 1.5.Calculating each tf
for (int r = 0; r < sizeList; r++) {
titleFreq = 0;
bodyFreq = 0;
// 1.5.1.Calculating tf in title
titleFreq = countWords.calculate(title, bodyTitleUnique.get(r).toString());
// 1.5.2.Calculating tf in body
bodyFreq = countWords.calculate(body, bodyTitleUnique.get(r).toString());
if (!(titleFreq == 0)) {
newTf = (titleFreq * 2) + (bodyFreq - titleFreq);
} else {
newTf = titleFreq + bodyFreq;
}
// 1.6.Inserting the result into string array
if(!(newTf == 0)){
wkp[r][0] = bodyTitleUnique.get(r).toString();
wkp[r][1] = String.valueOf(newTf);
}
}
}else{
return wkp;
}
} catch (Exception e) {
// TODO: handle exception
}
return wkp;
}
}
、これが第二のコード
public class CountWords {
CountWords() {
}
protected static StopWordsAndStemmer stemmer;
public static int calculate(String txt, String keyword) {
StopAnalyzer analyzer = new StopAnalyzer(Version.LUCENE_CURRENT);
RAMDirectory idx = new RAMDirectory();
int counts = 0;
int count = 0;
try {
IndexWriter writer = new IndexWriter(idx, analyzer, true,
IndexWriter.MaxFieldLength.UNLIMITED);
Document doc = new Document();
//String text1 = stemmer.removeStopWordsAndStem(txt.toLowerCase());
writer.addDocument(createDocument("", txt));
writer.optimize();
writer.close();
Searcher searcher = new IndexSearcher(idx);
IndexReader ir = IndexReader.open(idx);
TermDocs termDocs = ir.termDocs(new Term("content", keyword.toLowerCase()));
while (termDocs.next()) {
count = count + termDocs.freq();
}
//counts = count(count);
searcher.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
return count;
}
private static Document createDocument(String title, String content) {
Document doc = new Document();
doc.add(new Field("content", new StringReader(content)));
return doc;
}
private static int search(Searcher searcher, String queryString)throws ParseException, IOException {
StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);
QueryParser parser = new QueryParser(Version.LUCENE_CURRENT, "content",analyzer);
Query query = parser.parse(queryString);
TopScoreDocCollector collector = TopScoreDocCollector.create(10, true);
searcher.search(query, collector);
return collector.getTotalHits();
}
public static Integer count(int count) {
if (count == 0) {
count = 1;
} else {
count = count;
}
return count;
}
}
<「あなたたちは私を助けることができる」 - 私はすでに私のコード – fge
私はLuceneのは、大量のメモリを持つサーバー用に設計されていた疑いがあります。 http://wiki.apache.org/lucene-java/PoweredBy私はLucene 3.5.0にいくつかの重要なメモリ使用量の改善があることに気付きます。あなたはそのバージョンを使用していますか? – Carlo
を添付していないコードを使用せずに、そこには –