Skip to content

Commit

Permalink
Revert "HBASE-26856:BufferedDataBlockEncoder.OnheapDecodedCell value …
Browse files Browse the repository at this point in the history
…can get corrupted (apache#4394)"

This reverts commit c198f23.
  • Loading branch information
ndimiduk committed May 18, 2022
1 parent b787648 commit f5fd353
Showing 1 changed file with 5 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,9 @@ private Cell toOnheapCell(ByteBuffer valAndTagsBuffer, int vOffset,
int tOffset = 0;
if (this.includeTags) {
if (this.tagCompressionContext == null) {
tagsArray = valAndTagsBuffer.array();
tOffset =
valAndTagsBuffer.arrayOffset() + vOffset + this.valueLength + tagsLenSerializationSize;
tagsArray = Bytes.copy(valAndTagsBuffer.array(), tOffset, this.tagsLength);
tOffset = 0;
} else {
tagsArray = Bytes.copy(tagsBuffer, 0, this.tagsLength);
tOffset = 0;
Expand All @@ -244,8 +243,9 @@ private Cell toOnheapCell(ByteBuffer valAndTagsBuffer, int vOffset,
return new OnheapDecodedCell(Bytes.copy(keyBuffer, 0, this.keyLength),
currentKey.getRowLength(), currentKey.getFamilyOffset(), currentKey.getFamilyLength(),
currentKey.getQualifierOffset(), currentKey.getQualifierLength(), currentKey.getTimestamp(),
currentKey.getTypeByte(), Bytes.copy(valAndTagsBuffer.array(), valAndTagsBuffer.arrayOffset() + vOffset,
this.valueLength), 0, this.valueLength, memstoreTS, tagsArray, tOffset, this.tagsLength);
currentKey.getTypeByte(), valAndTagsBuffer.array(),
valAndTagsBuffer.arrayOffset() + vOffset, this.valueLength, memstoreTS, tagsArray, tOffset,
this.tagsLength);
}

private Cell toOffheapCell(ByteBuffer valAndTagsBuffer, int vOffset,
Expand All @@ -254,26 +254,13 @@ private Cell toOffheapCell(ByteBuffer valAndTagsBuffer, int vOffset,
int tOffset = 0;
if (this.includeTags) {
if (this.tagCompressionContext == null) {
tagsBuf = valAndTagsBuffer;
tOffset = vOffset + this.valueLength + tagsLenSerializationSize;
byte[] output = new byte[this.tagsLength];
ByteBufferUtils.copyFromBufferToArray(output, valAndTagsBuffer, tOffset, 0,
this.tagsLength);
tagsBuf = ByteBuffer.wrap(output);
tOffset = 0;
} else {
tagsBuf = ByteBuffer.wrap(Bytes.copy(tagsBuffer, 0, this.tagsLength));
tOffset = 0;
}
}

if (this.valueLength > 0) {
byte[] output = new byte[this.valueLength];
ByteBufferUtils.copyFromBufferToArray(output, valAndTagsBuffer, vOffset, 0,
this.valueLength);
valAndTagsBuffer = ByteBuffer.wrap(output);
vOffset = 0;
}

return new OffheapDecodedExtendedCell(
ByteBuffer.wrap(Bytes.copy(keyBuffer, 0, this.keyLength)), currentKey.getRowLength(),
currentKey.getFamilyOffset(), currentKey.getFamilyLength(), currentKey.getQualifierOffset(),
Expand Down

0 comments on commit f5fd353

Please sign in to comment.