Java Code Examples for org.apache.hadoop.hbase.client.Scan#getCaching()

The following examples show how to use org.apache.hadoop.hbase.client.Scan#getCaching() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: pinpoint   File: ParallelResultScanner.java    License: Apache License 2.0 6 votes vote down vote up
public ParallelResultScanner(TableName tableName, HbaseAccessor hbaseAccessor, ExecutorService executor, Scan originalScan, AbstractRowKeyDistributor keyDistributor, int numParallelThreads) throws IOException {
    if (hbaseAccessor == null) {
        throw new NullPointerException("hbaseAccessor");
    }
    if (executor == null) {
        throw new NullPointerException("executor");
    }
    if (originalScan == null) {
        throw new NullPointerException("originalScan");
    }
    this.keyDistributor = Objects.requireNonNull(keyDistributor, "keyDistributor");

    final ScanTaskConfig scanTaskConfig = new ScanTaskConfig(tableName, hbaseAccessor, keyDistributor, originalScan.getCaching());
    final Scan[] splitScans = splitScans(originalScan);

    this.scanTasks = createScanTasks(scanTaskConfig, splitScans, numParallelThreads);
    this.nextResults = new Result[scanTasks.size()];
    for (ScanTask scanTask : scanTasks) {
        executor.execute(scanTask);
    }
}
 
Example 2
Source Project: hbase   File: ThriftTable.java    License: Apache License 2.0 5 votes vote down vote up
public Scanner(Scan scan) throws IOException {
  if (scan.getBatch() > 0) {
    throw new IOException("Batch is not supported in Scanner");
  }
  if (scan.getCaching() <= 0) {
    scan.setCaching(scannerCaching);
  } else if (scan.getCaching() == 1 && scan.isReversed()){
    // for reverse scan, we need to pass the last row to the next scanner
    // we need caching number bigger than 1
    scan.setCaching(scan.getCaching() + 1);
  }
  this.scan = ThriftUtilities.scanFromHBase(scan);
}
 
Example 3
Source Project: hbase   File: ScannerModel.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * @param scan the scan specification
 * @throws Exception
 */
public static ScannerModel fromScan(Scan scan) throws Exception {
  ScannerModel model = new ScannerModel();
  model.setStartRow(scan.getStartRow());
  model.setEndRow(scan.getStopRow());
  Map<byte [], NavigableSet<byte []>> families = scan.getFamilyMap();
  if (families != null) {
    for (Map.Entry<byte [], NavigableSet<byte []>> entry : families.entrySet()) {
      if (entry.getValue() != null) {
        for (byte[] qualifier: entry.getValue()) {
          model.addColumn(Bytes.add(entry.getKey(), COLUMN_DIVIDER, qualifier));
        }
      } else {
        model.addColumn(entry.getKey());
      }
    }
  }
  model.setStartTime(scan.getTimeRange().getMin());
  model.setEndTime(scan.getTimeRange().getMax());
  int caching = scan.getCaching();
  if (caching > 0) {
    model.setCaching(caching);
  }
  int batch = scan.getBatch();
  if (batch > 0) {
    model.setBatch(batch);
  }
  int maxVersions = scan.getMaxVersions();
  if (maxVersions > 0) {
    model.setMaxVersions(maxVersions);
  }
  if (scan.getLimit() > 0) {
    model.setLimit(scan.getLimit());
  }
  Filter filter = scan.getFilter();
  if (filter != null) {
    model.setFilter(stringifyFilter(filter));
  }
  // Add the visbility labels if found in the attributes
  Authorizations authorizations = scan.getAuthorizations();
  if (authorizations != null) {
    List<String> labels = authorizations.getLabels();
    for (String label : labels) {
      model.addLabel(label);
    }
  }
  return model;
}