From 34f644095fc20344c2916f5d2ca0834254a09f76 Mon Sep 17 00:00:00 2001 From: Wellington Ramos Chevreuil Date: Fri, 23 Sep 2022 10:33:27 +0100 Subject: [PATCH] HBASE-27386 Use encoded size for calculating compression ratio in block size predicator (#4795) Signed-off-by: Ankit Singhal --- .../java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java | 2 +- .../org/apache/hadoop/hbase/regionserver/TestHStoreFile.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java index f57e27b3a4c7..a067e50f30a4 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java @@ -933,7 +933,7 @@ private void finishBlock() throws IOException { // We need to cache the unencoded/uncompressed size before changing the block state int rawBlockSize = 0; if (this.getEncodingState() != null) { - rawBlockSize = blockSizeWritten(); + rawBlockSize = encodedBlockSizeWritten(); } // We need to set state before we can package the block up for cache-on-write. In a way, the // block is ready, but not yet encoded or compressed. diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStoreFile.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStoreFile.java index d617492e86d8..fa41768084fa 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStoreFile.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStoreFile.java @@ -1216,8 +1216,8 @@ public void testDataBlockSizeEncoded() throws Exception { public void testDataBlockSizeCompressed() throws Exception { conf.set(BLOCK_COMPRESSED_SIZE_PREDICATOR, PreviousBlockCompressionRatePredicator.class.getName()); - testDataBlockSizeWithCompressionRatePredicator(11, - (s, c) -> (c > 1 && c < 11) ? s >= BLOCKSIZE_SMALL * 10 : true); + testDataBlockSizeWithCompressionRatePredicator(12, + (s, c) -> (c > 2 && c < 11) ? s >= BLOCKSIZE_SMALL * 10 : true); } @Test