Search in sources :

Example 1 with HFileBlockDecodingContext

use of org.apache.hadoop.hbase.io.encoding.HFileBlockDecodingContext in project hbase by apache.

the class HFileBlock method unpack.

/**
   * Retrieves the decompressed/decrypted view of this block. An encoded block remains in its
   * encoded structure. Internal structures are shared between instances where applicable.
   */
HFileBlock unpack(HFileContext fileContext, FSReader reader) throws IOException {
    if (!fileContext.isCompressedOrEncrypted()) {
        // encryption details.
        return this;
    }
    HFileBlock unpacked = new HFileBlock(this);
    // allocates space for the decompressed block
    unpacked.allocateBuffer();
    HFileBlockDecodingContext ctx = blockType == BlockType.ENCODED_DATA ? reader.getBlockDecodingContext() : reader.getDefaultBlockDecodingContext();
    ByteBuff dup = this.buf.duplicate();
    dup.position(this.headerSize());
    dup = dup.slice();
    ctx.prepareDecoding(unpacked.getOnDiskSizeWithoutHeader(), unpacked.getUncompressedSizeWithoutHeader(), unpacked.getBufferWithoutHeader(), dup);
    return unpacked;
}
Also used : HFileBlockDecodingContext(org.apache.hadoop.hbase.io.encoding.HFileBlockDecodingContext) MultiByteBuff(org.apache.hadoop.hbase.nio.MultiByteBuff) SingleByteBuff(org.apache.hadoop.hbase.nio.SingleByteBuff) ByteBuff(org.apache.hadoop.hbase.nio.ByteBuff)

Aggregations

HFileBlockDecodingContext (org.apache.hadoop.hbase.io.encoding.HFileBlockDecodingContext)1 ByteBuff (org.apache.hadoop.hbase.nio.ByteBuff)1 MultiByteBuff (org.apache.hadoop.hbase.nio.MultiByteBuff)1 SingleByteBuff (org.apache.hadoop.hbase.nio.SingleByteBuff)1