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)
  • Field Details

    • context

      private final IOContext.Context context
      The field for the context record component.
    • mergeInfo

      private final MergeInfo mergeInfo
      The field for the mergeInfo record component.
    • flushInfo

      private final FlushInfo flushInfo
      The field for the flushInfo record component.
    • readAdvice

      private final ReadAdvice readAdvice
      The field for the readAdvice record component.
    • 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.

    • READADVICE_TO_IOCONTEXT

      private static final IOContext[] READADVICE_TO_IOCONTEXT
  • Constructor Details

  • 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 IndexInputs open for searching to use arbitrary ReadAdvices.
    • 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