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

The following are Jave code examples for showing how to use getCaching() of the org.apache.hadoop.hbase.client.Scan class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: easyhbase   File: ParallelResultScanner.java   Source Code and License Vote up 5 votes
public ParallelResultScanner(TableName tableName, HbaseAccessor hbaseAccessor,
                             ExecutorService executor, Scan originalScan,
                             AbstractRowKeyDistributor keyDistributor, int
                                     numParallelThreads) throws IOException {
    if (hbaseAccessor == null) {
        throw new NullPointerException("hbaseAccessor must not be null");
    }
    if (executor == null) {
        throw new NullPointerException("executor must not be null");
    }
    if (keyDistributor == null) {
        throw new NullPointerException("keyDistributor must not be null");
    }
    if (originalScan == null) {
        throw new NullPointerException("originalScan must not be null");
    }
    this.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
Project: ditb   File: ScannerModel.java   Source Code and License Vote up 4 votes
/**
 * @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);
  }
  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;
}