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.hbase.classification.InterfaceAudience; 25 import org.apache.hadoop.hbase.classification.InterfaceStability; 26 import org.apache.hadoop.hbase.Cell; 27 import org.apache.hadoop.hbase.HBaseInterfaceAudience; 28 import org.apache.hadoop.hbase.HRegionInfo; 29 import org.apache.hadoop.hbase.client.Scan; 30 31 /** 32 * RegionScanner describes iterators over rows in an HRegion. 33 */ 34 @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC) 35 @InterfaceStability.Stable 36 public interface RegionScanner extends InternalScanner { 37 /** 38 * @return The RegionInfo for this scanner. 39 */ 40 HRegionInfo getRegionInfo(); 41 42 /** 43 * @return True if a filter indicates that this scanner will return no further rows. 44 * @throws IOException in case of I/O failure on a filter. 45 */ 46 boolean isFilterDone() throws IOException; 47 48 /** 49 * Do a reseek to the required row. Should not be used to seek to a key which 50 * may come before the current position. Always seeks to the beginning of a 51 * row boundary. 52 * 53 * @throws IOException 54 * @throws IllegalArgumentException 55 * if row is null 56 * 57 */ 58 boolean reseek(byte[] row) throws IOException; 59 60 /** 61 * @return The preferred max buffersize. See {@link Scan#setMaxResultSize(long)} 62 */ 63 long getMaxResultSize(); 64 65 /** 66 * @return The Scanner's MVCC readPt see {@link MultiVersionConsistencyControl} 67 */ 68 long getMvccReadPoint(); 69 70 /** 71 * Grab the next row's worth of values with the default limit on the number of values 72 * to return. 73 * This is a special internal method to be called from coprocessor hooks to avoid expensive setup. 74 * Caller must set the thread's readpoint, start and close a region operation, an synchronize on the scanner object. 75 * Caller should maintain and update metrics. 76 * See {@link #nextRaw(List, int)} 77 * @param result return output array 78 * @return true if more rows exist after this one, false if scanner is done 79 * @throws IOException e 80 */ 81 boolean nextRaw(List<Cell> result) throws IOException; 82 83 /** 84 * Grab the next row's worth of values with a limit on the number of values 85 * to return. 86 * This is a special internal method to be called from coprocessor hooks to avoid expensive setup. 87 * Caller must set the thread's readpoint, start and close a region operation, an synchronize on the scanner object. 88 * Example: 89 * <code><pre> 90 * HRegion region = ...; 91 * RegionScanner scanner = ... 92 * MultiVersionConsistencyControl.setThreadReadPoint(scanner.getMvccReadPoint()); 93 * region.startRegionOperation(); 94 * try { 95 * synchronized(scanner) { 96 * ... 97 * boolean moreRows = scanner.nextRaw(values); 98 * ... 99 * } 100 * } finally { 101 * region.closeRegionOperation(); 102 * } 103 * </pre></code> 104 * @param result return output array 105 * @param limit limit on row count to get 106 * @return true if more rows exist after this one, false if scanner is done 107 * @throws IOException e 108 */ 109 boolean nextRaw(List<Cell> result, int limit) throws IOException; 110 }