Java Code Examples for org.apache.hadoop.hbase.HConstants#HFILEBLOCK_HEADER_SIZE_NO_CHECKSUM

The following examples show how to use org.apache.hadoop.hbase.HConstants#HFILEBLOCK_HEADER_SIZE_NO_CHECKSUM . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestHFileDataBlockEncoder.java    From hbase with Apache License 2.0 6 votes vote down vote up
private void testHeaderSizeInCacheWithoutChecksumInternals(boolean useTags) throws IOException {
  int headerSize = HConstants.HFILEBLOCK_HEADER_SIZE_NO_CHECKSUM;
  // Create some KVs and create the block with old-style header.
  List<KeyValue> kvs = generator.generateTestKeyValues(60, useTags);
  ByteBuffer keyValues = RedundantKVGenerator.convertKvToByteBuffer(kvs, includesMemstoreTS);
  int size = keyValues.limit();
  ByteBuffer buf = ByteBuffer.allocate(size + headerSize);
  buf.position(headerSize);
  keyValues.rewind();
  buf.put(keyValues);
  HFileContext hfileContext = new HFileContextBuilder().withHBaseCheckSum(false)
                      .withIncludesMvcc(includesMemstoreTS)
                      .withIncludesTags(useTags)
                      .withBlockSize(0)
                      .withChecksumType(ChecksumType.NULL)
                      .build();
  HFileBlock block = new HFileBlock(BlockType.DATA, size, size, -1, ByteBuff.wrap(buf),
      HFileBlock.FILL_HEADER, 0, 0, -1, hfileContext, ByteBuffAllocator.HEAP);
  HFileBlock cacheBlock = createBlockOnDisk(kvs, block, useTags);
  assertEquals(headerSize, cacheBlock.getDummyHeaderForVersion().length);
}
 
Example 2
Source File: HFileBlock.java    From hbase with Apache License 2.0 4 votes vote down vote up
/**
 * Maps a minor version to the size of the header.
 */
public static int headerSize(boolean usesHBaseChecksum) {
  return usesHBaseChecksum?
      HConstants.HFILEBLOCK_HEADER_SIZE: HConstants.HFILEBLOCK_HEADER_SIZE_NO_CHECKSUM;
}