java.lang.Object
org.elasticsearch.index.engine.SearchBasedChangesSnapshot
org.elasticsearch.index.engine.LuceneChangesSnapshot
- All Implemented Interfaces:
Closeable,AutoCloseable,Translog.Snapshot
A
Translog.Snapshot from changes in a Lucene index-
Field Summary
Fields inherited from class org.elasticsearch.index.engine.SearchBasedChangesSnapshot
DEFAULT_BATCH_SIZE, fromSeqNo, requiredFullRange, searchBatchSize, toSeqNoFields inherited from interface org.elasticsearch.index.translog.Translog.Snapshot
EMPTY -
Constructor Summary
ConstructorsConstructorDescriptionLuceneChangesSnapshot(MapperService mapperService, Engine.Searcher engineSearcher, int searchBatchSize, long fromSeqNo, long toSeqNo, boolean requiredFullRange, boolean singleConsumer, boolean accessStats, IndexVersion indexVersionCreated) Creates a new "translog" snapshot from Lucene for reading operations whose seq# in the specified range. -
Method Summary
Modifier and TypeMethodDescriptionprotected SourceaddSyntheticFields(Source source, int segmentDocID) Creates a newSourceobject by combining the providedoriginalSourcewith additional synthetic fields.voidclose()protected Translog.OperationAbstract method for retrieving the next operation.protected voidsetNextSyntheticFieldsReader(org.apache.lucene.index.LeafReaderContext context) Sets the reader context to enable reading synthetic fields that were removed from the_source.intThe number of operations have been skipped (overridden or trimmed) in the snapshot so far.intThe total estimated number of operations in the snapshot.Methods inherited from class org.elasticsearch.index.engine.SearchBasedChangesSnapshot
assertDocSoftDeleted, leaves, next, nextTopDocs
-
Constructor Details
-
LuceneChangesSnapshot
public LuceneChangesSnapshot(MapperService mapperService, Engine.Searcher engineSearcher, int searchBatchSize, long fromSeqNo, long toSeqNo, boolean requiredFullRange, boolean singleConsumer, boolean accessStats, IndexVersion indexVersionCreated) throws IOException Creates a new "translog" snapshot from Lucene for reading operations whose seq# in the specified range.- Parameters:
mapperService- the mapper service for this indexengineSearcher- the internal engine searcher which will be taken over if the snapshot is opened successfullysearchBatchSize- the number of documents should be returned by each searchfromSeqNo- the min requesting seq# - inclusivetoSeqNo- the maximum requesting seq# - inclusiverequiredFullRange- if true, the snapshot will strictly check for the existence of operations between fromSeqNo and toSeqNosingleConsumer- true if the snapshot is accessed by a single thread that creates the snapshotaccessStats- true if the stats of the snapshot can be accessed viatotalOperations()indexVersionCreated- the version on which this index was created- Throws:
IOException
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classSearchBasedChangesSnapshot- Throws:
IOException
-
totalOperations
public int totalOperations()Description copied from interface:Translog.SnapshotThe total estimated number of operations in the snapshot.- Specified by:
totalOperationsin interfaceTranslog.Snapshot- Overrides:
totalOperationsin classSearchBasedChangesSnapshot
-
skippedOperations
public int skippedOperations()Description copied from interface:Translog.SnapshotThe number of operations have been skipped (overridden or trimmed) in the snapshot so far. UnlikeTranslog.Snapshot.totalOperations(), this value is updated each time afterTranslog.Snapshot.next()) is called. -
nextOperation
Description copied from class:SearchBasedChangesSnapshotAbstract method for retrieving the next operation. Should be implemented by subclasses.- Specified by:
nextOperationin classSearchBasedChangesSnapshot- Returns:
- The next Translog.Operation in the snapshot.
- Throws:
IOException- If an I/O error occurs.
-
setNextSyntheticFieldsReader
protected void setNextSyntheticFieldsReader(org.apache.lucene.index.LeafReaderContext context) throws IOException Description copied from class:SearchBasedChangesSnapshotSets the reader context to enable reading synthetic fields that were removed from the_source. This method sets up thesourceMetadataFetcherwith the providedLeafReaderContext, ensuring it is ready to fetch metadata for subsequent operations.Note: This method should be called before
SearchBasedChangesSnapshot.addSyntheticFields(Source, int)at the start of every leaf to ensure the metadata fetcher is properly initialized.- Overrides:
setNextSyntheticFieldsReaderin classSearchBasedChangesSnapshot- Throws:
IOException
-
addSyntheticFields
Description copied from class:SearchBasedChangesSnapshotCreates a newSourceobject by combining the providedoriginalSourcewith additional synthetic fields. If thesourceMetadataFetcheris null or no metadata fields are fetched, the original source is returned unchanged.- Overrides:
addSyntheticFieldsin classSearchBasedChangesSnapshot- Parameters:
source- the original sourcesegmentDocID- the document ID used to fetch metadata fields- Returns:
- a new
Sourceinstance containing the original data and additional metadata, or the original source if no metadata is added - Throws:
IOException- if an error occurs while fetching synthetic values
-