001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.io;
019
020import java.io.IOException;
021import org.apache.hadoop.hbase.Cell;
022import org.apache.yetus.audience.InterfaceAudience;
023import org.apache.yetus.audience.InterfaceStability;
024
025/**
026 * Accepts a stream of Cells. This can be used to build a block of cells during compactions and
027 * flushes, or to build a byte[] to send to the client. This could be backed by a
028 * List<KeyValue>, but more efficient implementations will append results to a byte[] to
029 * eliminate overhead, and possibly encode the cells further.
030 * <p>
031 * To read Cells, use {@link org.apache.hadoop.hbase.CellScanner}
032 * @see org.apache.hadoop.hbase.CellScanner
033 */
034@InterfaceAudience.Private
035@InterfaceStability.Evolving
036public interface CellOutputStream {
037  /**
038   * Implementation must copy the entire state of the Cell. If the written Cell is modified
039   * immediately after the write method returns, the modifications must have absolutely no effect on
040   * the copy of the Cell that was added in the write.
041   * @param cell Cell to write out n
042   */
043  void write(Cell cell) throws IOException;
044
045  /**
046   * Let the implementation decide what to do. Usually means writing accumulated data into a byte[]
047   * that can then be read from the implementation to be sent to disk, put in the block cache, or
048   * sent over the network. n
049   */
050  void flush() throws IOException;
051}