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.hbase.classification.InterfaceAudience;
23 import org.apache.hadoop.hbase.io.hfile.HFileContext;
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    * Perform all actions that need to be done before the encoder's real decoding process.
36    * Decompression needs to be done if {@link HFileContext#getCompression()} returns a valid compression
37    * algorithm.
38    *
39    * @param onDiskSizeWithoutHeader numBytes after block and encoding headers
40    * @param uncompressedSizeWithoutHeader numBytes without header required to store the block after
41    *          decompressing (not decoding)
42    * @param blockBufferWithoutHeader ByteBuffer pointed after the header but before the data
43    * @param onDiskBlock on disk data to be decoded
44    * @throws IOException
45    */
prepareDecoding( int onDiskSizeWithoutHeader, int uncompressedSizeWithoutHeader, ByteBuffer blockBufferWithoutHeader, ByteBuffer onDiskBlock )46   void prepareDecoding(
47     int onDiskSizeWithoutHeader,
48     int uncompressedSizeWithoutHeader,
49     ByteBuffer blockBufferWithoutHeader,
50     ByteBuffer onDiskBlock
51   ) throws IOException;
52 
53   /**
54    * @return HFile meta information
55    */
getHFileContext()56   HFileContext getHFileContext();
57 }
58