From 7c4f7367dd5ca30c322a0a25368f3d439ba2d378 Mon Sep 17 00:00:00 2001 From: xianjing feng <583872483@qq.com> Date: Sat, 14 May 2022 12:38:15 +0800 Subject: [PATCH] HBASE-27034 NegativeArraySizeException was encountered during compaction --- .../apache/hadoop/hbase/io/hfile/HFileWriterImpl.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileWriterImpl.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileWriterImpl.java index 9170cbef4e7..11489729d65 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileWriterImpl.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileWriterImpl.java @@ -550,7 +550,7 @@ public class HFileWriterImpl implements HFile.Writer { blockWriter.startWriting(BlockType.DATA); firstCellInBlock = null; if (lastCell != null) { - lastCellOfPreviousBlock = lastCell; + lastCellOfPreviousBlock = KeyValueUtil.toNewKeyCell(lastCell); } } @@ -728,7 +728,7 @@ public class HFileWriterImpl implements HFile.Writer { if (firstCellInBlock == null) { // If cell is big, block will be closed and this firstCellInBlock reference will only last // a short while. - firstCellInBlock = cell; + firstCellInBlock = KeyValueUtil.toNewKeyCell(cell); } // TODO: What if cell is 10MB and we write infrequently? We hold on to cell here indefinitely? @@ -748,12 +748,6 @@ public class HFileWriterImpl implements HFile.Writer { if (this.lastCell != null) { this.lastCell = KeyValueUtil.toNewKeyCell(this.lastCell); } - if (this.firstCellInBlock != null) { - this.firstCellInBlock = KeyValueUtil.toNewKeyCell(this.firstCellInBlock); - } - if (this.lastCellOfPreviousBlock != null) { - this.lastCellOfPreviousBlock = KeyValueUtil.toNewKeyCell(this.lastCellOfPreviousBlock); - } } public Cell getLastCell() {