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 21 import org.apache.hadoop.hbase.classification.InterfaceAudience; 22 import org.apache.hadoop.hbase.io.hfile.BlockType; 23 import org.apache.hadoop.hbase.io.hfile.HFileContext; 24 25 /** 26 * An encoding context that is created by a writer's encoder, and is shared 27 * across the writer's whole lifetime. 28 * 29 * @see HFileBlockDecodingContext for decoding 30 * 31 */ 32 @InterfaceAudience.Private 33 public interface HFileBlockEncodingContext { 34 35 /** 36 * @return the block type after encoding 37 */ 38 BlockType getBlockType(); 39 40 /** 41 * @return the {@link DataBlockEncoding} encoding used 42 */ 43 DataBlockEncoding getDataBlockEncoding(); 44 45 /** 46 * Do any action that needs to be performed after the encoding. 47 * Compression is also included if a non-null compression algorithm is used 48 * 49 * @param blockType 50 * @throws IOException 51 */ 52 void postEncoding(BlockType blockType) throws IOException; 53 54 /** 55 * Releases the resources used. 56 */ 57 void close(); 58 59 /** 60 * @return HFile context information 61 */ 62 HFileContext getHFileContext(); 63 64 /** 65 * Sets the encoding state. 66 * @param state 67 */ 68 void setEncodingState(EncodingState state); 69 70 /** 71 * @return the encoding state 72 */ 73 EncodingState getEncodingState(); 74 75 /** 76 * @param uncompressedBytesWithHeader encoded bytes with header 77 * @return Bytes with header which are ready to write out to disk. This is compressed and 78 * encrypted bytes applying the set compression algorithm and encryption. 79 */ 80 byte[] compressAndEncrypt(byte[] uncompressedBytesWithHeader) throws IOException; 81 }