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; 019 020import java.io.IOException; 021 022import org.apache.yetus.audience.InterfaceAudience; 023 024/** 025 * An interface for iterating through a sequence of cells. Similar to Java's Iterator, but without 026 * the hasNext() or remove() methods. The hasNext() method is problematic because it may require 027 * actually loading the next object, which in turn requires storing the previous object somewhere. 028 * 029 * <p>The core data block decoder should be as fast as possible, so we push the complexity and 030 * performance expense of concurrently tracking multiple cells to layers above the CellScanner. 031 * <p> 032 * The {@link #current()} method will return a reference to a Cell implementation. This reference 033 * may or may not point to a reusable cell implementation, so users of the CellScanner should not, 034 * for example, accumulate a List of Cells. All of the references may point to the same object, 035 * which would be the latest state of the underlying Cell. In short, the Cell is mutable. 036 * </p> 037 * Typical usage: 038 * 039 * <pre> 040 * while (scanner.advance()) { 041 * Cell cell = scanner.current(); 042 * // do something 043 * } 044 * </pre> 045 * <p>Often used reading {@link org.apache.hadoop.hbase.Cell}s written by 046 * {@link org.apache.hadoop.hbase.io.CellOutputStream}. 047 */ 048@InterfaceAudience.Public 049public interface CellScanner { 050 /** 051 * @return the current Cell which may be mutable 052 */ 053 Cell current(); 054 055 /** 056 * Advance the scanner 1 cell. 057 * @return true if the next cell is found and {@link #current()} will return a valid Cell 058 * @throws IOException if advancing the scanner fails 059 */ 060 boolean advance() throws IOException; 061}