Package org.apache.lucene.store

# Record Class IOContext

java.lang.Object
java.lang.Record
org.apache.lucene.store.IOContext

Record Components:
  `context` - An object of a enumerator Context type
  `mergeInfo` - must be given when `context == MERGE`
  `flushInfo` - must be given when `context == FLUSH`
  `readAdvice` - Advice regarding the read access pattern

public record IOContext(IOContext.Context context, MergeInfo mergeInfo, FlushInfo flushInfo, ReadAdvice readAdvice) extends Record
IOContext holds additional details on the merge/search context. An IOContext object can never be passed as a `null` parameter to either `Directory.openInput(String, IOContext)` or `Directory.createOutput(String, IOContext)`

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `IOContext.Context`
  Context is a enumerator which specifies the context in which the Directory is being used for.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final IOContext`
  `DEFAULT`
  A default context for normal reads/writes.
  `static final IOContext`
  `READONCE`
  A default context for reads with `ReadAdvice.SEQUENTIAL`.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `IOContext(FlushInfo flushInfo)`
  Creates an `IOContext` for flushing.
  `IOContext(IOContext.Context context, MergeInfo mergeInfo, FlushInfo flushInfo, ReadAdvice readAdvice)`
  Creates an instance of a `IOContext` record class.
  `IOContext(MergeInfo mergeInfo)`
  Creates an `IOContext` for merging.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `IOContext.Context`
  `context()`
  Returns the value of the `context` record component.
  `final boolean`
  `equals(Object o)`
  Indicates whether some other object is "equal to" this one.
  `FlushInfo`
  `flushInfo()`
  Returns the value of the `flushInfo` record component.
  `final int`
  `hashCode()`
  Returns a hash code value for this object.
  `MergeInfo`
  `mergeInfo()`
  Returns the value of the `mergeInfo` record component.
  `ReadAdvice`
  `readAdvice()`
  Returns the value of the `readAdvice` record component.
  `final String`
  `toString()`
  Returns a string representation of this record class.
  `IOContext`
  `withReadAdvice(ReadAdvice advice)`
  Return an updated `IOContext` that has the provided `ReadAdvice` if the `IOContext.Context` is a `IOContext.Context.DEFAULT` context, otherwise return this existing instance.

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

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### DEFAULT

    public static final IOContext DEFAULT
    A default context for normal reads/writes. Use `withReadAdvice(ReadAdvice)` to specify another `ReadAdvice`.

    It will use `ReadAdvice.RANDOM` by default, unless set by system property `org.apache.lucene.store.defaultReadAdvice`.

  - ### READONCE

    public static final IOContext READONCE
    A default context for reads with `ReadAdvice.SEQUENTIAL`.

    This context should only be used when the read operations will be performed in the same thread as the thread that opens the underlying storage.

- ## Constructor Details

  - ### IOContext

    public IOContext(IOContext.Context context, MergeInfo mergeInfo, FlushInfo flushInfo, ReadAdvice readAdvice)
    Creates an instance of a `IOContext` record class.
    Parameters:
      `context` - the value for the `context` record component
      `mergeInfo` - the value for the `mergeInfo` record component
      `flushInfo` - the value for the `flushInfo` record component
      `readAdvice` - the value for the `readAdvice` record component

  - ### IOContext

    public IOContext(FlushInfo flushInfo)
    Creates an `IOContext` for flushing.

  - ### IOContext

    public IOContext(MergeInfo mergeInfo)
    Creates an `IOContext` for merging.

- ## Method Details

  - ### withReadAdvice

    public IOContext withReadAdvice(ReadAdvice advice)
    Return an updated `IOContext` that has the provided `ReadAdvice` if the `IOContext.Context` is a `IOContext.Context.DEFAULT` context, otherwise return this existing instance. This helps preserve a `ReadAdvice.SEQUENTIAL` advice for merging, which is always the right choice, while allowing `IndexInput`s open for searching to use arbitrary `ReadAdvice`s.

  - ### toString

    public final String toString()
    Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
    Specified by:
      `toString` in class `Record`
    Returns:
      a string representation of this object

  - ### hashCode

    public final int hashCode()
    Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
    Specified by:
      `hashCode` in class `Record`
    Returns:
      a hash code value for this object

  - ### equals

    public final boolean equals(Object o)
    Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with `Objects::equals(Object,Object)`.
    Specified by:
      `equals` in class `Record`
    Parameters:
      `o` - the object with which to compare
    Returns:
      `true` if this object is the same as the `o` argument; `false` otherwise.

  - ### context

    public IOContext.Context context()
    Returns the value of the `context` record component.
    Returns:
      the value of the `context` record component

  - ### mergeInfo

    public MergeInfo mergeInfo()
    Returns the value of the `mergeInfo` record component.
    Returns:
      the value of the `mergeInfo` record component

  - ### flushInfo

    public FlushInfo flushInfo()
    Returns the value of the `flushInfo` record component.
    Returns:
      the value of the `flushInfo` record component

  - ### readAdvice

    public ReadAdvice readAdvice()
    Returns the value of the `readAdvice` record component.
    Returns:
      the value of the `readAdvice` record component