View Javadoc

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.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 bytes to be decoded
44     * @param offset data start offset in onDiskBlock
45     * @throws IOException
46     */
47    void prepareDecoding(
48      int onDiskSizeWithoutHeader,
49      int uncompressedSizeWithoutHeader,
50      ByteBuffer blockBufferWithoutHeader,
51      byte[] onDiskBlock,
52      int offset
53    ) throws IOException;
54  
55    /**
56     * @return HFile meta information
57     */
58    HFileContext getHFileContext();
59  }