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 * Caller should maintain and update metrics. 73 * See {@link #nextRaw(List, int)} 74 * @param result return output array 75 * @return true if more rows exist after this one, false if scanner is done 76 * @throws IOException e 77 */ 78 boolean nextRaw(List<Cell> result) throws IOException; 79 80 /** 81 * Grab the next row's worth of values with a limit on the number of values 82 * to return. 83 * This is a special internal method to be called from coprocessor hooks to avoid expensive setup. 84 * Caller must set the thread's readpoint, start and close a region operation, an synchronize on the scanner object. 85 * Example: 86 * <code><pre> 87 * HRegion region = ...; 88 * RegionScanner scanner = ... 89 * MultiVersionConsistencyControl.setThreadReadPoint(scanner.getMvccReadPoint()); 90 * region.startRegionOperation(); 91 * try { 92 * synchronized(scanner) { 93 * ... 94 * boolean moreRows = scanner.nextRaw(values); 95 * ... 96 * } 97 * } finally { 98 * region.closeRegionOperation(); 99 * } 100 * </pre></code> 101 * @param result return output array 102 * @param limit limit on row count to get 103 * @return true if more rows exist after this one, false if scanner is done 104 * @throws IOException e 105 */ 106 boolean nextRaw(List<Cell> result, int limit) throws IOException; 107 }