lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gol...@apache.org
Subject cvs commit: jakarta-lucene/src/java/org/apache/lucene/search IndexSearcher.java
Date Wed, 21 Apr 2004 17:26:28 GMT
goller      2004/04/21 10:26:28

  Modified:    src/java/org/apache/lucene/search IndexSearcher.java
  Log:
  Making bahavior of close() more consistent.
  
  Revision  Changes    Path
  1.17      +16 -4     jakarta-lucene/src/java/org/apache/lucene/search/IndexSearcher.java
  
  Index: IndexSearcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/IndexSearcher.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- IndexSearcher.java	29 Mar 2004 22:48:03 -0000	1.16
  +++ IndexSearcher.java	21 Apr 2004 17:26:28 -0000	1.17
  @@ -32,25 +32,37 @@
    */
   public class IndexSearcher extends Searcher {
     IndexReader reader;
  +  private boolean closeReader;
   
     /** Creates a searcher searching the index in the named directory. */
     public IndexSearcher(String path) throws IOException {
  -    this(IndexReader.open(path));
  +    this(IndexReader.open(path), true);
     }
   
     /** Creates a searcher searching the index in the provided directory. */
     public IndexSearcher(Directory directory) throws IOException {
  -    this(IndexReader.open(directory));
  +    this(IndexReader.open(directory), true);
     }
   
     /** Creates a searcher searching the provided index. */
     public IndexSearcher(IndexReader r) {
  +    this(r, false);
  +  }
  +  
  +  private IndexSearcher(IndexReader r, boolean closeReader) {
       reader = r;
  +    this.closeReader = closeReader;
     }
   
  -  // inherit javadoc
  +  /**
  +   * Note that the underlying IndexReader is not closed, if
  +   * IndexSearcher was constructed with IndexSearcher(IndexReader r).
  +   * If the IndexReader was supplied implicitly by specifying a directory, then
  +   * the IndexReader gets closed.
  +   */
     public void close() throws IOException {
  -    reader.close();
  +    if(closeReader)
  +      reader.close();
     }
   
     // inherit javadoc
  
  
  

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


Mime
View raw message