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 == MERGE
flushInfo
- must be given whencontext == 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 ClassesModifier and TypeClassDescriptionstatic enum
Context is a enumerator which specifies the context in which the Directory is being used for. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IOContext
A default context for normal reads/writes.static final IOContext
A default context for reads withReadAdvice.SEQUENTIAL
. -
Constructor Summary
ConstructorsConstructorDescriptionCreates anIOContext
for flushing.IOContext
(IOContext.Context context, MergeInfo mergeInfo, FlushInfo flushInfo, ReadAdvice readAdvice) Creates an instance of aIOContext
record class.Creates anIOContext
for merging. -
Method Summary
Modifier and TypeMethodDescriptioncontext()
Returns the value of thecontext
record component.final boolean
Indicates whether some other object is "equal to" this one.Returns the value of theflushInfo
record component.final int
hashCode()
Returns a hash code value for this object.Returns the value of themergeInfo
record component.Returns the value of thereadAdvice
record component.final String
toString()
Returns a string representation of this record class.withReadAdvice
(ReadAdvice advice) Return an updatedIOContext
that has the providedReadAdvice
if theIOContext.Context
is aIOContext.Context.DEFAULT
context, otherwise return this existing instance.
-
Field Details
-
DEFAULT
A default context for normal reads/writes. UsewithReadAdvice(ReadAdvice)
to specify anotherReadAdvice
.It will use
ReadAdvice.RANDOM
by 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 aIOContext
record class.- Parameters:
context
- the value for thecontext
record componentmergeInfo
- the value for themergeInfo
record componentflushInfo
- the value for theflushInfo
record componentreadAdvice
- the value for thereadAdvice
record component
-
IOContext
Creates anIOContext
for flushing. -
IOContext
Creates anIOContext
for merging.
-
-
Method Details
-
withReadAdvice
Return an updatedIOContext
that has the providedReadAdvice
if theIOContext.Context
is aIOContext.Context.DEFAULT
context, otherwise return this existing instance. This helps preserve aReadAdvice.SEQUENTIAL
advice for merging, which is always the right choice, while allowingIndexInput
s open for searching to use arbitraryReadAdvice
s. -
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 thecontext
record component.- Returns:
- the value of the
context
record component
-
mergeInfo
Returns the value of themergeInfo
record component.- Returns:
- the value of the
mergeInfo
record component
-
flushInfo
Returns the value of theflushInfo
record component.- Returns:
- the value of the
flushInfo
record component
-
readAdvice
Returns the value of thereadAdvice
record component.- Returns:
- the value of the
readAdvice
record component
-