001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with this
004 * work for additional information regarding copyright ownership. The ASF
005 * licenses this file to you under the Apache License, Version 2.0 (the
006 * "License"); you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
014 * License for the specific language governing permissions and limitations
015 * under the License.
016 */
017package org.apache.hadoop.hbase.io.encoding;
018
019import java.io.IOException;
020
021import org.apache.hadoop.hbase.io.hfile.HFileContext;
022import org.apache.hadoop.hbase.nio.ByteBuff;
023import org.apache.yetus.audience.InterfaceAudience;
024
025/**
026 * A decoding context that is created by a reader's encoder, and is shared
027 * across the reader's all read operations.
028 *
029 * @see HFileBlockEncodingContext for encoding
030 */
031@InterfaceAudience.Private
032public interface HFileBlockDecodingContext {
033
034  /**
035   * Perform all actions that need to be done before the encoder's real decoding
036   * process. Decompression needs to be done if
037   * {@link HFileContext#getCompression()} returns a valid compression
038   * algorithm.
039   *
040   * @param onDiskSizeWithoutHeader
041   *          numBytes after block and encoding headers
042   * @param uncompressedSizeWithoutHeader
043   *          numBytes without header required to store the block after
044   *          decompressing (not decoding)
045   * @param blockBufferWithoutHeader
046   *          ByteBuffer pointed after the header but before the data
047   * @param onDiskBlock
048   *          on disk data to be decoded
049   * @throws IOException
050   */
051  void prepareDecoding(
052    int onDiskSizeWithoutHeader,
053    int uncompressedSizeWithoutHeader,
054    ByteBuff blockBufferWithoutHeader,
055    ByteBuff onDiskBlock
056  ) throws IOException;
057
058  /**
059   * @return HFile meta information
060   */
061  HFileContext getHFileContext();
062}