1 /** 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 package org.apache.hadoop.hbase.codec; 19 20 import java.io.InputStream; 21 import java.io.OutputStream; 22 23 import org.apache.hadoop.hbase.CellScanner; 24 import org.apache.hadoop.hbase.io.CellOutputStream; 25 import org.apache.hadoop.hbase.io.encoding.DataBlockEncoder; 26 27 /** 28 * Encoder/Decoder for Cell. 29 * 30 * <p>Like {@link DataBlockEncoder} only Cell-based rather than KeyValue version 1 based 31 * and without presuming an hfile context. Intent is an Interface that will work for hfile and 32 * rpc. 33 */ 34 public interface Codec { 35 // TODO: interfacing with {@link DataBlockEncoder} 36 /** 37 * Call flush when done. Some encoders may not put anything on the stream until flush is called. 38 * On flush, let go of any resources used by the encoder. 39 */ 40 public interface Encoder extends CellOutputStream {} 41 42 /** 43 * Implementations should implicitly clean up any resources allocated when the 44 * Decoder/CellScanner runs off the end of the cell block. Do this rather than require the user 45 * call close explicitly. 46 */ 47 public interface Decoder extends CellScanner {}; 48 49 Decoder getDecoder(InputStream is); 50 Encoder getEncoder(OutputStream os); 51 }