lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Klaus Moysich" <klaus.moys...@ascirum.de>
Subject AW: indexReader close method
Date Thu, 03 Mar 2005 19:28:41 GMT


-----Urspr√ľngliche Nachricht-----
Von: hossman@hal.rescomp.berkeley.edu [mailto:hossman@hal.rescomp.berkeley.edu] Im Auftrag
von Chris Hostetter
Gesendet: Montag, 6. Dezember 2004 21:32
An: Lucene Users List
Betreff: Re: indexReader close method


: Do you know why I can't close the IndexReader  explicitly under some
: circumstances and why, when I do manage to close it I can still call
: methods on the reader?

1) I tried to create a test case that demonstrated your bug based on the
code outline you provided, and i couldn't (see below).  that implies to me
that somethine else is going on.  If you can create a completely self
contained program that demonstrates your bug and mail it to the list that
would help us help you.

2) the documentation for IndexReader.close() says...

	Closes files associated with this index. Also saves any new deletions to
	disk. No other methods should be called after this has been called.

...note the word "should".  it doesn't say what the other methods will do
if you try to call them, just that you shouldn't try.  In some cases they
may generate exceptions, in other cases they may just be able to return
you data based on state internal to the object which is unaffected by the
fact that the files have all been closed.

-Hoss

    public static void main(String argv[]) throws IOException {

        /* create a directory */
        String d = System.getProperty("java.io.tmpdir", "tmp")
            + System.getProperty("file.separator")
            + "index-dir-" + (new Random()).nextInt(1000);
        Directory trash = FSDirectory.getDirectory(d, true);


        /* build index */
        Document doc;
        IndexWriter w = new IndexWriter(d, new SimpleAnalyzer(), true);
        doc = new Document();
        doc.add(Field.Text("words", "apple emu"));
        w.addDocument(doc);
        w.optimize();
        w.close();

        /* search index */
        IndexReader r = IndexReader.open(d);
        IndexSearcher s = new IndexSearcher(r);
        Hits h = s.search(new TermQuery(new Term("words", "apple")));

        s.close();
        r.close();

        System.out.println("Reader? - " + r.maxDoc());

    }






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


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


Mime
View raw message