View Javadoc

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.classification.InterfaceAudience;
24  import org.apache.hadoop.hbase.CellScanner;
25  import org.apache.hadoop.hbase.io.CellOutputStream;
26  import org.apache.hadoop.hbase.io.encoding.DataBlockEncoder;
27  
28  /**
29   * Encoder/Decoder for Cell.
30   *
31   * <p>Like {@link DataBlockEncoder} only Cell-based rather than KeyValue version 1 based
32   * and without presuming an hfile context.  Intent is an Interface that will work for hfile and
33   * rpc.
34   */
35  @InterfaceAudience.Private
36  public interface Codec {
37    // TODO: interfacing with {@link DataBlockEncoder}
38    /**
39     * Call flush when done.  Some encoders may not put anything on the stream until flush is called.
40     * On flush, let go of any resources used by the encoder.
41     */
42    interface Encoder extends CellOutputStream {}
43  
44    /**
45     * Implementations should implicitly clean up any resources allocated when the
46     * Decoder/CellScanner runs off the end of the cell block. Do this rather than require the user
47     * call close explicitly.
48     */
49    interface Decoder extends CellScanner {};
50  
51    Decoder getDecoder(InputStream is);
52    Encoder getEncoder(OutputStream os);
53  }