All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.hadoop.hbase.client.ClientSimpleScanner Maven / Gradle / Ivy

There is a newer version: 3.0.0-beta-1
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.hadoop.hbase.client;

import static org.apache.hadoop.hbase.client.ConnectionUtils.createClosestRowAfter;
import static org.apache.hadoop.hbase.client.ConnectionUtils.isEmptyStartRow;
import static org.apache.hadoop.hbase.client.ConnectionUtils.noMoreResultsForScan;

import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.ipc.RpcControllerFactory;
import org.apache.yetus.audience.InterfaceAudience;

/**
 * ClientSimpleScanner implements a sync scanner behaviour. The cache is a simple list. The prefetch
 * is invoked only when the application finished processing the entire cache.
 */
@InterfaceAudience.Private
public class ClientSimpleScanner extends ClientScanner {
  public ClientSimpleScanner(Configuration configuration, Scan scan, Scan scanForMetrics,
    TableName name, ClusterConnection connection, RpcRetryingCallerFactory rpcCallerFactory,
    RpcControllerFactory rpcControllerFactory, ExecutorService pool, int scanReadRpcTimeout,
    int scannerTimeout, int replicaCallTimeoutMicroSecondScan,
    ConnectionConfiguration connectionConfiguration, Map requestAttributes)
    throws IOException {
    super(configuration, scan, scanForMetrics, name, connection, rpcCallerFactory,
      rpcControllerFactory, pool, scanReadRpcTimeout, scannerTimeout,
      replicaCallTimeoutMicroSecondScan, connectionConfiguration, requestAttributes);
  }

  @Override
  protected boolean setNewStartKey() {
    if (noMoreResultsForScan(scan, currentRegion)) {
      return false;
    }
    scan.withStartRow(currentRegion.getEndKey(), true);
    return true;
  }

  @Override
  protected ScannerCallable createScannerCallable() {
    if (!scan.includeStartRow() && !isEmptyStartRow(scan.getStartRow())) {
      // we have not implemented locate to next row for sync client yet, so here we change the
      // inclusive of start row to true.
      scan.withStartRow(createClosestRowAfter(scan.getStartRow()), true);
    }
    return new ScannerCallable(getConnection(), getTable(), scan, this.scanMetrics,
      this.rpcControllerFactory, getScanReplicaId(), requestAttributes);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy