lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jiří Kuhn <k...@fg.cz>
Subject RE: OutOfMemory example
Date Mon, 13 Sep 2004 13:52:23 GMT
I disagree or I don't understand. 

I can change the code as it is shown below. Now I must reopen the index to see the changes,
but the memory problem remains. I realy don't know what I'm doing wrong, the code is so simple.

Jiri.

	...

    public static void main(String[] args) throws IOException
    {
        Directory directory = create_index();

        for (int i = 1; i < 100; i++) {
            System.err.println("loop " + i + ", index version: " + IndexReader.getCurrentVersion(directory));
            search_index(directory);
            add_to_index(directory, i);
        }
    }

    private static void add_to_index(Directory directory, int i) throws IOException
    {
        IndexWriter writer = new IndexWriter(directory, new StandardAnalyzer(), false);

        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        Document doc = new Document();

        doc.add(Field.Keyword("date", df.format(new Date(System.currentTimeMillis()))));
        doc.add(Field.Keyword("id", "CD" + String.valueOf(i)));
        doc.add(Field.Text("text", "Tohle neni text " + i));
        writer.addDocument(doc);

        System.err.println("index size: " + writer.docCount());
        writer.close();
    }

	...

-----Original Message-----
From: John Moylan [mailto:johnm@rte.ie]
Sent: Monday, September 13, 2004 3:25 PM
To: Lucene Users List
Subject: Re: OutOfMemory example


You should reuse your old index (as eg an application variable) unless 
it has changed - use getCurrentVersion to check the index for updates. 
This has come up before.

John


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message