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