Skip to content

Commit

Permalink
Serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Brooks committed Aug 15, 2024
1 parent fad6142 commit a2ca451
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.RamUsageEstimator;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.CompositeIndicesRequest;
Expand Down Expand Up @@ -94,6 +95,11 @@ public BulkRequest(StreamInput in) throws IOException {
for (DocWriteRequest<?> request : requests) {
indices.add(Objects.requireNonNull(request.index(), "request index must not be null"));
}
if (in.getTransportVersion().onOrAfter(TransportVersions.BULK_INCREMENTAL_STATE)) {
incrementalState = new BulkRequest.IncrementalState(in);
} else {
incrementalState = BulkRequest.IncrementalState.EMPTY;
}
}

public BulkRequest(@Nullable String globalIndex) {
Expand Down Expand Up @@ -445,6 +451,9 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeCollection(requests, DocWriteRequest::writeDocumentRequest);
refreshPolicy.writeTo(out);
out.writeTimeValue(timeout);
if (out.getTransportVersion().onOrAfter(TransportVersions.BULK_INCREMENTAL_STATE)) {
incrementalState.writeTo(out);
}
}

@Override
Expand Down

0 comments on commit a2ca451

Please sign in to comment.