Module org.elasticsearch.server
Class FetchPhaseResponseChunk
java.lang.Object
org.elasticsearch.search.fetch.chunk.FetchPhaseResponseChunk
- All Implemented Interfaces:
Closeable,AutoCloseable,Writeable,Releasable
A single chunk of fetch results streamed from a data node to the coordinator.
Contains sequence information to maintain correct ordering when chunks arrive out of order.
Supports zero-copy transport by separating header metadata from serialized hits.
The header is created after hits are serialized (since we don't know hit count until
the buffer is full), then combined using CompositeBytesReference to avoid copying.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface for sending chunk responses from the data node to the coordinator.Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V> -
Constructor Summary
ConstructorsConstructorDescriptionDeserializes from stream (receiving side).FetchPhaseResponseChunk(ShardId shardId, BytesReference serializedHits, int hitCount, int expectedTotalDocs, long sequenceStart) Creates a chunk with pre-serialized hits. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intlongint[]getHits()inthitCount()longshardId()toReleasableBytesReference(long coordinatingTaskId) voidwriteTo(StreamOutput out) Write this into the StreamOutput.
-
Constructor Details
-
FetchPhaseResponseChunk
public FetchPhaseResponseChunk(ShardId shardId, BytesReference serializedHits, int hitCount, int expectedTotalDocs, long sequenceStart) Creates a chunk with pre-serialized hits. Takes ownership of serializedHits - caller must not release it.- Parameters:
shardId- source shardserializedHits- pre-serialized hit byteshitCount- number of hits in the serialized bytesexpectedTotalDocs- total number of documents requested for this shard fetch operation across all chunks (derived from requested doc IDs, not an observed count of docs received so far)sequenceStart- sequence number of first hit for ordering
-
FetchPhaseResponseChunk
Deserializes from stream (receiving side).- Throws:
IOException
-
-
Method Details
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
toReleasableBytesReference
public ReleasableBytesReference toReleasableBytesReference(long coordinatingTaskId) throws IOException - Throws:
IOException
-
getBytesLength
public long getBytesLength() -
getHits
- Throws:
IOException
-
getHitPositions
public int[] getHitPositions() -
shardId
-
hitCount
public int hitCount() -
expectedTotalDocs
public int expectedTotalDocs() -
sequenceStart
public long sequenceStart() -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceReleasable
-