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