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 */ 018 019package org.apache.hadoop.hbase.io; 020 021import java.io.IOException; 022 023import org.apache.hadoop.hbase.Cell; 024import org.apache.yetus.audience.InterfaceAudience; 025import org.apache.yetus.audience.InterfaceStability; 026 027/** 028 * Accepts a stream of Cells. This can be used to build a block of cells during compactions 029 * and flushes, or to build a byte[] to send to the client. This could be backed by a 030 * List<KeyValue>, but more efficient implementations will append results to a 031 * byte[] to eliminate overhead, and possibly encode the cells further. 032 * <p>To read Cells, use {@link org.apache.hadoop.hbase.CellScanner} 033 * @see org.apache.hadoop.hbase.CellScanner 034 */ 035@InterfaceAudience.Private 036@InterfaceStability.Evolving 037public interface CellOutputStream { 038 /** 039 * Implementation must copy the entire state of the Cell. If the written Cell is modified 040 * immediately after the write method returns, the modifications must have absolutely no effect 041 * on the copy of the Cell that was added in the write. 042 * @param cell Cell to write out 043 * @throws IOException 044 */ 045 void write(Cell cell) throws IOException; 046 047 /** 048 * Let the implementation decide what to do. Usually means writing accumulated data into a 049 * byte[] that can then be read from the implementation to be sent to disk, put in the block 050 * cache, or sent over the network. 051 * @throws IOException 052 */ 053 void flush() throws IOException; 054}