Class ReaderContext
java.lang.Object
org.elasticsearch.search.internal.ReaderContext
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,Releasable
- Direct Known Subclasses:
LegacyReaderContext
public class ReaderContext extends java.lang.Object implements 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
Fields Modifier and Type Field Description protected Engine.SearcherSuppliersearcherSupplier -
Constructor Summary
Constructors Constructor Description ReaderContext(ShardSearchContextId id, IndexService indexService, IndexShard indexShard, Engine.SearcherSupplier searcherSupplier, long keepAliveInMillis, boolean singleSession) -
Method Summary
Modifier and Type Method Description Engine.SearcheracquireSearcher(java.lang.String source)voidaddOnClose(Releasable releasable)voidclose()AggregatedDfsgetAggregatedDfs(AggregatedDfs other)<T> TgetFromContext(java.lang.String key)Returns the object ornullif the given key does not have a value in the contextRescoreDocIdsgetRescoreDocIds(RescoreDocIds other)ShardSearchRequestgetShardSearchRequest(ShardSearchRequest other)longgetStartTimeInNano()ShardSearchContextIdid()IndexServiceindexService()IndexShardindexShard()booleanisExpired()ReleasablemarkAsUsed(long keepAliveInMillis)Returns a releasable to indicate that the caller has stopped using this reader.voidputInContext(java.lang.String key, java.lang.Object value)Puts the object into the contextScrollContextscrollContext()voidsetAggregatedDfs(AggregatedDfs aggregatedDfs)voidsetRescoreDocIds(RescoreDocIds rescoreDocIds)booleansingleSession()Returnstruefor readers that are intended to use in a single query.voidvalidate(TransportRequest request)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceReleasable
-
addOnClose
-
id
-
indexService
-
indexShard
-
acquireSearcher
-
markAsUsed
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()Returnstruefor 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(java.lang.String key)Returns the object ornullif the given key does not have a value in the context -
putInContext
public void putInContext(java.lang.String key, java.lang.Object value)Puts the object into the context -
getStartTimeInNano
public long getStartTimeInNano()
-