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

The following examples show how to use org.apache.hadoop.hbase.client.Scan#isReversed() . 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 File: HMobStore.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the MobStoreScanner or MobReversedStoreScanner. In these scanners, a additional seeks in
 * the mob files should be performed after the seek in HBase is done.
 */
@Override
protected KeyValueScanner createScanner(Scan scan, ScanInfo scanInfo,
    NavigableSet<byte[]> targetCols, long readPt) throws IOException {
  if (MobUtils.isRefOnlyScan(scan)) {
    Filter refOnlyFilter = new MobReferenceOnlyFilter();
    Filter filter = scan.getFilter();
    if (filter != null) {
      scan.setFilter(new FilterList(filter, refOnlyFilter));
    } else {
      scan.setFilter(refOnlyFilter);
    }
  }
  return scan.isReversed() ? new ReversedMobStoreScanner(this, scanInfo, scan, targetCols, readPt)
      : new MobStoreScanner(this, scanInfo, scan, targetCols, readPt);
}
 
Example 2
Source File: StoreFileReader.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Checks whether the given scan rowkey range overlaps with the current storefile's
 * @param scan the scan specification. Used to determine the rowkey range.
 * @return true if there is overlap, false otherwise
 */
public boolean passesKeyRangeFilter(Scan scan) {
  Optional<Cell> firstKeyKV = this.getFirstKey();
  Optional<Cell> lastKeyKV = this.getLastKey();
  if (!firstKeyKV.isPresent() || !lastKeyKV.isPresent()) {
    // the file is empty
    return false;
  }
  if (Bytes.equals(scan.getStartRow(), HConstants.EMPTY_START_ROW) &&
      Bytes.equals(scan.getStopRow(), HConstants.EMPTY_END_ROW)) {
    return true;
  }
  byte[] smallestScanRow = scan.isReversed() ? scan.getStopRow() : scan.getStartRow();
  byte[] largestScanRow = scan.isReversed() ? scan.getStartRow() : scan.getStopRow();
  boolean nonOverLapping = (getComparator()
      .compareRows(firstKeyKV.get(), largestScanRow, 0, largestScanRow.length) > 0 &&
      !Bytes.equals(scan.isReversed() ? scan.getStartRow() : scan.getStopRow(),
        HConstants.EMPTY_END_ROW)) ||
      getComparator().compareRows(lastKeyKV.get(), smallestScanRow, 0,
        smallestScanRow.length) < 0;
  return !nonOverLapping;
}
 
Example 3
Source File: ThriftTable.java    From hbase with 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 4
Source File: TestScannerHeartbeatMessages.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
protected RegionScannerImpl instantiateRegionScanner(Scan scan,
    List<KeyValueScanner> additionalScanners, long nonceGroup, long nonce) throws IOException {
  if (scan.isReversed()) {
    if (scan.getFilter() != null) {
      scan.getFilter().setReversed(true);
    }
    return new HeartbeatReversedRegionScanner(scan, additionalScanners, this);
  }
  return new HeartbeatRegionScanner(scan, additionalScanners, this);
}
 
Example 5
Source File: HStore.java    From hbase with Apache License 2.0 4 votes vote down vote up
protected KeyValueScanner createScanner(Scan scan, ScanInfo scanInfo,
    NavigableSet<byte[]> targetCols, long readPt) throws IOException {
  return scan.isReversed() ? new ReversedStoreScanner(this, scanInfo, scan, targetCols, readPt)
      : new StoreScanner(this, scanInfo, scan, targetCols, readPt);
}