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