1 /** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 package org.apache.hadoop.hbase.regionserver; 20 21 import java.io.IOException; 22 import java.util.List; 23 24 import org.apache.hadoop.classification.InterfaceAudience; 25 import org.apache.hadoop.hbase.Cell; 26 import org.apache.hadoop.hbase.HRegionInfo; 27 import org.apache.hadoop.hbase.client.Scan; 28 29 /** 30 * RegionScanner describes iterators over rows in an HRegion. 31 */ 32 @InterfaceAudience.Private 33 public interface RegionScanner extends InternalScanner { 34 /** 35 * @return The RegionInfo for this scanner. 36 */ 37 HRegionInfo getRegionInfo(); 38 39 /** 40 * @return True if a filter indicates that this scanner will return no further rows. 41 * @throws IOException in case of I/O failure on a filter. 42 */ 43 boolean isFilterDone() throws IOException; 44 45 /** 46 * Do a reseek to the required row. Should not be used to seek to a key which 47 * may come before the current position. Always seeks to the beginning of a 48 * row boundary. 49 * 50 * @throws IOException 51 * @throws IllegalArgumentException 52 * if row is null 53 * 54 */ 55 boolean reseek(byte[] row) throws IOException; 56 57 /** 58 * @return The preferred max buffersize. See {@link Scan#setMaxResultSize(long)} 59 */ 60 long getMaxResultSize(); 61 62 /** 63 * @return The Scanner's MVCC readPt see {@link MultiVersionConsistencyControl} 64 */ 65 long getMvccReadPoint(); 66 67 /** 68 * Grab the next row's worth of values with the default limit on the number of values 69 * to return. 70 * This is a special internal method to be called from coprocessor hooks to avoid expensive setup. 71 * Caller must set the thread's readpoint, start and close a region operation, an synchronize on the scanner object. 72 * See {@link #nextRaw(List, int)} 73 * @param result return output array 74 * @return true if more rows exist after this one, false if scanner is done 75 * @throws IOException e 76 */ 77 boolean nextRaw(List<Cell> result) throws IOException; 78 79 /** 80 * Grab the next row's worth of values with a limit on the number of values 81 * to return. 82 * This is a special internal method to be called from coprocessor hooks to avoid expensive setup. 83 * Caller must set the thread's readpoint, start and close a region operation, an synchronize on the scanner object. 84 * Example: 85 * <code><pre> 86 * HRegion region = ...; 87 * RegionScanner scanner = ... 88 * MultiVersionConsistencyControl.setThreadReadPoint(scanner.getMvccReadPoint()); 89 * region.startRegionOperation(); 90 * try { 91 * synchronized(scanner) { 92 * ... 93 * boolean moreRows = scanner.nextRaw(values); 94 * ... 95 * } 96 * } finally { 97 * region.closeRegionOperation(); 98 * } 99 * </pre></code> 100 * @param result return output array 101 * @param limit limit on row count to get 102 * @return true if more rows exist after this one, false if scanner is done 103 * @throws IOException e 104 */ 105 boolean nextRaw(List<Cell> result, int limit) throws IOException; 106 }