Class TestHFileBlockUnpack

java.lang.Object
org.apache.hadoop.hbase.io.hfile.TestHFileBlockUnpack

@Tag("org.apache.hadoop.hbase.testclassification.IOTests") @Tag("org.apache.hadoop.hbase.testclassification.MediumTests") public class TestHFileBlockUnpack extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • setUp

      @BeforeEach public void setUp() throws Exception
      Throws:
      Exception
    • itUnpacksIdenticallyEachTime

      @Test public void itUnpacksIdenticallyEachTime(org.junit.jupiter.api.TestInfo testInfo) throws IOException
      It's important that if you read and unpack the same HFileBlock twice, it results in an identical buffer each time. Otherwise we end up with validation failures in block cache, since contents may not match if the same block is cached twice. See https://issues.apache.org/jira/browse/HBASE-27053
      Throws:
      IOException
    • assertBuffersEqual

      private void assertBuffersEqual(org.apache.hadoop.hbase.nio.ByteBuff bufferOne, org.apache.hadoop.hbase.nio.ByteBuff bufferTwo, int expectedSize)
    • itUsesSharedMemoryIfUnpackedBlockExceedsMinAllocationSize

      @Test public void itUsesSharedMemoryIfUnpackedBlockExceedsMinAllocationSize(org.junit.jupiter.api.TestInfo testInfo) throws IOException
      If the block on disk size is less than ByteBuffAllocator's min allocation size, that block will be allocated to heap regardless of desire for off-heap. After de-compressing the block, the new size may now exceed the min allocation size. This test ensures that those de-compressed blocks, which will be allocated off-heap, are properly marked as HFileBlock.isSharedMem() == true See https://issues.apache.org/jira/browse/HBASE-27170
      Throws:
      IOException
    • readBlock

      private TestHFileBlockUnpack.HFileBlockWrapper readBlock(org.apache.hadoop.fs.Path path, int totalSize) throws IOException
      Throws:
      IOException
    • createTestBlock

      private int createTestBlock(org.apache.hadoop.fs.Path path) throws IOException
      Throws:
      IOException
    • writeTestKeyValues

      static int writeTestKeyValues(org.apache.hadoop.hbase.io.hfile.HFileBlock.Writer hbw, int desiredSize) throws IOException
      Throws:
      IOException
    • maybeIncrement

      private static int maybeIncrement(Random random, int value)