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