Class ReaderContext
org.elasticsearch.search.internal.ReaderContext
- All Implemented Interfaces:
,
,
org.elasticsearch.core.Releasable
- Direct Known Subclasses:
LegacyReaderContext
public class ReaderContext
extends
implements org.elasticsearch.core.Releasable
Holds a reference to a point in time
Engine.Searcher
that will be used to construct SearchContext
.
This class also implements RefCounted
since in some situations like
in SearchService
a SearchContext can be closed concurrently due to independent events
ie. when an index gets removed. To prevent accessing closed IndexReader / IndexSearcher instances the SearchContext
can be guarded by a reference count and fail if it's been closed by an external event.-
Field Summary
-
Constructor Summary
ConstructorDescriptionReaderContext(ShardSearchContextId id, IndexService indexService, IndexShard indexShard, Engine.SearcherSupplier searcherSupplier, long keepAliveInMillis, boolean singleSession)
-
Method Summary
Modifier and TypeMethodDescriptionsource)
void
addOnClose(org.elasticsearch.core.Releasable releasable)
void
close()
getAggregatedDfs(AggregatedDfs other)
<T> T
key)
Returns the object ornull
if the given key does not have a value in the contextgetRescoreDocIds(RescoreDocIds other)
long
id()
boolean
org.elasticsearch.core.Releasable
markAsUsed(long keepAliveInMillis)
Returns a releasable to indicate that the caller has stopped using this reader.void
key, value)
Puts the object into the contextvoid
setAggregatedDfs(AggregatedDfs aggregatedDfs)
void
setRescoreDocIds(RescoreDocIds rescoreDocIds)
boolean
Returnstrue
for readers that are intended to use in a single query.void
validate(TransportRequest request)
Methods inherited from class java.lang.
, , , , , , , , , ,
-
Field Details
-
searcherSupplier
-
-
Constructor Details
-
ReaderContext
public ReaderContext(ShardSearchContextId id, IndexService indexService, IndexShard indexShard, Engine.SearcherSupplier searcherSupplier, long keepAliveInMillis, boolean singleSession)
-
-
Method Details
-
validate
-
close
public final void close()- Specified by:
in interface
- Specified by:
in interface
- Specified by:
close
in interfaceorg.elasticsearch.core.Releasable
-
addOnClose
public void addOnClose(org.elasticsearch.core.Releasable releasable) -
id
-
indexService
-
indexShard
-
acquireSearcher
public source) -
markAsUsed
public org.elasticsearch.core.Releasable markAsUsed(long keepAliveInMillis)Returns a releasable to indicate that the caller has stopped using this reader. The time to live of the reader after usage can be extended using the providedkeepAliveInMillis
. -
isExpired
public boolean isExpired() -
getShardSearchRequest
-
scrollContext
-
getAggregatedDfs
-
setAggregatedDfs
-
getRescoreDocIds
-
setRescoreDocIds
-
singleSession
public boolean singleSession()Returnstrue
for readers that are intended to use in a single query. For readers that are intended to use in multiple queries (i.e., scroll or readers), we should not release them after the fetch phase or the query phase with empty results. -
getFromContext
public <T> T getFromContext( key)Returns the object ornull
if the given key does not have a value in the context -
putInContext
public void putInContext( key, value)Puts the object into the context -
getStartTimeInNano
public long getStartTimeInNano()
-