org.apache.lucene.store.instantiated

## Class InstantiatedIndexReader

- java.lang.Object
- - org.apache.lucene.index.IndexReader
  - - org.apache.lucene.store.instantiated.InstantiatedIndexReader

- All Implemented Interfaces:
    java.lang.Cloneable

      public class InstantiatedIndexReader
      extends org.apache.lucene.index.IndexReader

  An InstantiatedIndexReader is not a snapshot in time, it is completely in sync with the latest commit to the store!

  Consider using InstantiatedIndex as if it was immutable.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.lucene.index.IndexReader

      `org.apache.lucene.index.IndexReader.FieldOption`

  - ### Field Summary

    - ### Fields inherited from class org.apache.lucene.index.IndexReader

      `hasChanges`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `InstantiatedIndexReader(InstantiatedIndex index)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `org.apache.lucene.store.Directory` | `directory()`
    `int` | `docFreq(org.apache.lucene.index.Term t)`
    `protected void` | `doClose()`
    `protected void` | `doCommit()`
    `org.apache.lucene.document.Document` | `document(int n)` Returns the stored fields of the `n`th `Document` in this index.
    `org.apache.lucene.document.Document` | `document(int n, org.apache.lucene.document.FieldSelector fieldSelector)` Return the `Document` at the `n`th position.
    `protected void` | `doDelete(int docNum)`
    `protected void` | `doSetNorm(int doc, java.lang.String field, byte value)`
    `protected void` | `doUndeleteAll()`
    `java.util.Collection` | `getFieldNames(org.apache.lucene.index.IndexReader.FieldOption fieldOption)`
    `InstantiatedIndex` | `getIndex()`
    `org.apache.lucene.index.TermFreqVector` | `getTermFreqVector(int docNumber, java.lang.String field)`
    `void` | `getTermFreqVector(int docNumber, java.lang.String field, org.apache.lucene.index.TermVectorMapper mapper)`
    `void` | `getTermFreqVector(int docNumber, org.apache.lucene.index.TermVectorMapper mapper)`
    `org.apache.lucene.index.TermFreqVector[]` | `getTermFreqVectors(int docNumber)`
    `long` | `getVersion()` An InstantiatedIndexReader is not a snapshot in time, it is completely in sync with the latest commit to the store!
    `boolean` | `hasDeletions()`
    `boolean` | `isCurrent()` An InstantiatedIndexReader is always current! Check whether this IndexReader is still using the current (i.e., most recently committed) version of the index.
    `boolean` | `isDeleted(int n)`
    `boolean` | `isOptimized()`
    `int` | `maxDoc()`
    `byte[]` | `norms(java.lang.String field)` never ever touch these values.
    `void` | `norms(java.lang.String field, byte[] bytes, int offset)`
    `int` | `numDocs()`
    `org.apache.lucene.index.TermDocs` | `termDocs()`
    `org.apache.lucene.index.TermDocs` | `termDocs(org.apache.lucene.index.Term term)`
    `org.apache.lucene.index.TermPositions` | `termPositions()`
    `org.apache.lucene.index.TermEnum` | `terms()`
    `org.apache.lucene.index.TermEnum` | `terms(org.apache.lucene.index.Term t)`

    - ### Methods inherited from class org.apache.lucene.index.IndexReader

      `acquireWriteLock, clone, clone, close, commit, commit, decRef, deleteDocument, deleteDocuments, ensureOpen, flush, flush, getCommitUserData, getCommitUserData, getCurrentVersion, getCurrentVersion, getCurrentVersion, getDeletesCacheKey, getDisableFakeNorms, getFieldCacheKey, getIndexCommit, getRefCount, getSequentialSubReaders, getTermInfosIndexDivisor, getUniqueTermCount, hasNorms, incRef, indexExists, indexExists, indexExists, isLocked, isLocked, lastModified, lastModified, lastModified, listCommits, main, numDeletedDocs, open, open, open, open, open, open, open, open, open, open, open, open, open, open, reopen, reopen, reopen, setDisableFakeNorms, setNorm, setNorm, setTermInfosIndexDivisor, termPositions, undeleteAll, unlock`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### InstantiatedIndexReader

          public InstantiatedIndexReader(InstantiatedIndex index)

  - ### Method Detail

    - #### isOptimized

          public boolean isOptimized()

      Overrides:
        `isOptimized` in class `org.apache.lucene.index.IndexReader`
      Returns:
        always true.

    - #### getVersion

          public long getVersion()

      An InstantiatedIndexReader is not a snapshot in time, it is completely in sync with the latest commit to the store!
      Overrides:
        `getVersion` in class `org.apache.lucene.index.IndexReader`
      Returns:
        output from `InstantiatedIndex.getVersion()` in associated instantiated index.

    - #### directory

          public org.apache.lucene.store.Directory directory()

      Overrides:
        `directory` in class `org.apache.lucene.index.IndexReader`

    - #### isCurrent

          public boolean isCurrent()
                            throws java.io.IOException

      An InstantiatedIndexReader is always current! Check whether this IndexReader is still using the current (i.e., most recently committed) version of the index. If a writer has committed any changes to the index since this reader was opened, this will return `false`, in which case you must open a new IndexReader in order to see the changes. See the description of the `autoCommit` flag which controls when the `IndexWriter` actually commits changes to the index.
      Overrides:
        `isCurrent` in class `org.apache.lucene.index.IndexReader`
      Returns:
        always true
      Throws:
        `org.apache.lucene.index.CorruptIndexException` - if the index is corrupt
        `java.io.IOException` - if there is a low-level IO error
        `java.lang.UnsupportedOperationException` - unless overridden in subclass

    - #### getIndex

          public InstantiatedIndex getIndex()

    - #### numDocs

          public int numDocs()

      Specified by:
        `numDocs` in class `org.apache.lucene.index.IndexReader`

    - #### maxDoc

          public int maxDoc()

      Specified by:
        `maxDoc` in class `org.apache.lucene.index.IndexReader`

    - #### hasDeletions

          public boolean hasDeletions()

      Specified by:
        `hasDeletions` in class `org.apache.lucene.index.IndexReader`

    - #### isDeleted

          public boolean isDeleted(int n)

      Specified by:
        `isDeleted` in class `org.apache.lucene.index.IndexReader`

    - #### doDelete

          protected void doDelete(int docNum)
                           throws java.io.IOException

      Specified by:
        `doDelete` in class `org.apache.lucene.index.IndexReader`
      Throws:
        `java.io.IOException`

    - #### doUndeleteAll

          protected void doUndeleteAll()
                                throws java.io.IOException

      Specified by:
        `doUndeleteAll` in class `org.apache.lucene.index.IndexReader`
      Throws:
        `java.io.IOException`

    - #### doCommit

          protected void doCommit()
                           throws java.io.IOException

      Specified by:
        `doCommit` in class `org.apache.lucene.index.IndexReader`
      Throws:
        `java.io.IOException`

    - #### doClose

          protected void doClose()
                          throws java.io.IOException

      Specified by:
        `doClose` in class `org.apache.lucene.index.IndexReader`
      Throws:
        `java.io.IOException`

    - #### getFieldNames

          public java.util.Collection getFieldNames(org.apache.lucene.index.IndexReader.FieldOption fieldOption)

      Specified by:
        `getFieldNames` in class `org.apache.lucene.index.IndexReader`

    - #### document

          public org.apache.lucene.document.Document document(int n,
                                                              org.apache.lucene.document.FieldSelector fieldSelector)
                                                       throws org.apache.lucene.index.CorruptIndexException,
                                                              java.io.IOException

      Return the `Document` at the `n`th position.

      Warning! The resulting document is the actual stored document instance and not a deserialized clone as retuned by an IndexReader over a `Directory`. I.e., if you need to touch the document, clone it first!

      This can also be seen as a feature for live changes of stored values, but be careful! Adding a field with an name unknown to the index or to a field with previously no stored values will make `getFieldNames(org.apache.lucene.index.IndexReader.FieldOption)` out of sync, causing problems for instance when merging the instantiated index to another index.

      This implementation ignores the field selector! All stored fields are always returned!

      Specified by:
        `document` in class `org.apache.lucene.index.IndexReader`
      Parameters:
        `n` - document number
        `fieldSelector` - ignored
      Returns:
        The stored fields of the `Document` at the nth position
      Throws:
        `org.apache.lucene.index.CorruptIndexException` - if the index is corrupt
        `java.io.IOException` - if there is a low-level IO error
      See Also:
        `Fieldable`, `FieldSelector`, `SetBasedFieldSelector`, `LoadFirstFieldSelector`

    - #### document

          public org.apache.lucene.document.Document document(int n)
                                                       throws java.io.IOException

      Returns the stored fields of the `n`th `Document` in this index.

      Warning! The resulting document is the actual stored document instance and not a deserialized clone as retuned by an IndexReader over a `Directory`. I.e., if you need to touch the document, clone it first!

      This can also be seen as a feature for live changes of stored values, but be careful! Adding a field with an name unknown to the index or to a field with previously no stored values will make `getFieldNames(org.apache.lucene.index.IndexReader.FieldOption)` out of sync, causing problems for instance when merging the instantiated index to another index.

      Overrides:
        `document` in class `org.apache.lucene.index.IndexReader`
      Throws:
        `org.apache.lucene.index.CorruptIndexException` - if the index is corrupt
        `java.io.IOException` - if there is a low-level IO error

    - #### norms

          public byte[] norms(java.lang.String field)
                       throws java.io.IOException

      never ever touch these values. it is the true values, unless norms have been touched.
      Specified by:
        `norms` in class `org.apache.lucene.index.IndexReader`
      Throws:
        `java.io.IOException`

    - #### norms

          public void norms(java.lang.String field,
                            byte[] bytes,
                            int offset)
                     throws java.io.IOException

      Specified by:
        `norms` in class `org.apache.lucene.index.IndexReader`
      Throws:
        `java.io.IOException`

    - #### doSetNorm

          protected void doSetNorm(int doc,
                                   java.lang.String field,
                                   byte value)
                            throws java.io.IOException

      Specified by:
        `doSetNorm` in class `org.apache.lucene.index.IndexReader`
      Throws:
        `java.io.IOException`

    - #### docFreq

          public int docFreq(org.apache.lucene.index.Term t)
                      throws java.io.IOException

      Specified by:
        `docFreq` in class `org.apache.lucene.index.IndexReader`
      Throws:
        `java.io.IOException`

    - #### terms

          public org.apache.lucene.index.TermEnum terms()
                                                 throws java.io.IOException

      Specified by:
        `terms` in class `org.apache.lucene.index.IndexReader`
      Throws:
        `java.io.IOException`

    - #### terms

          public org.apache.lucene.index.TermEnum terms(org.apache.lucene.index.Term t)
                                                 throws java.io.IOException

      Specified by:
        `terms` in class `org.apache.lucene.index.IndexReader`
      Throws:
        `java.io.IOException`

    - #### termDocs

          public org.apache.lucene.index.TermDocs termDocs()
                                                    throws java.io.IOException

      Specified by:
        `termDocs` in class `org.apache.lucene.index.IndexReader`
      Throws:
        `java.io.IOException`

    - #### termDocs

          public org.apache.lucene.index.TermDocs termDocs(org.apache.lucene.index.Term term)
                                                    throws java.io.IOException

      Overrides:
        `termDocs` in class `org.apache.lucene.index.IndexReader`
      Throws:
        `java.io.IOException`

    - #### termPositions

          public org.apache.lucene.index.TermPositions termPositions()
                                                              throws java.io.IOException

      Specified by:
        `termPositions` in class `org.apache.lucene.index.IndexReader`
      Throws:
        `java.io.IOException`

    - #### getTermFreqVectors

          public org.apache.lucene.index.TermFreqVector[] getTermFreqVectors(int docNumber)
                                                                      throws java.io.IOException

      Specified by:
        `getTermFreqVectors` in class `org.apache.lucene.index.IndexReader`
      Throws:
        `java.io.IOException`

    - #### getTermFreqVector

          public org.apache.lucene.index.TermFreqVector getTermFreqVector(int docNumber,
                                                                          java.lang.String field)
                                                                   throws java.io.IOException

      Specified by:
        `getTermFreqVector` in class `org.apache.lucene.index.IndexReader`
      Throws:
        `java.io.IOException`

    - #### getTermFreqVector

          public void getTermFreqVector(int docNumber,
                                        java.lang.String field,
                                        org.apache.lucene.index.TermVectorMapper mapper)
                                 throws java.io.IOException

      Specified by:
        `getTermFreqVector` in class `org.apache.lucene.index.IndexReader`
      Throws:
        `java.io.IOException`

    - #### getTermFreqVector

          public void getTermFreqVector(int docNumber,
                                        org.apache.lucene.index.TermVectorMapper mapper)
                                 throws java.io.IOException

      Specified by:
        `getTermFreqVector` in class `org.apache.lucene.index.IndexReader`
      Throws:
        `java.io.IOException`

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.