Interface ChunkedToXContent
- All Known Subinterfaces:
ChunkedToXContentObject,ClusterState.Custom,InferenceServiceResults,Metadata.Custom
- All Known Implementing Classes:
AbstractAllocationDecision,AllocateUnassignedDecision,BaseNodesXContentResponse,BulkResponse,ChunkedBroadcastResponse,ClusterAllocationExplainResponse,ClusterAllocationExplanation,ClusterFeatures,ClusterInfo,ClusterRerouteResponse,ClusterState,ComponentTemplateMetadata,ComposableIndexTemplateMetadata,DataStreamMetadata,DesiredBalanceResponse,DesiredBalanceResponse.DesiredShards,DesiredNodesMetadata,Diagnosis,Diagnosis.Resource,ElasticsearchNodeCommand.UnknownMetadataCustom,ExplainDataStreamLifecycleAction.Response,FieldCapabilitiesResponse,FieldUsageStatsResponse,GetDataStreamLifecycleAction.Response,GetHealthAction.Response,GetIndexResponse,GetMappingsResponse,GetSettingsResponse,GetSnapshotsResponse,HealthIndicatorResult,HealthMetadata,HttpStats,IndexGraveyard,IndicesSegmentResponse,IndicesShardStoresResponse,IndicesStatsResponse,IngestMetadata,IngestStats,Metadata,MoveDecision,MultiSearchResponse,MultiSearchResponse.Item,NodeIndicesStats,NodesShutdownMetadata,NodesStatsResponse,NodeStats,PendingClusterTasksResponse,PersistentTasksCustomMetadata,RecoveryResponse,RegisteredPolicySnapshots,RepositoriesMetadata,RepositoryCleanupInProgress,RestoreInProgress,ScriptMetadata,ScriptStats,SearchHits,SearchResponse,ShardAllocationDecision,ShutdownShardMigrationStatus,SnapshotDeletionsInProgress,SnapshotsInProgress,SnapshotsStatusResponse,SnapshotStatus,ThreadPoolStats,ThreadPoolStats.Stats,TransportStats
ToXContent allowing for progressive serialization by creating an Iterator of ToXContent chunks.
The REST layer only serializes enough chunks at once to keep an outbound buffer full, rather than consuming all the time and memory
needed to serialize the entire response as must be done with the regular ToXContent responses.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ChunkedToXContentAChunkedToXContentthat yields no chunks -
Method Summary
Modifier and TypeMethodDescriptiondefault booleandefault Iterator<? extends ToXContent> toXContentChunked(RestApiVersion restApiVersion, ToXContent.Params params) Create an iterator ofToXContentchunks for a REST response for the givenRestApiVersion.Iterator<? extends ToXContent> toXContentChunked(ToXContent.Params params) Create an iterator ofToXContentchunks for a REST response.default Iterator<? extends ToXContent> toXContentChunkedV8(ToXContent.Params params) Create an iterator ofToXContentchunks for a response to theRestApiVersion.V_8API.static ToXContentwrapAsToXContent(ChunkedToXContent chunkedToXContent) Wraps the given instance in aToXContentthat will fully serialize the instance when serialized.
-
Field Details
-
EMPTY
AChunkedToXContentthat yields no chunks
-
-
Method Details
-
toXContentChunked
default Iterator<? extends ToXContent> toXContentChunked(RestApiVersion restApiVersion, ToXContent.Params params) Create an iterator ofToXContentchunks for a REST response for the givenRestApiVersion. Each chunk is serialized with the sameXContentBuilderandToXContent.Params, which is also the same as theToXContent.Paramspassed as theparamsargument. For best results, all chunks should beO(1)size. The last chunk in the iterator must always yield at least one byte of output. See alsoChunkedToXContentHelperfor some handy utilities.Note that chunked response bodies cannot send deprecation warning headers once transmission has started, so implementations must check for deprecated feature use before returning.
By default, delegates to
toXContentChunked(org.elasticsearch.core.RestApiVersion, org.elasticsearch.xcontent.ToXContent.Params)or {#toXContentChunkedV8}.- Returns:
- iterator over chunks of
ToXContent
-
toXContentChunked
Create an iterator ofToXContentchunks for a REST response. Each chunk is serialized with the sameXContentBuilderandToXContent.Params, which is also the same as theToXContent.Paramspassed as theparamsargument. For best results, all chunks should beO(1)size. The last chunk in the iterator must always yield at least one byte of output. See alsoChunkedToXContentHelperfor some handy utilities.Note that chunked response bodies cannot send deprecation warning headers once transmission has started, so implementations must check for deprecated feature use before returning.
- Returns:
- iterator over chunks of
ToXContent
-
toXContentChunkedV8
Create an iterator ofToXContentchunks for a response to theRestApiVersion.V_8API. Each chunk is serialized with the sameXContentBuilderandToXContent.Params, which is also the same as theToXContent.Paramspassed as theparamsargument. For best results, all chunks should beO(1)size. The last chunk in the iterator must always yield at least one byte of output. See alsoChunkedToXContentHelperfor some handy utilities.Similar to
toXContentChunked(org.elasticsearch.core.RestApiVersion, org.elasticsearch.xcontent.ToXContent.Params)but for theRestApiVersion.V_8API. By default this method delegates totoXContentChunked(org.elasticsearch.core.RestApiVersion, org.elasticsearch.xcontent.ToXContent.Params).Note that chunked response bodies cannot send deprecation warning headers once transmission has started, so implementations must check for deprecated feature use before returning.
- Returns:
- iterator over chunks of
ToXContent
-
wrapAsToXContent
Wraps the given instance in aToXContentthat will fully serialize the instance when serialized.- Parameters:
chunkedToXContent- instance to wrap- Returns:
- x-content instance
-
isFragment
default boolean isFragment()- Returns:
- true iff this instance serializes as a fragment. See
ToXContentObjectfor additional details.
-