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.createClosestRowAfter; 021import static org.apache.hadoop.hbase.client.ConnectionUtils.isEmptyStartRow; 022import static org.apache.hadoop.hbase.client.ConnectionUtils.noMoreResultsForScan; 023 024import java.io.IOException; 025import java.util.concurrent.ExecutorService; 026import org.apache.hadoop.conf.Configuration; 027import org.apache.hadoop.hbase.TableName; 028import org.apache.hadoop.hbase.ipc.RpcControllerFactory; 029import org.apache.yetus.audience.InterfaceAudience; 030 031/** 032 * ClientSimpleScanner implements a sync scanner behaviour. The cache is a simple list. The prefetch 033 * is invoked only when the application finished processing the entire cache. 034 */ 035@InterfaceAudience.Private 036public class ClientSimpleScanner extends ClientScanner { 037 public ClientSimpleScanner(Configuration configuration, Scan scan, TableName name, 038 ClusterConnection connection, RpcRetryingCallerFactory rpcCallerFactory, 039 RpcControllerFactory rpcControllerFactory, ExecutorService pool, int scanReadRpcTimeout, 040 int scannerTimeout, int replicaCallTimeoutMicroSecondScan) throws IOException { 041 super(configuration, scan, name, connection, rpcCallerFactory, rpcControllerFactory, pool, 042 scanReadRpcTimeout, scannerTimeout, replicaCallTimeoutMicroSecondScan); 043 } 044 045 @Override 046 protected boolean setNewStartKey() { 047 if (noMoreResultsForScan(scan, currentRegion)) { 048 return false; 049 } 050 scan.withStartRow(currentRegion.getEndKey(), true); 051 return true; 052 } 053 054 @Override 055 protected ScannerCallable createScannerCallable() { 056 if (!scan.includeStartRow() && !isEmptyStartRow(scan.getStartRow())) { 057 // we have not implemented locate to next row for sync client yet, so here we change the 058 // inclusive of start row to true. 059 scan.withStartRow(createClosestRowAfter(scan.getStartRow()), true); 060 } 061 return new ScannerCallable(getConnection(), getTable(), scan, this.scanMetrics, 062 this.rpcControllerFactory, getScanReplicaId()); 063 } 064}