File tree 6 files changed +33
-2
lines changed
server/src/main/java/org/elasticsearch/common
6 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,12 @@ public ReleasableBytesReference readReleasableBytesReference() throws IOExceptio
178
178
return retainAndSkip (len );
179
179
}
180
180
181
+ @ Override
182
+ public ReleasableBytesReference readReleasableBytesReference2 () throws IOException {
183
+ final int len = readInt ();
184
+ return retainAndSkip (len );
185
+ }
186
+
181
187
@ Override
182
188
public ReleasableBytesReference readAllToReleasableBytesReference () throws IOException {
183
189
return retainAndSkip (length () - offset ());
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ private Referencing(T reference) {
109
109
@ Override
110
110
public void writeTo (StreamOutput out ) throws IOException {
111
111
if (out .getTransportVersion ().onOrAfter (TransportVersions .COMPRESS_DELAYABLE_WRITEABLE )) {
112
- out .writeWithSizePrefixAndCompressed (reference );
112
+ out .writeWithSizePrefix2 (reference );
113
113
} else {
114
114
out .writeWithSizePrefix (reference );
115
115
}
Original file line number Diff line number Diff line change @@ -47,6 +47,11 @@ public ReleasableBytesReference readReleasableBytesReference() throws IOExceptio
47
47
return delegate .readReleasableBytesReference ();
48
48
}
49
49
50
+ @ Override
51
+ public ReleasableBytesReference readReleasableBytesReference2 () throws IOException {
52
+ return delegate .readReleasableBytesReference2 ();
53
+ }
54
+
50
55
@ Override
51
56
public boolean supportReadAllToReleasableBytesReference () {
52
57
return delegate .supportReadAllToReleasableBytesReference ();
Original file line number Diff line number Diff line change 13
13
import org .elasticsearch .common .bytes .BytesArray ;
14
14
import org .elasticsearch .common .bytes .BytesReference ;
15
15
import org .elasticsearch .common .bytes .CompositeBytesReference ;
16
+ import org .elasticsearch .common .compress .CompressorFactory ;
16
17
import org .elasticsearch .common .recycler .Recycler ;
17
18
import org .elasticsearch .core .Releasable ;
18
19
import org .elasticsearch .core .Releasables ;
20
+ import org .elasticsearch .core .Streams ;
19
21
20
22
import java .io .ByteArrayOutputStream ;
21
23
import java .io .IOException ;
@@ -177,6 +179,20 @@ public void writeWithSizePrefix(Writeable writeable) throws IOException {
177
179
}
178
180
}
179
181
182
+ @ Override
183
+ public void writeWithSizePrefix2 (Writeable writeable ) throws IOException {
184
+ long pos = position ();
185
+ skip (Integer .BYTES );
186
+ try (var out = new OutputStreamStreamOutput (CompressorFactory .COMPRESSOR .threadLocalOutputStream (Streams .noCloseStream (this )))) {
187
+ out .setTransportVersion (getTransportVersion ());
188
+ writeable .writeTo (out );
189
+ }
190
+ long newPos = position ();
191
+ seek (pos );
192
+ writeInt (Math .toIntExact (newPos - pos - Integer .BYTES ));
193
+ seek (newPos );
194
+ }
195
+
180
196
// overridden with some code duplication the same way other write methods in this class are overridden to bypass StreamOutput's
181
197
// intermediary buffers
182
198
@ Override
Original file line number Diff line number Diff line change @@ -142,6 +142,10 @@ public BytesReference readSlicedBytesReference() throws IOException {
142
142
return readBytesReference ();
143
143
}
144
144
145
+ public BytesReference readSlicedBytesReference (int bytes ) throws IOException {
146
+ return readBytesReference (bytes );
147
+ }
148
+
145
149
/**
146
150
* Checks if this {@link InputStream} supports {@link #readAllToReleasableBytesReference()}.
147
151
*/
Original file line number Diff line number Diff line change @@ -146,7 +146,7 @@ public void writeWithSizePrefix(Writeable writeable) throws IOException {
146
146
*
147
147
* @param writeable {@link Writeable} to serialize
148
148
*/
149
- public void writeWithSizePrefixAndCompressed (Writeable writeable ) throws IOException {
149
+ public void writeWithSizePrefix2 (Writeable writeable ) throws IOException {
150
150
final BytesStreamOutput tmp = new BytesStreamOutput ();
151
151
try (var o = new OutputStreamStreamOutput (CompressorFactory .COMPRESSOR .threadLocalOutputStream (tmp ))) {
152
152
o .setTransportVersion (version );
You can’t perform that action at this time.
0 commit comments