Dry up collection writing to StreamOutput (#86386)

Small weekend project around automated refactoring:
We have endless duplication here, drying up some of it.
This commit is contained in:
Armin Braun 2022-05-24 07:30:34 +02:00 committed by GitHub
parent 03388ff09e
commit 00b3721108
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
92 changed files with 184 additions and 570 deletions

View file

@ -51,10 +51,7 @@ public class GeometryCollectionBuilder extends ShapeBuilder<Shape, GeometryColle
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(shapes.size()); out.writeNamedWriteableList(shapes);
for (ShapeBuilder<?, ?, ?> shape : shapes) {
out.writeNamedWriteable(shape);
}
} }
public GeometryCollectionBuilder shape(ShapeBuilder<?, ?, ?> shape) { public GeometryCollectionBuilder shape(ShapeBuilder<?, ?, ?> shape) {

View file

@ -49,10 +49,7 @@ public class MultiLineStringBuilder extends ShapeBuilder<JtsGeometry, org.elasti
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(lines.size()); out.writeList(lines);
for (LineStringBuilder line : lines) {
line.writeTo(out);
}
} }
public MultiLineStringBuilder linestring(LineStringBuilder line) { public MultiLineStringBuilder linestring(LineStringBuilder line) {

View file

@ -63,10 +63,7 @@ public class MultiPolygonBuilder extends ShapeBuilder<Shape, MultiPolygon, Multi
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
orientation.writeTo(out); orientation.writeTo(out);
out.writeVInt(polygons.size()); out.writeList(polygons);
for (PolygonBuilder polygon : polygons) {
polygon.writeTo(out);
}
} }
public Orientation orientation() { public Orientation orientation() {

View file

@ -93,10 +93,7 @@ public class PolygonBuilder extends ShapeBuilder<JtsGeometry, org.elasticsearch.
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
shell.writeTo(out); shell.writeTo(out);
orientation.writeTo(out); orientation.writeTo(out);
out.writeVInt(holes.size()); out.writeList(holes);
for (LineStringBuilder hole : holes) {
hole.writeTo(out);
}
} }
public Orientation orientation() { public Orientation orientation() {

View file

@ -107,10 +107,7 @@ public abstract class ShapeBuilder<T extends Shape, G extends org.elasticsearch.
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(coordinates.size()); out.writeCollection(coordinates, (o, p) -> writeCoordinateTo(p, o));
for (Coordinate point : coordinates) {
writeCoordinateTo(point, out);
}
} }
protected static void writeCoordinateTo(Coordinate coordinate, StreamOutput out) throws IOException { protected static void writeCoordinateTo(Coordinate coordinate, StreamOutput out) throws IOException {

View file

@ -275,10 +275,7 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
} else { } else {
out.writeBoolean(false); out.writeBoolean(false);
} }
out.writeVInt(documents.size()); out.writeCollection(documents, StreamOutput::writeBytesReference);
for (BytesReference document : documents) {
out.writeBytesReference(document);
}
if (documents.isEmpty() == false) { if (documents.isEmpty() == false) {
XContentHelper.writeTo(out, documentXContentType); XContentHelper.writeTo(out, documentXContentType);
} }

View file

@ -88,16 +88,8 @@ public class RankEvalResponse extends ActionResponse implements ToXContentObject
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeDouble(metricScore); out.writeDouble(metricScore);
out.writeVInt(details.size()); out.writeMap(details, StreamOutput::writeString, (o, v) -> v.writeTo(o));
for (String queryId : details.keySet()) { out.writeMap(failures, StreamOutput::writeString, StreamOutput::writeException);
out.writeString(queryId);
details.get(queryId).writeTo(out);
}
out.writeVInt(failures.size());
for (String queryId : failures.keySet()) {
out.writeString(queryId);
out.writeException(failures.get(queryId));
}
} }
@Override @Override

View file

@ -96,16 +96,9 @@ public class RankEvalSpec implements Writeable, ToXContentObject {
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(ratedRequests.size()); out.writeList(ratedRequests);
for (RatedRequest spec : ratedRequests) {
spec.writeTo(out);
}
out.writeNamedWriteable(metric); out.writeNamedWriteable(metric);
out.writeVInt(templates.size()); out.writeMap(templates, StreamOutput::writeString, (o, v) -> v.writeTo(o));
for (Entry<String, Script> entry : templates.entrySet()) {
out.writeString(entry.getKey());
entry.getValue().writeTo(out);
}
out.writeVInt(maxConcurrentSearches); out.writeVInt(maxConcurrentSearches);
} }

View file

@ -646,18 +646,12 @@ public class AnalyzeAction extends ActionType<AnalyzeAction.Response> {
if (customAnalyzer) { if (customAnalyzer) {
tokenizer.writeTo(out); tokenizer.writeTo(out);
if (charfilters != null) { if (charfilters != null) {
out.writeVInt(charfilters.length); out.writeArray(charfilters);
for (CharFilteredText charfilter : charfilters) {
charfilter.writeTo(out);
}
} else { } else {
out.writeVInt(0); out.writeVInt(0);
} }
if (tokenfilters != null) { if (tokenfilters != null) {
out.writeVInt(tokenfilters.length); out.writeArray(tokenfilters);
for (AnalyzeTokenList tokenfilter : tokenfilters) {
tokenfilter.writeTo(out);
}
} else { } else {
out.writeVInt(0); out.writeVInt(0);
} }

View file

@ -465,10 +465,7 @@ public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest>
} else { } else {
out.writeString(mappings); out.writeString(mappings);
} }
out.writeVInt(aliases.size()); out.writeCollection(aliases);
for (Alias alias : aliases) {
alias.writeTo(out);
}
waitForActiveShards.writeTo(out); waitForActiveShards.writeTo(out);
if (out.getVersion().onOrAfter(Version.V_7_12_0)) { if (out.getVersion().onOrAfter(Version.V_7_12_0)) {
out.writeString(origin); out.writeString(origin);

View file

@ -120,11 +120,7 @@ public final class RolloverResponse extends ShardsAcknowledgedResponse implement
super.writeTo(out); super.writeTo(out);
out.writeString(oldIndex); out.writeString(oldIndex);
out.writeString(newIndex); out.writeString(newIndex);
out.writeVInt(conditionStatus.size()); out.writeMap(conditionStatus, StreamOutput::writeString, StreamOutput::writeBoolean);
for (Map.Entry<String, Boolean> entry : conditionStatus.entrySet()) {
out.writeString(entry.getKey());
out.writeBoolean(entry.getValue());
}
out.writeBoolean(dryRun); out.writeBoolean(dryRun);
out.writeBoolean(rolledOver); out.writeBoolean(rolledOver);
out.writeBoolean(shardsAcknowledged); out.writeBoolean(shardsAcknowledged);

View file

@ -52,10 +52,7 @@ public class IndicesShardStoresRequest extends MasterNodeReadRequest<IndicesShar
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out); super.writeTo(out);
out.writeStringArrayNullable(indices); out.writeStringArrayNullable(indices);
out.writeVInt(statuses.size()); out.writeCollection(statuses, (o, v) -> o.writeByte(v.value()));
for (ClusterHealthStatus status : statuses) {
out.writeByte(status.value());
}
indicesOptions.writeIndicesOptions(out); indicesOptions.writeIndicesOptions(out);
} }

View file

@ -269,13 +269,11 @@ public class IndicesShardStoresResponse extends ActionResponse implements ToXCon
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeMap(storeStatuses, StreamOutput::writeString, (o, v) -> { out.writeMap(
o.writeVInt(v.size()); storeStatuses,
for (Map.Entry<Integer, List<StoreStatus>> shardStatusesEntry : v.entrySet()) { StreamOutput::writeString,
o.writeInt(shardStatusesEntry.getKey()); (o, v) -> o.writeMap(v, StreamOutput::writeInt, StreamOutput::writeCollection)
o.writeCollection(shardStatusesEntry.getValue()); );
}
});
out.writeList(failures); out.writeList(failures);
} }

View file

@ -42,10 +42,7 @@ public class GetIndexTemplatesResponse extends ActionResponse implements ToXCont
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(indexTemplates.size()); out.writeCollection(indexTemplates);
for (IndexTemplateMetadata indexTemplate : indexTemplates) {
indexTemplate.writeTo(out);
}
} }
@Override @Override

View file

@ -456,10 +456,7 @@ public class PutIndexTemplateRequest extends MasterNodeRequest<PutIndexTemplateR
} else { } else {
out.writeOptionalString(mappings); out.writeOptionalString(mappings);
} }
out.writeVInt(aliases.size()); out.writeCollection(aliases);
for (Alias alias : aliases) {
alias.writeTo(out);
}
out.writeOptionalVInt(version); out.writeOptionalVInt(version);
} }
} }

View file

@ -64,10 +64,7 @@ public class GetPipelineResponse extends ActionResponse implements StatusToXCont
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(pipelines.size()); out.writeCollection(pipelines);
for (PipelineConfiguration pipeline : pipelines) {
pipeline.writeTo(out);
}
out.writeBoolean(summary); out.writeBoolean(summary);
} }

View file

@ -55,10 +55,7 @@ public final class SimulateDocumentVerboseResult implements SimulateDocumentResu
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(processorResults.size()); out.writeCollection(processorResults);
for (SimulateProcessorResult result : processorResults) {
result.writeTo(out);
}
} }
public List<SimulateProcessorResult> getProcessorResults() { public List<SimulateProcessorResult> getProcessorResults() {

View file

@ -121,10 +121,7 @@ public class SimulatePipelineResponse extends ActionResponse implements ToXConte
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalString(pipelineId); out.writeOptionalString(pipelineId);
out.writeBoolean(verbose); out.writeBoolean(verbose);
out.writeVInt(results.size()); out.writeCollection(results);
for (SimulateDocumentResult response : results) {
response.writeTo(out);
}
} }
@Override @Override

View file

@ -147,10 +147,7 @@ public class MultiSearchRequest extends ActionRequest implements CompositeIndice
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out); super.writeTo(out);
out.writeVInt(maxConcurrentSearchRequests); out.writeVInt(maxConcurrentSearchRequests);
out.writeVInt(requests.size()); out.writeCollection(requests);
for (SearchRequest request : requests) {
request.writeTo(out);
}
} }
@Override @Override

View file

@ -39,19 +39,18 @@ public final class TransportSearchHelper {
BytesStreamOutput out = new BytesStreamOutput(); BytesStreamOutput out = new BytesStreamOutput();
out.writeString(INCLUDE_CONTEXT_UUID); out.writeString(INCLUDE_CONTEXT_UUID);
out.writeString(searchPhaseResults.length() == 1 ? ParsedScrollId.QUERY_AND_FETCH_TYPE : ParsedScrollId.QUERY_THEN_FETCH_TYPE); out.writeString(searchPhaseResults.length() == 1 ? ParsedScrollId.QUERY_AND_FETCH_TYPE : ParsedScrollId.QUERY_THEN_FETCH_TYPE);
out.writeVInt(searchPhaseResults.asList().size()); out.writeCollection(searchPhaseResults.asList(), (o, searchPhaseResult) -> {
for (SearchPhaseResult searchPhaseResult : searchPhaseResults.asList()) { o.writeString(searchPhaseResult.getContextId().getSessionId());
out.writeString(searchPhaseResult.getContextId().getSessionId()); o.writeLong(searchPhaseResult.getContextId().getId());
out.writeLong(searchPhaseResult.getContextId().getId());
SearchShardTarget searchShardTarget = searchPhaseResult.getSearchShardTarget(); SearchShardTarget searchShardTarget = searchPhaseResult.getSearchShardTarget();
if (searchShardTarget.getClusterAlias() != null) { if (searchShardTarget.getClusterAlias() != null) {
out.writeString( o.writeString(
RemoteClusterAware.buildRemoteIndexName(searchShardTarget.getClusterAlias(), searchShardTarget.getNodeId()) RemoteClusterAware.buildRemoteIndexName(searchShardTarget.getClusterAlias(), searchShardTarget.getNodeId())
); );
} else { } else {
out.writeString(searchShardTarget.getNodeId()); o.writeString(searchShardTarget.getNodeId());
} }
} });
return Base64.getUrlEncoder().encodeToString(out.copyBytes().array()); return Base64.getUrlEncoder().encodeToString(out.copyBytes().array());
} catch (IOException e) { } catch (IOException e) {
throw new UncheckedIOException(e); throw new UncheckedIOException(e);

View file

@ -137,10 +137,7 @@ public class BroadcastResponse extends ActionResponse implements ToXContentObjec
out.writeVInt(totalShards); out.writeVInt(totalShards);
out.writeVInt(successfulShards); out.writeVInt(successfulShards);
out.writeVInt(failedShards); out.writeVInt(failedShards);
out.writeVInt(shardFailures.length); out.writeArray(shardFailures);
for (DefaultShardOperationFailedException exp : shardFailures) {
exp.writeTo(out);
}
} }
@Override @Override

View file

@ -671,10 +671,7 @@ public abstract class TransportBroadcastByNodeAction<
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeString(nodeId); out.writeString(nodeId);
out.writeVInt(totalShards); out.writeVInt(totalShards);
out.writeVInt(results.size()); out.writeCollection(results, StreamOutput::writeOptionalWriteable);
for (ShardOperationResult result : results) {
out.writeOptionalWriteable(result);
}
out.writeBoolean(exceptions != null); out.writeBoolean(exceptions != null);
if (exceptions != null) { if (exceptions != null) {
out.writeList(exceptions); out.writeList(exceptions);

View file

@ -135,10 +135,7 @@ public class ReplicationResponse extends ActionResponse {
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(total); out.writeVInt(total);
out.writeVInt(successful); out.writeVInt(successful);
out.writeVInt(failures.length); out.writeArray(failures);
for (Failure failure : failures) {
failure.writeTo(out);
}
} }
@Override @Override

View file

@ -61,14 +61,8 @@ public class BaseTasksResponse extends ActionResponse {
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(taskFailures.size()); out.writeCollection(taskFailures);
for (TaskOperationFailure exp : taskFailures) { out.writeCollection(nodeFailures);
exp.writeTo(out);
}
out.writeVInt(nodeFailures.size());
for (ElasticsearchException exp : nodeFailures) {
exp.writeTo(out);
}
} }
/** /**

View file

@ -393,22 +393,10 @@ public abstract class TransportTasksAction<
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeString(nodeId); out.writeString(nodeId);
out.writeVInt(results.size()); out.writeCollection(results, StreamOutput::writeOptionalWriteable);
for (TaskResponse result : results) {
if (result != null) {
out.writeBoolean(true);
result.writeTo(out);
} else {
out.writeBoolean(false);
}
}
out.writeBoolean(exceptions != null); out.writeBoolean(exceptions != null);
if (exceptions != null) { if (exceptions != null) {
int taskFailures = exceptions.size(); out.writeCollection(exceptions);
out.writeVInt(taskFailures);
for (TaskOperationFailure exception : exceptions) {
exception.writeTo(out);
}
} }
} }
} }

View file

@ -116,15 +116,11 @@ public class ClusterInfo implements ToXContentFragment, Writeable {
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(this.leastAvailableSpaceUsage.size()); out.writeMap(this.leastAvailableSpaceUsage, StreamOutput::writeString, (o, v) -> v.writeTo(o));
for (Map.Entry<String, DiskUsage> c : this.leastAvailableSpaceUsage.entrySet()) {
out.writeString(c.getKey());
c.getValue().writeTo(out);
}
out.writeMap(this.mostAvailableSpaceUsage, StreamOutput::writeString, (o, v) -> v.writeTo(o)); out.writeMap(this.mostAvailableSpaceUsage, StreamOutput::writeString, (o, v) -> v.writeTo(o));
out.writeMap(this.shardSizes, StreamOutput::writeString, (o, v) -> out.writeLong(v == null ? -1 : v)); out.writeMap(this.shardSizes, StreamOutput::writeString, (o, v) -> o.writeLong(v == null ? -1 : v));
if (out.getVersion().onOrAfter(DATA_SET_SIZE_SIZE_VERSION)) { if (out.getVersion().onOrAfter(DATA_SET_SIZE_SIZE_VERSION)) {
out.writeMap(this.shardDataSetSizes, (o, s) -> s.writeTo(o), (o, v) -> out.writeLong(v)); out.writeMap(this.shardDataSetSizes, (o, s) -> s.writeTo(o), StreamOutput::writeLong);
} }
out.writeMap(this.routingToDataPath, (o, k) -> k.writeTo(o), StreamOutput::writeString); out.writeMap(this.routingToDataPath, (o, k) -> k.writeTo(o), StreamOutput::writeString);
if (out.getVersion().onOrAfter(StoreStats.RESERVED_BYTES_VERSION)) { if (out.getVersion().onOrAfter(StoreStats.RESERVED_BYTES_VERSION)) {
@ -316,10 +312,7 @@ public class ClusterInfo implements ToXContentFragment, Writeable {
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVLong(total); out.writeVLong(total);
out.writeVInt(shardIds.size()); out.writeCollection(shardIds);
for (ShardId shardIdCursor : shardIds) {
shardIdCursor.writeTo(out);
}
} }
public long getTotal() { public long getTotal() {

View file

@ -370,14 +370,13 @@ public class RestoreInProgress extends AbstractNamedDiffable<Custom> implements
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(entries.size()); out.writeCollection(entries.values(), (o, entry) -> {
for (Entry entry : entries.values()) { o.writeString(entry.uuid);
out.writeString(entry.uuid); entry.snapshot().writeTo(o);
entry.snapshot().writeTo(out); o.writeByte(entry.state().value());
out.writeByte(entry.state().value()); o.writeStringCollection(entry.indices);
out.writeStringCollection(entry.indices); o.writeMap(entry.shards);
out.writeMap(entry.shards); });
}
} }
@Override @Override

View file

@ -1247,24 +1247,14 @@ public class IndexMetadata implements Diffable<IndexMetadata>, ToXContentFragmen
mapping.writeTo(out); mapping.writeTo(out);
} }
} }
out.writeVInt(aliases.size()); out.writeCollection(aliases.values());
for (AliasMetadata aliasMetadata : aliases.values()) { out.writeMap(customData, StreamOutput::writeString, (o, v) -> v.writeTo(o));
aliasMetadata.writeTo(out); out.writeMap(
} inSyncAllocationIds,
out.writeVInt(customData.size()); StreamOutput::writeVInt,
for (final Map.Entry<String, DiffableStringMap> cursor : customData.entrySet()) { (o, v) -> DiffableUtils.StringSetValueSerializer.getInstance().write(v, o)
out.writeString(cursor.getKey()); );
cursor.getValue().writeTo(out); out.writeCollection(rolloverInfos.values());
}
out.writeVInt(inSyncAllocationIds.size());
for (Map.Entry<Integer, Set<String>> cursor : inSyncAllocationIds.entrySet()) {
out.writeVInt(cursor.getKey());
DiffableUtils.StringSetValueSerializer.getInstance().write(cursor.getValue(), out);
}
out.writeVInt(rolloverInfos.size());
for (RolloverInfo rolloverInfo : rolloverInfos.values()) {
rolloverInfo.writeTo(out);
}
if (out.getVersion().onOrAfter(SYSTEM_INDEX_FLAG_ADDED)) { if (out.getVersion().onOrAfter(SYSTEM_INDEX_FLAG_ADDED)) {
out.writeBoolean(isSystem); out.writeBoolean(isSystem);
} }

View file

@ -207,15 +207,8 @@ public class IndexTemplateMetadata implements SimpleDiffable<IndexTemplateMetada
out.writeInt(order); out.writeInt(order);
out.writeStringCollection(patterns); out.writeStringCollection(patterns);
Settings.writeSettingsToStream(settings, out); Settings.writeSettingsToStream(settings, out);
out.writeVInt(mappings.size()); out.writeMap(mappings, StreamOutput::writeString, (o, v) -> v.writeTo(o));
for (Map.Entry<String, CompressedXContent> cursor : mappings.entrySet()) { out.writeCollection(aliases.values());
out.writeString(cursor.getKey());
cursor.getValue().writeTo(out);
}
out.writeVInt(aliases.size());
for (AliasMetadata aliasMetadata : aliases.values()) {
aliasMetadata.writeTo(out);
}
out.writeOptionalVInt(version); out.writeOptionalVInt(version);
} }

View file

@ -1212,10 +1212,7 @@ public class Metadata extends AbstractCollection<IndexMetadata> implements Diffa
for (IndexMetadata indexMetadata : this) { for (IndexMetadata indexMetadata : this) {
indexMetadata.writeTo(out, writeMappingsHash); indexMetadata.writeTo(out, writeMappingsHash);
} }
out.writeVInt(templates.size()); out.writeCollection(templates.values());
for (IndexTemplateMetadata template : templates.values()) {
template.writeTo(out);
}
VersionedNamedWriteable.writeVersionedWritables(out, customs); VersionedNamedWriteable.writeVersionedWritables(out, customs);
} }

View file

@ -388,12 +388,11 @@ public class DiscoveryNode implements Writeable, ToXContentFragment {
out.writeString(hostAddress); out.writeString(hostAddress);
address.writeTo(out); address.writeTo(out);
out.writeMap(attributes, StreamOutput::writeString, StreamOutput::writeString); out.writeMap(attributes, StreamOutput::writeString, StreamOutput::writeString);
out.writeVInt(roles.size()); out.writeCollection(roles, (o, role) -> {
for (final DiscoveryNodeRole role : roles) { o.writeString(role.roleName());
out.writeString(role.roleName()); o.writeString(role.roleNameAbbreviation());
out.writeString(role.roleNameAbbreviation()); o.writeBoolean(role.canContainData());
out.writeBoolean(role.canContainData()); });
}
Version.writeVersion(version, out); Version.writeVersion(version, out);
if (out.getVersion().onOrAfter(EXTERNAL_ID_VERSION)) { if (out.getVersion().onOrAfter(EXTERNAL_ID_VERSION)) {
out.writeString(externalId); out.writeString(externalId);

View file

@ -574,10 +574,7 @@ public class DiscoveryNodes extends AbstractCollection<DiscoveryNode> implements
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalString(masterNodeId); out.writeOptionalString(masterNodeId);
out.writeVInt(nodes.size()); out.writeCollection(nodes.values());
for (DiscoveryNode node : this) {
node.writeTo(out);
}
} }
public static DiscoveryNodes readFrom(StreamInput in, DiscoveryNode localNode) throws IOException { public static DiscoveryNodes readFrom(StreamInput in, DiscoveryNode localNode) throws IOException {

View file

@ -313,10 +313,7 @@ public class IndexRoutingTable implements SimpleDiffable<IndexRoutingTable> {
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
index.writeTo(out); index.writeTo(out);
out.writeVInt(shards.length); out.writeArray((o, s) -> IndexShardRoutingTable.Builder.writeToThin(s, o), shards);
for (IndexShardRoutingTable indexShard : this.shards) {
IndexShardRoutingTable.Builder.writeToThin(indexShard, out);
}
} }
public static Builder builder(Index index) { public static Builder builder(Index index) {

View file

@ -620,11 +620,7 @@ public class IndexShardRoutingTable {
public static void writeToThin(IndexShardRoutingTable indexShard, StreamOutput out) throws IOException { public static void writeToThin(IndexShardRoutingTable indexShard, StreamOutput out) throws IOException {
out.writeVInt(indexShard.shardId.id()); out.writeVInt(indexShard.shardId.id());
out.writeArray((o, v) -> v.writeToThin(o), indexShard.shards);
out.writeVInt(indexShard.shards.length);
for (ShardRouting entry : indexShard.shards) {
entry.writeToThin(out);
}
} }
} }

View file

@ -343,10 +343,7 @@ public class RoutingTable implements Iterable<IndexRoutingTable>, Diffable<Routi
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeLong(version); out.writeLong(version);
out.writeVInt(indicesRouting.size()); out.writeCollection(indicesRouting.values());
for (IndexRoutingTable index : indicesRouting.values()) {
index.writeTo(out);
}
} }
private static class RoutingTableDiff implements Diff<RoutingTable> { private static class RoutingTableDiff implements Diff<RoutingTable> {

View file

@ -68,10 +68,7 @@ public class RoutingExplanations implements ToXContentFragment {
* Write the RoutingExplanations object * Write the RoutingExplanations object
*/ */
public static void writeTo(RoutingExplanations explanations, StreamOutput out) throws IOException { public static void writeTo(RoutingExplanations explanations, StreamOutput out) throws IOException {
out.writeVInt(explanations.explanations.size()); out.writeCollection(explanations.explanations, (o, v) -> RerouteExplanation.writeTo(v, o));
for (RerouteExplanation explanation : explanations.explanations) {
RerouteExplanation.writeTo(explanation, out);
}
} }
@Override @Override

View file

@ -99,10 +99,7 @@ public class AllocationCommands implements ToXContentFragment {
* @throws IOException if something happens during write * @throws IOException if something happens during write
*/ */
public static void writeTo(AllocationCommands commands, StreamOutput out) throws IOException { public static void writeTo(AllocationCommands commands, StreamOutput out) throws IOException {
out.writeVInt(commands.commands.size()); out.writeNamedWriteableList(commands.commands);
for (AllocationCommand command : commands.commands) {
out.writeNamedWriteable(command);
}
} }
/** /**

View file

@ -339,10 +339,7 @@ public abstract class Decision implements ToXContent, Writeable {
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(true); // flag indicating it is a multi decision out.writeBoolean(true); // flag indicating it is a multi decision
out.writeVInt(getDecisions().size()); out.writeCollection(getDecisions());
for (Decision d : getDecisions()) {
d.writeTo(out);
}
} }
} }
} }

View file

@ -414,20 +414,12 @@ public class Lucene {
out.writeFloat(topDocs.maxScore); out.writeFloat(topDocs.maxScore);
out.writeArray(Lucene::writeSortField, topFieldDocs.fields); out.writeArray(Lucene::writeSortField, topFieldDocs.fields);
out.writeArray((o, doc) -> writeFieldDoc(o, (FieldDoc) doc), topFieldDocs.scoreDocs);
out.writeVInt(topDocs.topDocs.scoreDocs.length);
for (ScoreDoc doc : topFieldDocs.scoreDocs) {
writeFieldDoc(out, (FieldDoc) doc);
}
} else { } else {
out.writeByte((byte) 0); out.writeByte((byte) 0);
writeTotalHits(out, topDocs.topDocs.totalHits); writeTotalHits(out, topDocs.topDocs.totalHits);
out.writeFloat(topDocs.maxScore); out.writeFloat(topDocs.maxScore);
out.writeArray(Lucene::writeScoreDoc, topDocs.topDocs.scoreDocs);
out.writeVInt(topDocs.topDocs.scoreDocs.length);
for (ScoreDoc doc : topDocs.topDocs.scoreDocs) {
writeScoreDoc(out, doc);
}
} }
} }
@ -495,10 +487,7 @@ public class Lucene {
} }
public static void writeFieldDoc(StreamOutput out, FieldDoc fieldDoc) throws IOException { public static void writeFieldDoc(StreamOutput out, FieldDoc fieldDoc) throws IOException {
out.writeVInt(fieldDoc.fields.length); out.writeArray(Lucene::writeSortValue, fieldDoc.fields);
for (Object field : fieldDoc.fields) {
writeSortValue(out, field);
}
out.writeVInt(fieldDoc.doc); out.writeVInt(fieldDoc.doc);
out.writeFloat(fieldDoc.score); out.writeFloat(fieldDoc.score);
} }
@ -627,10 +616,7 @@ public class Lucene {
out.writeBoolean(explanation.isMatch()); out.writeBoolean(explanation.isMatch());
out.writeString(explanation.getDescription()); out.writeString(explanation.getDescription());
Explanation[] subExplanations = explanation.getDetails(); Explanation[] subExplanations = explanation.getDetails();
out.writeVInt(subExplanations.length); out.writeArray(Lucene::writeExplanation, subExplanations);
for (Explanation subExp : subExplanations) {
writeExplanation(out, subExp);
}
if (explanation.isMatch()) { if (explanation.isMatch()) {
writeExplanationValue(out, explanation.getValue()); writeExplanationValue(out, explanation.getValue());
} }

View file

@ -685,12 +685,7 @@ public final class ThreadContext implements Writeable {
requestHeaders.putAll(this.requestHeaders); requestHeaders.putAll(this.requestHeaders);
} }
out.writeVInt(requestHeaders.size()); out.writeMap(requestHeaders, StreamOutput::writeString, StreamOutput::writeString);
for (Map.Entry<String, String> entry : requestHeaders.entrySet()) {
out.writeString(entry.getKey());
out.writeString(entry.getValue());
}
out.writeMap(responseHeaders, StreamOutput::writeString, StreamOutput::writeStringCollection); out.writeMap(responseHeaders, StreamOutput::writeString, StreamOutput::writeStringCollection);
} }
} }

View file

@ -78,11 +78,7 @@ public final class CommitStats implements Writeable, ToXContentFragment {
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(userData.size()); out.writeMap(userData, StreamOutput::writeString, StreamOutput::writeString);
for (Map.Entry<String, String> entry : userData.entrySet()) {
out.writeString(entry.getKey());
out.writeString(entry.getValue());
}
out.writeLong(generation); out.writeLong(generation);
out.writeOptionalString(id); out.writeOptionalString(id);
out.writeInt(numDocs); out.writeInt(numDocs);

View file

@ -219,29 +219,28 @@ public class Segment implements Writeable {
out.writeVInt(0); out.writeVInt(0);
return; return;
} }
out.writeVInt(sort.getSort().length); out.writeArray((o, field) -> {
for (SortField field : sort.getSort()) { o.writeString(field.getField());
out.writeString(field.getField());
if (field instanceof SortedSetSortField) { if (field instanceof SortedSetSortField) {
out.writeByte((byte) 0); o.writeByte((byte) 0);
out.writeOptionalBoolean(field.getMissingValue() == null ? null : field.getMissingValue() == SortField.STRING_FIRST); o.writeOptionalBoolean(field.getMissingValue() == null ? null : field.getMissingValue() == SortField.STRING_FIRST);
out.writeBoolean(((SortedSetSortField) field).getSelector() == SortedSetSelector.Type.MAX); o.writeBoolean(((SortedSetSortField) field).getSelector() == SortedSetSelector.Type.MAX);
out.writeBoolean(field.getReverse()); o.writeBoolean(field.getReverse());
} else if (field instanceof SortedNumericSortField) { } else if (field instanceof SortedNumericSortField) {
switch (((SortedNumericSortField) field).getNumericType()) { switch (((SortedNumericSortField) field).getNumericType()) {
case INT -> out.writeByte((byte) 1); case INT -> o.writeByte((byte) 1);
case FLOAT -> out.writeByte((byte) 2); case FLOAT -> o.writeByte((byte) 2);
case DOUBLE -> out.writeByte((byte) 3); case DOUBLE -> o.writeByte((byte) 3);
case LONG -> out.writeByte((byte) 4); case LONG -> o.writeByte((byte) 4);
default -> throw new IOException("invalid index sort field:" + field); default -> throw new IOException("invalid index sort field:" + field);
} }
out.writeGenericValue(field.getMissingValue()); o.writeGenericValue(field.getMissingValue());
out.writeBoolean(((SortedNumericSortField) field).getSelector() == SortedNumericSelector.Type.MAX); o.writeBoolean(((SortedNumericSortField) field).getSelector() == SortedNumericSelector.Type.MAX);
out.writeBoolean(field.getReverse()); o.writeBoolean(field.getReverse());
} else { } else {
throw new IOException("invalid index sort field:" + field); throw new IOException("invalid index sort field:" + field);
} }
} }, sort.getSort());
} }
private static void readRamTree(StreamInput in) throws IOException { private static void readRamTree(StreamInput in) throws IOException {

View file

@ -224,10 +224,7 @@ public class SegmentsStats implements Writeable, ToXContentFragment {
out.writeLong(bitsetMemoryInBytes); out.writeLong(bitsetMemoryInBytes);
out.writeLong(maxUnsafeAutoIdTimestamp); out.writeLong(maxUnsafeAutoIdTimestamp);
out.writeVInt(files.size()); out.writeCollection(files.values());
for (FileStats file : files.values()) {
file.writeTo(out);
}
} }
public void clearFiles() { public void clearFiles() {

View file

@ -105,10 +105,7 @@ public class GeoPolygonQueryBuilder extends AbstractQueryBuilder<GeoPolygonQuery
@Override @Override
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeString(fieldName); out.writeString(fieldName);
out.writeVInt(shell.size()); out.writeCollection(shell, StreamOutput::writeGeoPoint);
for (GeoPoint point : shell) {
out.writeGeoPoint(point);
}
validationMethod.writeTo(out); validationMethod.writeTo(out);
out.writeBoolean(ignoreUnmapped); out.writeBoolean(ignoreUnmapped);
} }

View file

@ -223,10 +223,7 @@ public final class InnerHitBuilder implements Writeable, ToXContentObject {
boolean hasSorts = sorts != null; boolean hasSorts = sorts != null;
out.writeBoolean(hasSorts); out.writeBoolean(hasSorts);
if (hasSorts) { if (hasSorts) {
out.writeVInt(sorts.size()); out.writeNamedWriteableList(sorts);
for (SortBuilder<?> sort : sorts) {
out.writeNamedWriteable(sort);
}
} }
out.writeOptionalWriteable(highlightBuilder); out.writeOptionalWriteable(highlightBuilder);
out.writeOptionalWriteable(innerCollapseBuilder); out.writeOptionalWriteable(innerCollapseBuilder);

View file

@ -234,11 +234,7 @@ public class MultiMatchQueryBuilder extends AbstractQueryBuilder<MultiMatchQuery
@Override @Override
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeGenericValue(value); out.writeGenericValue(value);
out.writeVInt(fieldsBoosts.size()); out.writeMap(fieldsBoosts, StreamOutput::writeString, StreamOutput::writeFloat);
for (Map.Entry<String, Float> fieldsEntry : fieldsBoosts.entrySet()) {
out.writeString(fieldsEntry.getKey());
out.writeFloat(fieldsEntry.getValue());
}
type.writeTo(out); type.writeTo(out);
operator.writeTo(out); operator.writeTo(out);
out.writeOptionalString(analyzer); out.writeOptionalString(analyzer);

View file

@ -192,11 +192,7 @@ public class QueryStringQueryBuilder extends AbstractQueryBuilder<QueryStringQue
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeString(this.queryString); out.writeString(this.queryString);
out.writeOptionalString(this.defaultField); out.writeOptionalString(this.defaultField);
out.writeVInt(this.fieldsAndWeights.size()); out.writeMap(this.fieldsAndWeights, StreamOutput::writeString, StreamOutput::writeFloat);
for (Map.Entry<String, Float> fieldsEntry : this.fieldsAndWeights.entrySet()) {
out.writeString(fieldsEntry.getKey());
out.writeFloat(fieldsEntry.getValue());
}
this.defaultOperator.writeTo(out); this.defaultOperator.writeTo(out);
out.writeOptionalString(this.analyzer); out.writeOptionalString(this.analyzer);
out.writeOptionalString(this.quoteAnalyzer); out.writeOptionalString(this.quoteAnalyzer);

View file

@ -556,10 +556,7 @@ public class BulkByScrollTask extends CancellableTask {
out.writeFloat(requestsPerSecond); out.writeFloat(requestsPerSecond);
out.writeOptionalString(reasonCancelled); out.writeOptionalString(reasonCancelled);
out.writeTimeValue(throttledUntil); out.writeTimeValue(throttledUntil);
out.writeVInt(sliceStatuses.size()); out.writeCollection(sliceStatuses, StreamOutput::writeOptionalWriteable);
for (StatusOrException sliceStatus : sliceStatuses) {
out.writeOptionalWriteable(sliceStatus);
}
} }
@Override @Override

View file

@ -169,14 +169,7 @@ public class NodeIndicesStats implements Writeable, ToXContentFragment {
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
stats.writeTo(out); stats.writeTo(out);
out.writeVInt(statsByShard.size()); out.writeMap(statsByShard, (o, k) -> k.writeTo(o), StreamOutput::writeList);
for (Map.Entry<Index, List<IndexShardStats>> entry : statsByShard.entrySet()) {
entry.getKey().writeTo(out);
out.writeVInt(entry.getValue().size());
for (IndexShardStats indexShardStats : entry.getValue()) {
indexShardStats.writeTo(out);
}
}
} }
@Override @Override

View file

@ -92,25 +92,12 @@ public class RecoveryFilesInfoRequest extends RecoveryTransportRequest {
out.writeLong(recoveryId); out.writeLong(recoveryId);
shardId.writeTo(out); shardId.writeTo(out);
out.writeVInt(phase1FileNames.size()); out.writeStringCollection(phase1FileNames);
for (String phase1FileName : phase1FileNames) { out.writeCollection(phase1FileSizes, StreamOutput::writeVLong);
out.writeString(phase1FileName);
}
out.writeVInt(phase1FileSizes.size()); out.writeStringCollection(phase1ExistingFileNames);
for (Long phase1FileSize : phase1FileSizes) { out.writeCollection(phase1ExistingFileSizes, StreamOutput::writeVLong);
out.writeVLong(phase1FileSize);
}
out.writeVInt(phase1ExistingFileNames.size());
for (String phase1ExistingFileName : phase1ExistingFileNames) {
out.writeString(phase1ExistingFileName);
}
out.writeVInt(phase1ExistingFileSizes.size());
for (Long phase1ExistingFileSize : phase1ExistingFileSizes) {
out.writeVLong(phase1ExistingFileSize);
}
out.writeVInt(totalTranslogOps); out.writeVInt(totalTranslogOps);
} }
} }

View file

@ -77,12 +77,11 @@ public class IngestStats implements Writeable, ToXContentFragment {
if (processorStatsForPipeline == null) { if (processorStatsForPipeline == null) {
out.writeVInt(0); out.writeVInt(0);
} else { } else {
out.writeVInt(processorStatsForPipeline.size()); out.writeCollection(processorStatsForPipeline, (o, processorStat) -> {
for (ProcessorStat processorStat : processorStatsForPipeline) { o.writeString(processorStat.getName());
out.writeString(processorStat.getName()); o.writeString(processorStat.getType());
out.writeString(processorStat.getType()); processorStat.getStats().writeTo(o);
processorStat.getStats().writeTo(out); });
}
} }
} }
} }

View file

@ -461,10 +461,7 @@ public class FsInfo implements Iterable<FsInfo.Path>, Writeable, ToXContentFragm
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVLong(timestamp); out.writeVLong(timestamp);
out.writeOptionalWriteable(ioStats); out.writeOptionalWriteable(ioStats);
out.writeVInt(paths.length); out.writeArray(paths);
for (Path path : paths) {
path.writeTo(out);
}
} }
public Path getTotal() { public Path getTotal() {

View file

@ -313,11 +313,7 @@ public class JvmInfo implements ReportingService.Info {
} }
out.writeString(bootClassPath); out.writeString(bootClassPath);
out.writeString(classPath); out.writeString(classPath);
out.writeVInt(this.systemProperties.size()); out.writeMap(this.systemProperties, StreamOutput::writeString, StreamOutput::writeString);
for (Map.Entry<String, String> entry : systemProperties.entrySet()) {
out.writeString(entry.getKey());
out.writeString(entry.getValue());
}
mem.writeTo(out); mem.writeTo(out);
out.writeStringArray(gcCollectors); out.writeStringArray(gcCollectors);
out.writeStringArray(memoryPools); out.writeStringArray(memoryPools);

View file

@ -257,12 +257,7 @@ public final class ScriptMetadata implements Metadata.Custom, Writeable, ToXCont
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(scripts.size()); out.writeMap(scripts, StreamOutput::writeString, (o, v) -> v.writeTo(o));
for (Map.Entry<String, StoredScriptSource> entry : scripts.entrySet()) {
out.writeString(entry.getKey());
entry.getValue().writeTo(out);
}
} }
/** /**

View file

@ -233,10 +233,7 @@ public final class SearchHit implements Writeable, ToXContentObject, Iterable<Do
if (fields == null) { if (fields == null) {
out.writeVInt(0); out.writeVInt(0);
} else { } else {
out.writeVInt(fields.size()); out.writeCollection(fields.values());
for (DocumentField field : fields.values()) {
field.writeTo(out);
}
} }
} }
@ -267,30 +264,20 @@ public final class SearchHit implements Writeable, ToXContentObject, Iterable<Do
if (highlightFields == null) { if (highlightFields == null) {
out.writeVInt(0); out.writeVInt(0);
} else { } else {
out.writeVInt(highlightFields.size()); out.writeCollection(highlightFields.values());
for (HighlightField highlightField : highlightFields.values()) {
highlightField.writeTo(out);
}
} }
sortValues.writeTo(out); sortValues.writeTo(out);
if (matchedQueries.length == 0) { if (matchedQueries.length == 0) {
out.writeVInt(0); out.writeVInt(0);
} else { } else {
out.writeVInt(matchedQueries.length); out.writeStringArray(matchedQueries);
for (String matchedFilter : matchedQueries) {
out.writeString(matchedFilter);
}
} }
out.writeOptionalWriteable(shard); out.writeOptionalWriteable(shard);
if (innerHits == null) { if (innerHits == null) {
out.writeVInt(0); out.writeVInt(0);
} else { } else {
out.writeVInt(innerHits.size()); out.writeMap(innerHits, StreamOutput::writeString, (o, v) -> v.writeTo(o));
for (Map.Entry<String, SearchHits> entry : innerHits.entrySet()) {
out.writeString(entry.getKey());
entry.getValue().writeTo(out);
}
} }
} }

View file

@ -97,12 +97,7 @@ public final class SearchHits implements Writeable, ToXContentFragment, Iterable
Lucene.writeTotalHits(out, totalHits); Lucene.writeTotalHits(out, totalHits);
} }
out.writeFloat(maxScore); out.writeFloat(maxScore);
out.writeVInt(hits.length); out.writeArray(hits);
if (hits.length > 0) {
for (SearchHit hit : hits) {
hit.writeTo(out);
}
}
out.writeOptionalArray(Lucene::writeSortField, sortFields); out.writeOptionalArray(Lucene::writeSortField, sortFields);
out.writeOptionalString(collapseField); out.writeOptionalString(collapseField);
out.writeOptionalArray(Lucene::writeSortValue, collapseValues); out.writeOptionalArray(Lucene::writeSortValue, collapseValues);

View file

@ -303,14 +303,8 @@ public class AggregatorFactories {
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(this.aggregationBuilders.size()); out.writeCollection(this.aggregationBuilders, StreamOutput::writeNamedWriteable);
for (AggregationBuilder factory : aggregationBuilders) { out.writeCollection(this.pipelineAggregatorBuilders, StreamOutput::writeNamedWriteable);
out.writeNamedWriteable(factory);
}
out.writeVInt(this.pipelineAggregatorBuilders.size());
for (PipelineAggregationBuilder factory : pipelineAggregatorBuilders) {
out.writeNamedWriteable(factory);
}
} }
public boolean mustVisitAllDocs() { public boolean mustVisitAllDocs() {

View file

@ -519,10 +519,7 @@ public abstract class InternalOrder extends BucketOrder {
out.writeBoolean(aggregationOrder.order == SortOrder.ASC); out.writeBoolean(aggregationOrder.order == SortOrder.ASC);
out.writeString(aggregationOrder.path().toString()); out.writeString(aggregationOrder.path().toString());
} else if (order instanceof CompoundOrder compoundOrder) { } else if (order instanceof CompoundOrder compoundOrder) {
out.writeVInt(compoundOrder.orderElements.size()); out.writeCollection(compoundOrder.orderElements);
for (BucketOrder innerOrder : compoundOrder.orderElements) {
innerOrder.writeTo(out);
}
} }
} }

View file

@ -141,10 +141,7 @@ public class InternalAdjacencyMatrix extends InternalMultiBucketAggregation<Inte
@Override @Override
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeVInt(buckets.size()); out.writeCollection(buckets);
for (InternalBucket bucket : buckets) {
bucket.writeTo(out);
}
} }
@Override @Override

View file

@ -112,10 +112,7 @@ public class CompositeAggregationBuilder extends AbstractAggregationBuilder<Comp
@Override @Override
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeVInt(sources.size()); out.writeCollection(sources, (o, v) -> CompositeValuesSourceParserHelper.writeTo(v, o));
for (CompositeValuesSourceBuilder<?> builder : sources) {
CompositeValuesSourceParserHelper.writeTo(builder, out);
}
out.writeVInt(size); out.writeVInt(size);
out.writeBoolean(after != null); out.writeBoolean(after != null);
if (after != null) { if (after != null) {

View file

@ -128,16 +128,7 @@ public class FiltersAggregationBuilder extends AbstractAggregationBuilder<Filter
@Override @Override
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeBoolean(keyed); out.writeBoolean(keyed);
out.writeVInt(filters.size()); out.writeCollection(filters, keyed ? (o, v) -> v.writeTo(o) : (o, v) -> o.writeNamedWriteable(v.filter()));
if (keyed) {
for (KeyedFilter keyedFilter : filters) {
keyedFilter.writeTo(out);
}
} else {
for (KeyedFilter keyedFilter : filters) {
out.writeNamedWriteable(keyedFilter.filter());
}
}
out.writeBoolean(otherBucket); out.writeBoolean(otherBucket);
out.writeString(otherBucketKey); out.writeString(otherBucketKey);
} }

View file

@ -148,10 +148,7 @@ public class InternalFilters extends InternalMultiBucketAggregation<InternalFilt
@Override @Override
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeBoolean(keyed); out.writeBoolean(keyed);
out.writeVInt(buckets.size()); out.writeList(buckets);
for (InternalBucket bucket : buckets) {
bucket.writeTo(out);
}
} }
@Override @Override

View file

@ -166,10 +166,7 @@ public final class InternalAutoDateHistogram extends InternalMultiBucketAggregat
} }
void writeTo(StreamOutput out) throws IOException { void writeTo(StreamOutput out) throws IOException {
out.writeVInt(roundingInfos.length); out.writeArray(roundingInfos);
for (RoundingInfo roundingInfo : roundingInfos) {
roundingInfo.writeTo(out);
}
out.writeVInt(roundingIdx); out.writeVInt(roundingIdx);
emptySubAggregations.writeTo(out); emptySubAggregations.writeTo(out);
} }

View file

@ -106,10 +106,7 @@ public abstract class AbstractRangeBuilder<AB extends AbstractRangeBuilder<AB, R
@Override @Override
protected void innerWriteTo(StreamOutput out) throws IOException { protected void innerWriteTo(StreamOutput out) throws IOException {
out.writeVInt(ranges.size()); out.writeList(ranges);
for (Range range : ranges) {
range.writeTo(out);
}
out.writeBoolean(keyed); out.writeBoolean(keyed);
} }

View file

@ -311,10 +311,7 @@ public class GeoDistanceAggregationBuilder extends ValuesSourceAggregationBuilde
protected void innerWriteTo(StreamOutput out) throws IOException { protected void innerWriteTo(StreamOutput out) throws IOException {
out.writeDouble(origin.lat()); out.writeDouble(origin.lat());
out.writeDouble(origin.lon()); out.writeDouble(origin.lon());
out.writeVInt(ranges.size()); out.writeList(ranges);
for (Range range : ranges) {
range.writeTo(out);
}
out.writeBoolean(keyed); out.writeBoolean(keyed);
distanceType.writeTo(out); distanceType.writeTo(out);
unit.writeTo(out); unit.writeTo(out);

View file

@ -302,10 +302,7 @@ public class InternalRange<B extends InternalRange.Bucket, R extends InternalRan
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeNamedWriteable(format); out.writeNamedWriteable(format);
out.writeBoolean(keyed); out.writeBoolean(keyed);
out.writeVInt(ranges.size()); out.writeCollection(ranges);
for (B bucket : ranges) {
bucket.writeTo(out);
}
} }
@Override @Override

View file

@ -13,6 +13,7 @@ import org.elasticsearch.Version;
import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.network.InetAddresses; import org.elasticsearch.common.network.InetAddresses;
import org.elasticsearch.core.Tuple; import org.elasticsearch.core.Tuple;
import org.elasticsearch.script.Script; import org.elasticsearch.script.Script;
@ -100,7 +101,7 @@ public final class IpRangeAggregationBuilder extends ValuesSourceAggregationBuil
} }
} }
public static class Range implements ToXContentObject { public static class Range implements ToXContentObject, Writeable {
private final String key; private final String key;
private final String from; private final String from;
@ -155,7 +156,8 @@ public final class IpRangeAggregationBuilder extends ValuesSourceAggregationBuil
this.to = in.readOptionalString(); this.to = in.readOptionalString();
} }
void writeTo(StreamOutput out) throws IOException { @Override
public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalString(key); out.writeOptionalString(key);
out.writeOptionalString(from); out.writeOptionalString(from);
out.writeOptionalString(to); out.writeOptionalString(to);
@ -354,10 +356,7 @@ public final class IpRangeAggregationBuilder extends ValuesSourceAggregationBuil
@Override @Override
protected void innerWriteTo(StreamOutput out) throws IOException { protected void innerWriteTo(StreamOutput out) throws IOException {
out.writeVInt(ranges.size()); out.writeCollection(ranges);
for (Range range : ranges) {
range.writeTo(out);
}
out.writeBoolean(keyed); out.writeBoolean(keyed);
} }

View file

@ -433,18 +433,12 @@ public class IncludeExclude implements Writeable, ToXContentFragment {
boolean hasIncludes = includeValues != null; boolean hasIncludes = includeValues != null;
out.writeBoolean(hasIncludes); out.writeBoolean(hasIncludes);
if (hasIncludes) { if (hasIncludes) {
out.writeVInt(includeValues.size()); out.writeCollection(includeValues, StreamOutput::writeBytesRef);
for (BytesRef value : includeValues) {
out.writeBytesRef(value);
}
} }
boolean hasExcludes = excludeValues != null; boolean hasExcludes = excludeValues != null;
out.writeBoolean(hasExcludes); out.writeBoolean(hasExcludes);
if (hasExcludes) { if (hasExcludes) {
out.writeVInt(excludeValues.size()); out.writeCollection(excludeValues, StreamOutput::writeBytesRef);
for (BytesRef value : excludeValues) {
out.writeBytesRef(value);
}
} }
out.writeVInt(incNumPartitions); out.writeVInt(incNumPartitions);
out.writeVInt(incZeroBasedPartition); out.writeVInt(incZeroBasedPartition);

View file

@ -25,7 +25,6 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects; import java.util.Objects;
import java.util.TreeMap; import java.util.TreeMap;
@ -96,11 +95,7 @@ public class BucketScriptPipelineAggregationBuilder extends AbstractPipelineAggr
@Override @Override
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeVInt(bucketsPathsMap.size()); out.writeMap(bucketsPathsMap, StreamOutput::writeString, StreamOutput::writeString);
for (Entry<String, String> e : bucketsPathsMap.entrySet()) {
out.writeString(e.getKey());
out.writeString(e.getValue());
}
script.writeTo(out); script.writeTo(out);
out.writeOptionalString(format); out.writeOptionalString(format);
gapPolicy.writeTo(out); gapPolicy.writeTo(out);

View file

@ -52,14 +52,7 @@ public class AggregationInfo implements ReportingService.Info {
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(aggs.size()); out.writeMap(aggs, StreamOutput::writeString, StreamOutput::writeStringCollection);
for (Map.Entry<String, Set<String>> e : aggs.entrySet()) {
out.writeString(e.getKey());
out.writeVInt(e.getValue().size());
for (String type : e.getValue()) {
out.writeString(type);
}
}
} }
public Map<String, Set<String>> getAggregations() { public Map<String, Set<String>> getAggregations() {

View file

@ -181,10 +181,7 @@ public class InternalTimeSeries extends InternalMultiBucketAggregation<InternalT
@Override @Override
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeBoolean(keyed); out.writeBoolean(keyed);
out.writeVInt(buckets.size()); out.writeCollection(buckets);
for (InternalTimeSeries.InternalBucket bucket : buckets) {
bucket.writeTo(out);
}
} }
@Override @Override

View file

@ -283,10 +283,7 @@ public final class SearchSourceBuilder implements Writeable, ToXContentObject, R
boolean hasSorts = sorts != null; boolean hasSorts = sorts != null;
out.writeBoolean(hasSorts); out.writeBoolean(hasSorts);
if (hasSorts) { if (hasSorts) {
out.writeVInt(sorts.size()); out.writeNamedWriteableList(sorts);
for (SortBuilder<?> sort : sorts) {
out.writeNamedWriteable(sort);
}
} }
boolean hasStats = stats != null; boolean hasStats = stats != null;
out.writeBoolean(hasStats); out.writeBoolean(hasStats);

View file

@ -57,18 +57,14 @@ public class AggregatedDfs implements Writeable {
@Override @Override
public void writeTo(final StreamOutput out) throws IOException { public void writeTo(final StreamOutput out) throws IOException {
out.writeVInt(termStatistics.size()); out.writeMap(termStatistics, (o, k) -> {
o.writeString(k.field());
for (var entry : termStatistics().entrySet()) { o.writeBytesRef(k.bytes());
Term term = entry.getKey(); }, (o, v) -> {
out.writeString(term.field()); o.writeBytesRef(v.term());
out.writeBytesRef(term.bytes()); o.writeVLong(v.docFreq());
TermStatistics stats = entry.getValue(); o.writeVLong(DfsSearchResult.addOne(v.totalTermFreq()));
out.writeBytesRef(stats.term()); });
out.writeVLong(stats.docFreq());
out.writeVLong(DfsSearchResult.addOne(stats.totalTermFreq()));
}
DfsSearchResult.writeFieldStats(out, fieldStatistics); DfsSearchResult.writeFieldStats(out, fieldStatistics);
out.writeVLong(maxDoc); out.writeVLong(maxDoc);
} }

View file

@ -95,11 +95,10 @@ public class DfsSearchResult extends SearchPhaseResult {
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
contextId.writeTo(out); contextId.writeTo(out);
out.writeVInt(terms.length); out.writeArray((o, term) -> {
for (Term term : terms) { o.writeString(term.field());
out.writeString(term.field()); o.writeBytesRef(term.bytes());
out.writeBytesRef(term.bytes()); }, terms);
}
writeTermStats(out, termStatistics); writeTermStats(out, termStatistics);
writeFieldStats(out, fieldStatistics); writeFieldStats(out, fieldStatistics);
out.writeVInt(maxDoc); out.writeVInt(maxDoc);
@ -109,25 +108,18 @@ public class DfsSearchResult extends SearchPhaseResult {
} }
public static void writeFieldStats(StreamOutput out, Map<String, CollectionStatistics> fieldStatistics) throws IOException { public static void writeFieldStats(StreamOutput out, Map<String, CollectionStatistics> fieldStatistics) throws IOException {
out.writeVInt(fieldStatistics.size()); out.writeMap(fieldStatistics, StreamOutput::writeString, (o, statistics) -> {
for (var entry : fieldStatistics.entrySet()) {
out.writeString(entry.getKey());
CollectionStatistics statistics = entry.getValue();
assert statistics.maxDoc() >= 0; assert statistics.maxDoc() >= 0;
out.writeVLong(statistics.maxDoc()); o.writeVLong(statistics.maxDoc());
// stats are always positive numbers // stats are always positive numbers
out.writeVLong(statistics.docCount()); o.writeVLong(statistics.docCount());
out.writeVLong(statistics.sumTotalTermFreq()); o.writeVLong(statistics.sumTotalTermFreq());
out.writeVLong(statistics.sumDocFreq()); o.writeVLong(statistics.sumDocFreq());
} });
} }
public static void writeTermStats(StreamOutput out, TermStatistics[] termStatistics) throws IOException { public static void writeTermStats(StreamOutput out, TermStatistics[] termStatistics) throws IOException {
out.writeVInt(termStatistics.length); out.writeArray(DfsSearchResult::writeSingleTermStats, termStatistics);
for (TermStatistics termStatistic : termStatistics) {
writeSingleTermStats(out, termStatistic);
}
} }
public static void writeSingleTermStats(StreamOutput out, TermStatistics termStatistic) throws IOException { public static void writeSingleTermStats(StreamOutput out, TermStatistics termStatistic) throws IOException {

View file

@ -67,10 +67,7 @@ public class ShardFetchRequest extends TransportRequest {
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out); super.writeTo(out);
contextId.writeTo(out); contextId.writeTo(out);
out.writeVInt(docIds.length); out.writeVIntArray(docIds);
for (int docId : docIds) {
out.writeVInt(docId);
}
if (lastEmittedDoc == null) { if (lastEmittedDoc == null) {
out.writeByte((byte) 0); out.writeByte((byte) 0);
} else if (lastEmittedDoc instanceof FieldDoc) { } else if (lastEmittedDoc instanceof FieldDoc) {

View file

@ -94,10 +94,7 @@ public class HighlightField implements ToXContentFragment, Writeable {
out.writeBoolean(false); out.writeBoolean(false);
} else { } else {
out.writeBoolean(true); out.writeBoolean(true);
out.writeVInt(fragments.length); out.writeArray(StreamOutput::writeText, fragments);
for (Text fragment : fragments) {
out.writeText(fragment);
}
} }
} }

View file

@ -50,10 +50,7 @@ public final class AggregationProfileShardResult implements Writeable, ToXConten
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(aggProfileResults.size()); out.writeCollection(aggProfileResults);
for (ProfileResult p : aggProfileResults) {
p.writeTo(out);
}
} }
public List<ProfileResult> getProfileResults() { public List<ProfileResult> getProfileResults() {

View file

@ -58,10 +58,7 @@ public class SearchAfterBuilder implements ToXContentObject, Writeable {
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(sortValues.length); out.writeArray(StreamOutput::writeGenericValue, sortValues);
for (Object fieldValue : sortValues) {
out.writeGenericValue(fieldValue);
}
} }
public SearchAfterBuilder setSortValues(Object[] values) { public SearchAfterBuilder setSortValues(Object[] values) {

View file

@ -542,10 +542,7 @@ public class Suggest implements Iterable<Suggest.Suggestion<? extends Entry<? ex
out.writeText(text); out.writeText(text);
out.writeVInt(offset); out.writeVInt(offset);
out.writeVInt(length); out.writeVInt(length);
out.writeVInt(options.size()); out.writeCollection(options);
for (Option option : options) {
option.writeTo(out);
}
} }
@Override @Override

View file

@ -411,10 +411,7 @@ public final class CompletionSuggestion extends Suggest.Suggestion<CompletionSug
out.writeInt(contexts.size()); out.writeInt(contexts.size());
for (Map.Entry<String, Set<String>> entry : contexts.entrySet()) { for (Map.Entry<String, Set<String>> entry : contexts.entrySet()) {
out.writeString(entry.getKey()); out.writeString(entry.getKey());
out.writeVInt(entry.getValue().size()); out.writeStringCollection(entry.getValue());
for (CharSequence ctx : entry.getValue()) {
out.writeString(ctx.toString());
}
} }
} }

View file

@ -161,15 +161,7 @@ public class PhraseSuggestionBuilder extends SuggestionBuilder<PhraseSuggestionB
} }
out.writeMapWithConsistentOrder(collateParams); out.writeMapWithConsistentOrder(collateParams);
out.writeOptionalBoolean(collatePrune); out.writeOptionalBoolean(collatePrune);
out.writeVInt(this.generators.size()); out.writeMap(this.generators, StreamOutput::writeString, StreamOutput::writeList);
for (Entry<String, List<CandidateGenerator>> entry : this.generators.entrySet()) {
out.writeString(entry.getKey());
List<CandidateGenerator> generatorsList = entry.getValue();
out.writeVInt(generatorsList.size());
for (CandidateGenerator generator : generatorsList) {
generator.writeTo(out);
}
}
} }
/** /**

View file

@ -84,10 +84,7 @@ public class AutoscalingMetadata implements Metadata.Custom {
@Override @Override
public void writeTo(final StreamOutput out) throws IOException { public void writeTo(final StreamOutput out) throws IOException {
out.writeVInt(policies.size()); out.writeCollection(policies.values());
for (final Map.Entry<String, AutoscalingPolicyMetadata> policy : policies.entrySet()) {
policy.getValue().writeTo(out);
}
} }
@Override @Override

View file

@ -61,10 +61,7 @@ public final class BulkShardOperationsRequest extends ReplicatedWriteRequest<Bul
super.writeTo(out); super.writeTo(out);
out.writeString(historyUUID); out.writeString(historyUUID);
out.writeZLong(maxSeqNoOfUpdatesOrDeletes); out.writeZLong(maxSeqNoOfUpdatesOrDeletes);
out.writeVInt(operations.size()); out.writeCollection(operations, Translog.Operation::writeOperation);
for (Translog.Operation operation : operations) {
Translog.Operation.writeOperation(out, operation);
}
} }
@Override @Override

View file

@ -98,14 +98,7 @@ public class PostStartBasicResponse extends AcknowledgedResponse implements Stat
super.writeTo(out); super.writeTo(out);
out.writeEnum(status); out.writeEnum(status);
out.writeOptionalString(acknowledgeMessage); out.writeOptionalString(acknowledgeMessage);
out.writeVInt(acknowledgeMessages.size()); out.writeMap(acknowledgeMessages, StreamOutput::writeString, StreamOutput::writeStringArray);
for (Map.Entry<String, String[]> entry : acknowledgeMessages.entrySet()) {
out.writeString(entry.getKey());
out.writeVInt(entry.getValue().length);
for (String message : entry.getValue()) {
out.writeString(message);
}
}
} }
@Override @Override

View file

@ -88,14 +88,7 @@ public class PostStartTrialResponse extends ActionResponse {
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeEnum(status); out.writeEnum(status);
out.writeOptionalString(acknowledgeMessage); out.writeOptionalString(acknowledgeMessage);
out.writeVInt(acknowledgeMessages.size()); out.writeMap(acknowledgeMessages, StreamOutput::writeString, StreamOutput::writeStringArray);
for (Map.Entry<String, String[]> entry : acknowledgeMessages.entrySet()) {
out.writeString(entry.getKey());
out.writeVInt(entry.getValue().length);
for (String message : entry.getValue()) {
out.writeString(message);
}
}
} }
Map<String, String[]> getAcknowledgementMessages() { Map<String, String[]> getAcknowledgementMessages() {

View file

@ -15,6 +15,7 @@ import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.core.TimeValue; import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.search.aggregations.bucket.sampler.SamplerAggregationBuilder; import org.elasticsearch.search.aggregations.bucket.sampler.SamplerAggregationBuilder;
@ -313,7 +314,7 @@ public class GraphExploreRequest extends ActionRequest implements IndicesRequest
return hops.get(hopNumber); return hops.get(hopNumber);
} }
public static class TermBoost { public static class TermBoost implements Writeable {
String term; String term;
float boost; float boost;
@ -341,7 +342,8 @@ public class GraphExploreRequest extends ActionRequest implements IndicesRequest
this.boost = in.readFloat(); this.boost = in.readFloat();
} }
void writeTo(StreamOutput out) throws IOException { @Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(term); out.writeString(term);
out.writeFloat(boost); out.writeFloat(boost);
} }

View file

@ -71,10 +71,7 @@ public class Hop implements ToXContentFragment {
if (vertices == null) { if (vertices == null) {
out.writeVInt(0); out.writeVInt(0);
} else { } else {
out.writeVInt(vertices.size()); out.writeList(vertices);
for (VertexRequest vr : vertices) {
vr.writeTo(out);
}
} }
} }

View file

@ -9,6 +9,7 @@ package org.elasticsearch.protocol.xpack.graph;
import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.protocol.xpack.graph.GraphExploreRequest.TermBoost; import org.elasticsearch.protocol.xpack.graph.GraphExploreRequest.TermBoost;
import org.elasticsearch.xcontent.ToXContentObject; import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.XContentBuilder;
@ -27,7 +28,7 @@ import java.util.TreeSet;
* inclusion list to filter which terms are considered. * inclusion list to filter which terms are considered.
* *
*/ */
public class VertexRequest implements ToXContentObject { public class VertexRequest implements ToXContentObject, Writeable {
public static final int DEFAULT_SIZE = 5; public static final int DEFAULT_SIZE = 5;
public static final int DEFAULT_MIN_DOC_COUNT = 3; public static final int DEFAULT_MIN_DOC_COUNT = 3;
public static final int DEFAULT_SHARD_MIN_DOC_COUNT = 2; public static final int DEFAULT_SHARD_MIN_DOC_COUNT = 2;
@ -69,26 +70,21 @@ public class VertexRequest implements ToXContentObject {
} }
void writeTo(StreamOutput out) throws IOException { @Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(fieldName); out.writeString(fieldName);
out.writeVInt(size); out.writeVInt(size);
out.writeVInt(minDocCount); out.writeVInt(minDocCount);
out.writeVInt(shardMinDocCount); out.writeVInt(shardMinDocCount);
if (includes != null) { if (includes != null) {
out.writeVInt(includes.size()); out.writeCollection(includes.values());
for (TermBoost tb : includes.values()) {
tb.writeTo(out);
}
} else { } else {
out.writeVInt(0); out.writeVInt(0);
} }
if (excludes != null) { if (excludes != null) {
out.writeVInt(excludes.size()); out.writeStringCollection(excludes);
for (String term : excludes) {
out.writeString(term);
}
} else { } else {
out.writeVInt(0); out.writeVInt(0);
} }

View file

@ -76,14 +76,7 @@ public class PutLicenseResponse extends AcknowledgedResponse {
super.writeTo(out); super.writeTo(out);
out.writeVInt(status.id()); out.writeVInt(status.id());
out.writeOptionalString(acknowledgeHeader); out.writeOptionalString(acknowledgeHeader);
out.writeVInt(acknowledgeMessages.size()); out.writeMap(acknowledgeMessages, StreamOutput::writeString, StreamOutput::writeStringArray);
for (Map.Entry<String, String[]> entry : acknowledgeMessages.entrySet()) {
out.writeString(entry.getKey());
out.writeVInt(entry.getValue().length);
for (String message : entry.getValue()) {
out.writeString(message);
}
}
} }
@Override @Override

View file

@ -96,10 +96,7 @@ public class ExplainLifecycleResponse extends ActionResponse implements ToXConte
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(indexResponses.size()); out.writeCollection(indexResponses.values());
for (IndexLifecycleExplainResponse e : indexResponses.values()) {
e.writeTo(out);
}
} }
@Override @Override

View file

@ -55,10 +55,7 @@ public class ExportException extends ElasticsearchException implements Iterable<
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out); super.writeTo(out);
out.writeVInt(exceptions.size()); out.writeCollection(exceptions);
for (ExportException e : exceptions) {
e.writeTo(out);
}
} }
@Override @Override

View file

@ -455,10 +455,7 @@ public abstract class AbstractSqlQueryRequest extends AbstractSqlRequest impleme
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out); super.writeTo(out);
out.writeString(query); out.writeString(query);
out.writeVInt(params.size()); out.writeCollection(params, AbstractSqlQueryRequest::writeSqlTypedParamValue);
for (SqlTypedParamValue param : params) {
writeSqlTypedParamValue(out, param);
}
out.writeZoneId(zoneId); out.writeZoneId(zoneId);
if (out.getVersion().onOrAfter(Version.V_7_16_0)) { if (out.getVersion().onOrAfter(Version.V_7_16_0)) {
out.writeOptionalString(catalog); out.writeOptionalString(catalog);