lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@apache.org>
Subject Re: Patch - IndexReader methods and MultiSearcher methods...
Date Thu, 24 Feb 2005 20:58:41 GMT
If you add things that will appear in the javadoc then they need javadoc 
comments.

Also, I assume that the reason you make the reader field protected is 
because getReader() is not sufficient, i.e., you want to set the reader. 
  This would stylistically be better done with a setReader() method, no? 
  Do you only change it at construction, or at runtime?  If you only 
change it at construction, then super(reader) in the constructor might 
suffice.  The reason I ask is that folks might cache things for a 
Searcher, and these might be invalidated if the reader changes, thus we 
shouldn't make it too easy to change the reader.  Lucene's built-in 
caching is all keyed by the IndexReader, not the Searcher, so should not 
be broken by such an addition.

Doug

Kevin A. Burton wrote:
> 
> Can I get this patch accepted?
> 
> It makes 3 small changes:
> 
> 1. the 'reader' field of IndexSearcher is now protected so that it can 
> be extended and accessed by child classes.
> 2. New method in IndexSearcher called getIndexReader  which can 
> obviously be used to obtain the index reader it was created with.
> 3. MultiSearcher now has a getSearchables() method to return all 
> searchers the multisearcher was created with.
> 
> These are essentially the only changes I've made to my local build so if 
> I can get these accepted (this is my second attempt (ug)) then I don't 
> have to patch everytime I upgrade.
> 
> Thanks!
> 
> 
> 
> --- lucene-1.4.3/src/java/org/apache/lucene/search/IndexSearcher.java    
> 2004-10-07 00:50:21.000000000 -0700
> +++ 
> lucene-1.4.3-burton/src/java/org/apache/lucene/search/IndexSearcher.java    
> 2005-02-24 12:19:37.000000000 -0800
> @@ -30,7 +30,7 @@
>  * or {@link #search(Query,Filter)} methods.
>  */
> public class IndexSearcher extends Searcher {
> -  IndexReader reader;
> +  protected IndexReader reader;
>   private boolean closeReader;
> 
>   /** Creates a searcher searching the index in the named directory. */
> @@ -53,6 +53,10 @@
>     this.closeReader = closeReader;
>   }
> 
> +  public IndexReader getIndexReader() {
> +    return reader;
> +  }
> +
>   /**
>    * Note that the underlying IndexReader is not closed, if
>    * IndexSearcher was constructed with IndexSearcher(IndexReader r).
> @@ -139,7 +143,6 @@
>     return new TopFieldDocs(totalHits[0], scoreDocs, hq.getFields());
>   }
> 
> -
>   // inherit javadoc
>   public void search(Query query, Filter filter,
>                      final HitCollector results) throws IOException {
> diff --new-file --unified --ignore-all-space --recursive 
> lucene-1.4.3/src/java/org/apache/lucene/search/MultiSearcher.java 
> lucene-1.4.3-burton/src/java/org/apache/lucene/search/MultiSearcher.java
> --- lucene-1.4.3/src/java/org/apache/lucene/search/MultiSearcher.java    
> 2004-03-29 14:48:03.000000000 -0800
> +++ 
> lucene-1.4.3-burton/src/java/org/apache/lucene/search/MultiSearcher.java    
> 2005-02-24 12:16:02.000000000 -0800
> @@ -131,7 +131,6 @@
>     return new TopDocs(totalHits, scoreDocs);
>   }
> 
> -
>   public TopFieldDocs search (Query query, Filter filter, int n, Sort sort)
>     throws IOException {
>     FieldDocSortedHitQueue hq = null;
> @@ -157,7 +156,6 @@
>     return new TopFieldDocs (totalHits, scoreDocs, hq.getFields());
>   }
> 
> -
>   // inherit javadoc
>   public void search(Query query, Filter filter, final HitCollector 
> results)
>     throws IOException {
> @@ -187,4 +185,8 @@
>     return searchables[i].explain(query,doc-starts[i]); // dispatch to 
> searcher
>   }
> 
> +  public Searchable[] getSearchables() {
> +    return searchables;
> +  }
> +
> }
> 

---------------------------------------------------------------------
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