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