Vitaly Funstein created LUCENE-5912:
---------------------------------------

             Summary: Non-NRT directory readers don't reuse segments maintained 
IndexWriter's segment reader pool
                 Key: LUCENE-5912
                 URL: https://issues.apache.org/jira/browse/LUCENE-5912
             Project: Lucene - Core
          Issue Type: Improvement
          Components: core/index
    Affects Versions: 4.6.1
            Reporter: Vitaly Funstein


Currently, if you attempt to open a reader into an index at a specific commit 
point, it will always behave as though it's opening a completely new index - 
even if one were to use the {{DirectoryReader.openIfChanged(DirectoryReader, 
IndexCommit)}} API, and pass in an NRT reader instance. What should ideally 
happen here is that the SegmentReader pool managed by IndexWriter linked to the 
NRT reader gets reused for the commit point open as much as possible, to avoid 
wasting heap space.

The problem becomes evident when looking at the code in DirectoryReader:

{code}
protected DirectoryReader doOpenIfChanged(final IndexCommit commit) throws 
IOException {
    ensureOpen();

    // If we were obtained by writer.getReader(), re-ask the
    // writer to get a new reader.
    if (writer != null) {
      return doOpenFromWriter(commit);
    } else {
      return doOpenNoWriter(commit);
    }
  }

  private DirectoryReader doOpenFromWriter(IndexCommit commit) throws 
IOException {
    if (commit != null) {
      return doOpenFromCommit(commit);
    }
......
{code}

Looks like the fact that a commit point is being re-opened trumps the presence 
of the associated IndexWriter.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to