IndexReader.getVersion()

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

IndexReader.getVersion()

Radomir Mladenovic
Hello,

Am I missing an obvious way to return version of already opened index?

Static method IndexReader.getCurrentVersion() uses SegmentInfos to
read version number from "segments" files. This returns current
version of index in Directory but I need a reliable way to obtain
version of IndexReader.

This can be solved using some locking in higher level API. However,
all what's actually needed is a simple method addition to IndexReader:

  /**
   * Version number when this IndexReader was opened.
   */
  public long getVersion() {
    return segmentInfos.getVersion();
  }

that just passes version from segmentInfos instance used by
IndexReader. Is there a commiter willing to make such change please?

BTW, SigmentInfos.readCurrentVersion() reads ''segments" without
locking (COMMIT_LOCK). Is there a good reason or just an omission?

Best regards,
Radomir

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]