You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by mi...@apache.org on 2009/11/15 19:47:30 UTC
svn commit: r836390 - in /lucene/java/trunk: CHANGES.txt
src/java/org/apache/lucene/index/IndexReader.java
src/java/org/apache/lucene/search/IndexSearcher.java
Author: mikemccand
Date: Sun Nov 15 18:47:29 2009
New Revision: 836390
URL: http://svn.apache.org/viewvc?rev=836390&view=rev
Log:
LUCENE-1558: default readOnly=true for IndexReader.open(Dir) and new IndexSearcher(Dir)
Modified:
lucene/java/trunk/CHANGES.txt
lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java
lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java
Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=836390&r1=836389&r2=836390&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Sun Nov 15 18:47:29 2009
@@ -30,6 +30,11 @@
overridden methods unchanged and added varargs to constructors,
static, or final methods (MultiSearcher,...). (Uwe Schindler)
+* LUCENE-1558: IndexReader.open(Directory) now opens a readOnly=true
+ reader, and new IndexSearcher(Directory) does the same. Note that
+ this is a change in the default from 2.9, when these methods were
+ previously deprecated. (Mike McCandless)
+
Changes in runtime behavior
* LUCENE-1677: Remove the system property to set SegmentReader class
Modified: lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java?rev=836390&r1=836389&r2=836390&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java Sun Nov 15 18:47:29 2009
@@ -178,6 +178,16 @@
}
}
+ /** Returns a IndexReader reading the index in the given
+ * Directory, with readOnly=true.
+ * @param directory the index directory
+ * @throws CorruptIndexException if the index is corrupt
+ * @throws IOException if there is a low-level IO error
+ */
+ public static IndexReader open(final Directory directory) throws CorruptIndexException, IOException {
+ return open(directory, null, null, true, DEFAULT_TERMS_INDEX_DIVISOR);
+ }
+
/** Returns an IndexReader reading the index in the given
* Directory. You should pass readOnly=true, since it
* gives much better concurrent performance, unless you
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java?rev=836390&r1=836389&r2=836390&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java Sun Nov 15 18:47:29 2009
@@ -54,6 +54,16 @@
protected int[] docStarts;
/** Creates a searcher searching the index in the named
+ * directory, with readOnly=true
+ * @throws CorruptIndexException if the index is corrupt
+ * @throws IOException if there is a low-level IO error
+ * @param path directory where IndexReader will be opened
+ */
+ public IndexSearcher(Directory path) throws CorruptIndexException, IOException {
+ this(IndexReader.open(path, true), true);
+ }
+
+ /** Creates a searcher searching the index in the named
* directory. You should pass readOnly=true, since it
* gives much better concurrent performance, unless you
* intend to do write operations (delete documents or
@@ -179,14 +189,6 @@
public TopFieldDocs search(Weight weight, Filter filter, final int nDocs,
Sort sort, boolean fillFields)
throws IOException {
-
- SortField[] fields = sort.fields;
- for(int i = 0; i < fields.length; i++) {
- SortField field = fields[i];
- String fieldname = field.getField();
- int type = field.getType();
- }
-
TopFieldCollector collector = TopFieldCollector.create(sort, nDocs,
fillFields, fieldSortDoTrackScores, fieldSortDoMaxScore, !weight.scoresDocsOutOfOrder());
search(weight, filter, collector);