mirror of https://github.com/apache/lucene.git
LUCENE-1558: default readOnly=true for IndexReader.open(Dir) and new IndexSearcher(Dir)
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@836390 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cacb3506f6
commit
ce423d5d3b
|
@ -30,6 +30,11 @@ Changes in backwards compatibility policy
|
|||
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
|
||||
|
|
|
@ -178,6 +178,16 @@ public abstract class IndexReader implements Cloneable,Closeable {
|
|||
}
|
||||
}
|
||||
|
||||
/** 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
|
||||
|
|
|
@ -53,6 +53,16 @@ public class IndexSearcher extends Searcher {
|
|||
protected IndexReader[] subReaders;
|
||||
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
|
||||
|
@ -179,14 +189,6 @@ public class IndexSearcher extends Searcher {
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue