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.client; 019 020import static org.apache.hadoop.hbase.client.ConnectionUtils.noMoreResultsForReverseScan; 021 022import java.io.IOException; 023import java.util.Map; 024import java.util.concurrent.ExecutorService; 025import org.apache.hadoop.conf.Configuration; 026import org.apache.hadoop.hbase.TableName; 027import org.apache.hadoop.hbase.ipc.RpcControllerFactory; 028import org.apache.yetus.audience.InterfaceAudience; 029 030/** 031 * A reversed client scanner which support backward scanning 032 */ 033@InterfaceAudience.Private 034public class ReversedClientScanner extends ClientScanner { 035 036 /** 037 * Create a new ReversibleClientScanner for the specified table Note that the passed 038 * {@link Scan}'s start row maybe changed. 039 */ 040 public ReversedClientScanner(Configuration conf, Scan scan, Scan scanForMetrics, 041 TableName tableName, ClusterConnection connection, RpcRetryingCallerFactory rpcFactory, 042 RpcControllerFactory controllerFactory, ExecutorService pool, int scanReadRpcTimeout, 043 int scannerTimeout, int primaryOperationTimeout, 044 ConnectionConfiguration connectionConfiguration, Map<String, byte[]> requestAttributes) 045 throws IOException { 046 super(conf, scan, scanForMetrics, tableName, connection, rpcFactory, controllerFactory, pool, 047 scanReadRpcTimeout, scannerTimeout, primaryOperationTimeout, connectionConfiguration, 048 requestAttributes); 049 } 050 051 @Override 052 protected boolean setNewStartKey() { 053 if (noMoreResultsForReverseScan(scan, currentRegion)) { 054 return false; 055 } 056 scan.withStartRow(currentRegion.getStartKey(), false); 057 return true; 058 } 059 060 @Override 061 protected ReversedScannerCallable createScannerCallable() { 062 return new ReversedScannerCallable(getConnection(), getTable(), scan, this.scanMetrics, 063 this.rpcControllerFactory, getScanReplicaId(), requestAttributes); 064 } 065}