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.hbase.io.compress.Compression;
23  
24  /**
25   * A decoding context that is created by a reader's encoder, and is shared
26   * across the reader's all read operations.
27   *
28   * @see HFileBlockEncodingContext for encoding
29   */
30  public interface HFileBlockDecodingContext {
31  
32    /**
33     * @return the compression algorithm used by this decoding context
34     */
35    Compression.Algorithm getCompression();
36  
37    /**
38     * Perform all actions that need to be done before the encoder's real decoding process.
39     * Decompression needs to be done if {@link #getCompression()} returns a valid compression
40     * algorithm.
41     *
42     * @param onDiskSizeWithoutHeader numBytes after block and encoding headers
43     * @param uncompressedSizeWithoutHeader numBytes without header required to store the block after
44     *          decompressing (not decoding)
45     * @param blockBufferWithoutHeader ByteBuffer pointed after the header but before the data
46     * @param onDiskBlock on disk bytes to be decoded
47     * @param offset data start offset in onDiskBlock
48     * @throws IOException
49     */
50    void prepareDecoding(
51      int onDiskSizeWithoutHeader,
52      int uncompressedSizeWithoutHeader,
53      ByteBuffer blockBufferWithoutHeader,
54      byte[] onDiskBlock,
55      int offset
56    ) throws IOException;
57  
58  }