1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with this 4 * work for additional information regarding copyright ownership. The ASF 5 * licenses this file to you under the Apache License, Version 2.0 (the 6 * "License"); you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 * License for the specific language governing permissions and limitations 15 * under the License. 16 */ 17 package org.apache.hadoop.hbase.io.encoding; 18 19 import java.io.IOException; 20 import java.nio.ByteBuffer; 21 22 import org.apache.hadoop.classification.InterfaceAudience; 23 import org.apache.hadoop.hbase.io.compress.Compression; 24 25 /** 26 * A decoding context that is created by a reader's encoder, and is shared 27 * across the reader's all read operations. 28 * 29 * @see HFileBlockEncodingContext for encoding 30 */ 31 @InterfaceAudience.Private 32 public interface HFileBlockDecodingContext { 33 34 /** 35 * @return the compression algorithm used by this decoding context 36 */ 37 Compression.Algorithm getCompression(); 38 39 /** 40 * Perform all actions that need to be done before the encoder's real decoding process. 41 * Decompression needs to be done if {@link #getCompression()} returns a valid compression 42 * algorithm. 43 * 44 * @param onDiskSizeWithoutHeader numBytes after block and encoding headers 45 * @param uncompressedSizeWithoutHeader numBytes without header required to store the block after 46 * decompressing (not decoding) 47 * @param blockBufferWithoutHeader ByteBuffer pointed after the header but before the data 48 * @param onDiskBlock on disk bytes to be decoded 49 * @param offset data start offset in onDiskBlock 50 * @throws IOException 51 */ 52 void prepareDecoding( 53 int onDiskSizeWithoutHeader, 54 int uncompressedSizeWithoutHeader, 55 ByteBuffer blockBufferWithoutHeader, 56 byte[] onDiskBlock, 57 int offset 58 ) throws IOException; 59 60 }