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