View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.hadoop.hbase.client;
19  
20  import static org.apache.hadoop.hbase.client.ConnectionUtils.createClosestRowAfter;
21  import static org.apache.hadoop.hbase.client.ConnectionUtils.isEmptyStartRow;
22  import static org.apache.hadoop.hbase.client.ConnectionUtils.noMoreResultsForScan;
23  
24  import java.io.IOException;
25  import java.util.concurrent.ExecutorService;
26  
27  import org.apache.hadoop.conf.Configuration;
28  import org.apache.hadoop.hbase.TableName;
29  import org.apache.hadoop.hbase.classification.InterfaceAudience;
30  import org.apache.hadoop.hbase.ipc.RpcControllerFactory;
31  
32  /**
33   * ClientSimpleScanner implements a sync scanner behaviour. The cache is a simple list. The prefetch
34   * is invoked only when the application finished processing the entire cache.
35   */
36  @InterfaceAudience.Private
37  public class ClientSimpleScanner extends ClientScanner {
38    public ClientSimpleScanner(Configuration configuration, Scan scan, TableName name,
39        ClusterConnection connection, RpcRetryingCallerFactory rpcCallerFactory,
40        RpcControllerFactory rpcControllerFactory, ExecutorService pool,
41        int replicaCallTimeoutMicroSecondScan) throws IOException {
42      super(configuration, scan, name, connection, rpcCallerFactory, rpcControllerFactory, pool,
43          replicaCallTimeoutMicroSecondScan);
44    }
45  
46    @Override
47    protected boolean setNewStartKey() {
48      if (noMoreResultsForScan(scan, currentRegion)) {
49        return false;
50      }
51      scan.withStartRow(currentRegion.getEndKey(), true);
52      return true;
53    }
54  
55    @Override
56    protected ScannerCallable createScannerCallable() {
57      if (!scan.includeStartRow() && !isEmptyStartRow(scan.getStartRow())) {
58        // we have not implemented locate to next row for sync client yet, so here we change the
59        // inclusive of start row to true.
60        scan.withStartRow(createClosestRowAfter(scan.getStartRow()), true);
61      }
62      return new ScannerCallable(getConnection(), getTable(), scan, this.scanMetrics,
63          this.rpcControllerFactory);
64    }
65  }