IOContext (Lucene 10.5.0 core API)
Description: declaration: package: org.apache.lucene.store, interface: IOContext

Package org.apache.lucene.store

# Interface IOContext

public interface IOContext
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)`

Implementations of IOContext are immutable and thread-safe.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static enum`
  `IOContext.Context`
  Context is an enumerator which specifies the context in which the Directory is being used.
  `static interface`
  `IOContext.FileOpenHint`
  Implemented by classes that can specify hints on how the file will be used

- ## 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`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `IOContext.Context`
  `context()`
  The `IOContext.Context` this context is for
  `static IOContext`
  `flush(FlushInfo flushInfo)`
  Returns an `IOContext` for flushing with the specified `FlushInfo`
  `FlushInfo`
  `flushInfo()`
  Flush info, if `context()` is `IOContext.Context.FLUSH`
  `Set<IOContext.FileOpenHint>`
  `hints()`
  Any hints on how the file will be opened
  `default <T extends IOContext.FileOpenHint>
  Stream<T>`
  `hints(Class<T> cls)`
  Finds all hints of type `cls`
  `static IOContext`
  `merge(MergeInfo mergeInfo)`
  Returns an `IOContext` for merging with the specified `MergeInfo`
  `MergeInfo`
  `mergeInfo()`
  Merge info, if `context()` is `IOContext.Context.MERGE`
  `IOContext`
  `withHints(IOContext.FileOpenHint... hints)`
  Returns an IOContext with the given hints, if it makes sense to do so for this specific context.

- ## Field Details

  - ### DEFAULT

    static final IOContext DEFAULT
    A default context for normal reads/writes. Use `withHints(org.apache.lucene.store.IOContext.FileOpenHint...)` to specify additional information on how the file is to be used.

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

  - ### READONCE

    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.

- ## Method Details

  - ### merge

    static IOContext merge(MergeInfo mergeInfo)
    Returns an `IOContext` for merging with the specified `MergeInfo`

  - ### flush

    static IOContext flush(FlushInfo flushInfo)
    Returns an `IOContext` for flushing with the specified `FlushInfo`

  - ### context

    IOContext.Context context()
    The `IOContext.Context` this context is for

  - ### mergeInfo

    MergeInfo mergeInfo()
    Merge info, if `context()` is `IOContext.Context.MERGE`

  - ### flushInfo

    FlushInfo flushInfo()
    Flush info, if `context()` is `IOContext.Context.FLUSH`

  - ### hints

    Set<IOContext.FileOpenHint> hints()
    Any hints on how the file will be opened

  - ### hints

    default <T extends IOContext.FileOpenHint> Stream<T> hints(Class<T> cls)
    Finds all hints of type `cls`

  - ### withHints

    IOContext withHints(IOContext.FileOpenHint... hints)
    Returns an IOContext with the given hints, if it makes sense to do so for this specific context. Otherwise, returns this context.

    The returned context has the same `context()`, `mergeInfo()`, and `flushInfo()` as this context.

    This instance is immutable and unaffected by this method call.