diff --git a/lucene/src/java/org/apache/lucene/index/AtomicReader.java b/lucene/src/java/org/apache/lucene/index/AtomicReader.java index 40aba3a2f49..bbfd8ccabed 100644 --- a/lucene/src/java/org/apache/lucene/index/AtomicReader.java +++ b/lucene/src/java/org/apache/lucene/index/AtomicReader.java @@ -25,30 +25,20 @@ import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.ReaderUtil; // for javadocs -/** IndexReader is an abstract class, providing an interface for accessing an +/** {@code AtomicReader} is an abstract class, providing an interface for accessing an index. Search of an index is done entirely through this abstract interface, - so that any subclass which implements it is searchable. + so that any subclass which implements it is searchable. IndexReaders implemented + by this subclass do not consist of several sub-readers, + they are atomic. They support retrieval of stored fields, doc values, terms, + and postings. -

Concrete subclasses of IndexReader are usually constructed with a call to - one of the static open() methods, e.g. {@link - #open(Directory)}. - -

For efficiency, in this API documents are often referred to via +

For efficiency, in this API documents are often referred to via document numbers, non-negative integers which each name a unique - document in the index. These document numbers are ephemeral--they may change + document in the index. These document numbers are ephemeral -- they may change as documents are added to and deleted from an index. Clients should thus not rely on a given document having the same number between sessions.

- NOTE: for backwards API compatibility, several methods are not listed - as abstract, but have no useful implementations in this base class and - instead always throw UnsupportedOperationException. Subclasses are - strongly encouraged to override these methods, but in many cases may not - need to. -

- -

-

NOTE: {@link IndexReader} instances are completely thread safe, meaning multiple threads can call any of its methods, diff --git a/lucene/src/java/org/apache/lucene/index/CompositeReader.java b/lucene/src/java/org/apache/lucene/index/CompositeReader.java index 6e47e77300d..aec0bba5d8d 100644 --- a/lucene/src/java/org/apache/lucene/index/CompositeReader.java +++ b/lucene/src/java/org/apache/lucene/index/CompositeReader.java @@ -20,30 +20,26 @@ package org.apache.lucene.index; import org.apache.lucene.search.SearcherManager; // javadocs import org.apache.lucene.store.*; -/** IndexReader is an abstract class, providing an interface for accessing an - index. Search of an index is done entirely through this abstract interface, - so that any subclass which implements it is searchable. - +/** Instances of this reader type can only + be used to get stored fields from the underlying AtomicReaders, + but it is not possible to directly retrieve postings. To do that, get + the sub-readers via {@link #getSequentialSubReaders}. + +

IndexReader instances for indexes on disk are usually constructed + with a call to one of the static DirectoryReader,open() methods, + e.g. {@link DirectoryReader#open(Directory)}. {@link DirectoryReader} implements + the {@code CompositeReader} interface, it is not possible to directly get postings.

Concrete subclasses of IndexReader are usually constructed with a call to one of the static open() methods, e.g. {@link #open(Directory)}.

For efficiency, in this API documents are often referred to via document numbers, non-negative integers which each name a unique - document in the index. These document numbers are ephemeral--they may change + document in the index. These document numbers are ephemeral -- they may change as documents are added to and deleted from an index. Clients should thus not rely on a given document having the same number between sessions.

- NOTE: for backwards API compatibility, several methods are not listed - as abstract, but have no useful implementations in this base class and - instead always throw UnsupportedOperationException. Subclasses are - strongly encouraged to override these methods, but in many cases may not - need to. -

- -

-

NOTE: {@link IndexReader} instances are completely thread safe, meaning multiple threads can call any of its methods, diff --git a/lucene/src/java/org/apache/lucene/index/DirectoryReader.java b/lucene/src/java/org/apache/lucene/index/DirectoryReader.java index 69c0cd848e4..75d97717418 100644 --- a/lucene/src/java/org/apache/lucene/index/DirectoryReader.java +++ b/lucene/src/java/org/apache/lucene/index/DirectoryReader.java @@ -31,10 +31,28 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; import org.apache.lucene.util.IOUtils; -/** - * An IndexReader which reads indexes with multiple segments. - * To get an instance of this reader use {@link #open(Directory)}. - */ +/** DirectoryReader is an implementation of {@link CompositeReader} + that can read indexes in a {@link Directory}. + +

DirectoryReader instances are usually constructed with a call to + one of the static open() methods, e.g. {@link + #open(Directory)}. + +

For efficiency, in this API documents are often referred to via + document numbers, non-negative integers which each name a unique + document in the index. These document numbers are ephemeral -- they may change + as documents are added to and deleted from an index. Clients should thus not + rely on a given document having the same number between sessions. + +

+

NOTE: {@link + IndexReader} instances are completely thread + safe, meaning multiple threads can call any of its methods, + concurrently. If your application requires external + synchronization, you should not synchronize on the + IndexReader instance; use your own + (non-Lucene) objects instead. +*/ public final class DirectoryReader extends BaseMultiReader { static int DEFAULT_TERMS_INDEX_DIVISOR = 1; diff --git a/lucene/src/java/org/apache/lucene/index/IndexReader.java b/lucene/src/java/org/apache/lucene/index/IndexReader.java index 8b9ead38f46..d1b2cd1ddb1 100644 --- a/lucene/src/java/org/apache/lucene/index/IndexReader.java +++ b/lucene/src/java/org/apache/lucene/index/IndexReader.java @@ -36,26 +36,32 @@ import org.apache.lucene.util.ReaderUtil; // for javadocs index. Search of an index is done entirely through this abstract interface, so that any subclass which implements it is searchable. -

Concrete subclasses of IndexReader are usually constructed with a call to - one of the static open() methods, e.g. {@link - #open(Directory)}. +

There are two different types of IndexReaders: +

+ +

IndexReader instances for indexes on disk are usually constructed + with a call to one of the static DirectoryReader,open() methods, + e.g. {@link DirectoryReader#open(Directory)}. {@link DirectoryReader} implements + the {@link CompositeReader} interface, it is not possible to directly get postings.

For efficiency, in this API documents are often referred to via document numbers, non-negative integers which each name a unique - document in the index. These document numbers are ephemeral--they may change + document in the index. These document numbers are ephemeral -- they may change as documents are added to and deleted from an index. Clients should thus not rely on a given document having the same number between sessions.

- NOTE: for backwards API compatibility, several methods are not listed - as abstract, but have no useful implementations in this base class and - instead always throw UnsupportedOperationException. Subclasses are - strongly encouraged to override these methods, but in many cases may not - need to. -

- -

-

NOTE: {@link IndexReader} instances are completely thread safe, meaning multiple threads can call any of its methods,