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