@@ -232,9 +232,10 @@ private Cell toOnheapCell(ByteBuffer valAndTagsBuffer, int vOffset,
232
232
int tOffset = 0 ;
233
233
if (this .includeTags ) {
234
234
if (this .tagCompressionContext == null ) {
235
- tagsArray = valAndTagsBuffer .array ();
236
235
tOffset =
237
236
valAndTagsBuffer .arrayOffset () + vOffset + this .valueLength + tagsLenSerializationSize ;
237
+ tagsArray = Bytes .copy (valAndTagsBuffer .array (), tOffset , this .tagsLength );
238
+ tOffset = 0 ;
238
239
} else {
239
240
tagsArray = Bytes .copy (tagsBuffer , 0 , this .tagsLength );
240
241
tOffset = 0 ;
@@ -243,9 +244,9 @@ private Cell toOnheapCell(ByteBuffer valAndTagsBuffer, int vOffset,
243
244
return new OnheapDecodedCell (Bytes .copy (keyBuffer , 0 , this .keyLength ),
244
245
currentKey .getRowLength (), currentKey .getFamilyOffset (), currentKey .getFamilyLength (),
245
246
currentKey .getQualifierOffset (), currentKey .getQualifierLength (), currentKey .getTimestamp (),
246
- currentKey .getTypeByte (), valAndTagsBuffer .array (),
247
- valAndTagsBuffer .arrayOffset () + vOffset , this .valueLength , memstoreTS , tagsArray , tOffset ,
248
- this .tagsLength );
247
+ currentKey .getTypeByte (), Bytes . copy ( valAndTagsBuffer .array (),
248
+ valAndTagsBuffer .arrayOffset () + vOffset , this .valueLength ) ,
249
+ 0 , this . valueLength , memstoreTS , tagsArray , tOffset , this .tagsLength );
249
250
}
250
251
251
252
private Cell toOffheapCell (ByteBuffer valAndTagsBuffer , int vOffset ,
@@ -254,13 +255,26 @@ private Cell toOffheapCell(ByteBuffer valAndTagsBuffer, int vOffset,
254
255
int tOffset = 0 ;
255
256
if (this .includeTags ) {
256
257
if (this .tagCompressionContext == null ) {
257
- tagsBuf = valAndTagsBuffer ;
258
258
tOffset = vOffset + this .valueLength + tagsLenSerializationSize ;
259
+ byte [] output = new byte [this .tagsLength ];
260
+ ByteBufferUtils .copyFromBufferToArray (output , valAndTagsBuffer , tOffset , 0 ,
261
+ this .tagsLength );
262
+ tagsBuf = ByteBuffer .wrap (output );
263
+ tOffset = 0 ;
259
264
} else {
260
265
tagsBuf = ByteBuffer .wrap (Bytes .copy (tagsBuffer , 0 , this .tagsLength ));
261
266
tOffset = 0 ;
262
267
}
263
268
}
269
+
270
+ if (this .valueLength > 0 ) {
271
+ byte [] output = new byte [this .valueLength ];
272
+ ByteBufferUtils .copyFromBufferToArray (output , valAndTagsBuffer , vOffset , 0 ,
273
+ this .valueLength );
274
+ valAndTagsBuffer = ByteBuffer .wrap (output );
275
+ vOffset = 0 ;
276
+ }
277
+
264
278
return new OffheapDecodedExtendedCell (
265
279
ByteBuffer .wrap (Bytes .copy (keyBuffer , 0 , this .keyLength )), currentKey .getRowLength (),
266
280
currentKey .getFamilyOffset (), currentKey .getFamilyLength (), currentKey .getQualifierOffset (),
0 commit comments