SegmentInfos.FindSegmentsFile (Lucene 10.5.0 core API)
Description: declaration: package: org.apache.lucene.index, class: SegmentInfos, class: FindSegmentsFile

Package org.apache.lucene.index

# Class SegmentInfos.FindSegmentsFile<T>

java.lang.Object
org.apache.lucene.index.SegmentInfos.FindSegmentsFile<T>

Enclosing class:
  `SegmentInfos`

public abstract static class SegmentInfos.FindSegmentsFile<T> extends Object
Utility class for executing code that needs to do something with the current segments file. This is necessary with lock-less commits because from the time you locate the current segments file name, until you actually open it, read its contents, or check modified time, etc., it could have been deleted due to a writer commit finishing.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `FindSegmentsFile(Directory directory)`
  Sole constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected abstract T`
  `doBody(String segmentFileName)`
  Subclass must implement this.
  `T`
  `run()`
  Locate the most recent `segments` file and run `doBody(java.lang.String)` on it.
  `T`
  `run(IndexCommit commit)`
  Run `doBody(java.lang.String)` on the provided commit.

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

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

- ## Constructor Details

  - ### FindSegmentsFile

    protected FindSegmentsFile(Directory directory)
    Sole constructor.

- ## Method Details

  - ### run

    public T run() throws IOException
    Locate the most recent `segments` file and run `doBody(java.lang.String)` on it.
    Throws:
      `IOException`

  - ### run

    public T run(IndexCommit commit) throws IOException
    Run `doBody(java.lang.String)` on the provided commit.
    Throws:
      `IOException`

  - ### doBody

    protected abstract T doBody(String segmentFileName) throws IOException
    Subclass must implement this. The assumption is an IOException will be thrown if something goes wrong during the processing that could have been caused by a writer committing.
    Throws:
      `IOException`