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 typemergeInfo- must be given whencontext == MERGEflushInfo- must be given whencontext == FLUSHreadAdvice- 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 ClassesModifier and TypeClassDescriptionstatic enumContext is a enumerator which specifies the context in which the Directory is being used for. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IOContextA default context for normal reads/writes.static final IOContextA default context for reads withReadAdvice.SEQUENTIAL. -
Constructor Summary
ConstructorsConstructorDescriptionCreates anIOContextfor flushing.IOContext(IOContext.Context context, MergeInfo mergeInfo, FlushInfo flushInfo, ReadAdvice readAdvice) Creates an instance of aIOContextrecord class.Creates anIOContextfor merging. -
Method Summary
Modifier and TypeMethodDescriptioncontext()Returns the value of thecontextrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theflushInforecord component.final inthashCode()Returns a hash code value for this object.Returns the value of themergeInforecord component.Returns the value of thereadAdvicerecord component.final StringtoString()Returns a string representation of this record class.withReadAdvice(ReadAdvice advice) Return an updatedIOContextthat has the providedReadAdviceif theIOContext.Contextis aIOContext.Context.DEFAULTcontext, otherwise return this existing instance.
-
Field Details
-
DEFAULT
A default context for normal reads/writes. UsewithReadAdvice(ReadAdvice)to specify anotherReadAdvice.It will use
ReadAdvice.RANDOMby default, unless set by system propertyorg.apache.lucene.store.defaultReadAdvice. -
READONCE
A default context for reads withReadAdvice.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 aIOContextrecord class.- Parameters:
context- the value for thecontextrecord componentmergeInfo- the value for themergeInforecord componentflushInfo- the value for theflushInforecord componentreadAdvice- the value for thereadAdvicerecord component
-
IOContext
Creates anIOContextfor flushing. -
IOContext
Creates anIOContextfor merging.
-
-
Method Details
-
withReadAdvice
Return an updatedIOContextthat has the providedReadAdviceif theIOContext.Contextis aIOContext.Context.DEFAULTcontext, otherwise return this existing instance. This helps preserve aReadAdvice.SEQUENTIALadvice for merging, which is always the right choice, while allowingIndexInputs open for searching to use arbitraryReadAdvices. -
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
context
Returns the value of thecontextrecord component.- Returns:
- the value of the
contextrecord component
-
mergeInfo
Returns the value of themergeInforecord component.- Returns:
- the value of the
mergeInforecord component
-
flushInfo
Returns the value of theflushInforecord component.- Returns:
- the value of the
flushInforecord component
-
readAdvice
Returns the value of thereadAdvicerecord component.- Returns:
- the value of the
readAdvicerecord component
-