Java Code Examples for org.apache.hadoop.hbase.util.Bytes#findCommonPrefix()

The following examples show how to use org.apache.hadoop.hbase.util.Bytes#findCommonPrefix() . 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: StoreFileReader.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * A method for checking Bloom filters. Called directly from
 * StoreFileScanner in case of a multi-column query.
 *
 * @return True if passes
 */
private boolean passesGeneralRowPrefixBloomFilter(Scan scan) {
  BloomFilter bloomFilter = this.generalBloomFilter;
  if (bloomFilter == null) {
    return true;
  }

  byte[] row = scan.getStartRow();
  byte[] rowPrefix;
  if (scan.isGetScan()) {
    rowPrefix = Bytes.copy(row, 0, Math.min(prefixLength, row.length));
  } else {
    // For non-get scans
    // Find out the common prefix of startRow and stopRow.
    int commonLength = Bytes.findCommonPrefix(scan.getStartRow(), scan.getStopRow(),
        scan.getStartRow().length, scan.getStopRow().length, 0, 0);
    // startRow and stopRow don't have the common prefix.
    // Or the common prefix length is less than prefixLength
    if (commonLength <= 0 || commonLength < prefixLength) {
      return true;
    }
    rowPrefix = Bytes.copy(row, 0, prefixLength);
  }
  return checkGeneralBloomFilter(rowPrefix, null, bloomFilter);
}
 
Example 2
Source File: BufferedDataBlockEncoder.java    From hbase with Apache License 2.0 5 votes vote down vote up
private static int findCommonPrefixInFamilyPart(Cell left, Cell right, int familyCommonPrefix) {
  return Bytes
      .findCommonPrefix(left.getFamilyArray(), right.getFamilyArray(), left.getFamilyLength()
          - familyCommonPrefix, right.getFamilyLength() - familyCommonPrefix,
          left.getFamilyOffset() + familyCommonPrefix, right.getFamilyOffset()
              + familyCommonPrefix);
}
 
Example 3
Source File: BufferedDataBlockEncoder.java    From hbase with Apache License 2.0 5 votes vote down vote up
private static int findCommonPrefixInQualifierPart(Cell left, Cell right,
    int qualifierCommonPrefix) {
  return Bytes.findCommonPrefix(left.getQualifierArray(), right.getQualifierArray(),
      left.getQualifierLength() - qualifierCommonPrefix, right.getQualifierLength()
          - qualifierCommonPrefix, left.getQualifierOffset() + qualifierCommonPrefix,
      right.getQualifierOffset() + qualifierCommonPrefix);
}
 
Example 4
Source File: BufferedDataBlockEncoder.java    From hbase with Apache License 2.0 4 votes vote down vote up
private static int findCommonPrefixInRowPart(Cell left, Cell right, int rowCommonPrefix) {
  return Bytes.findCommonPrefix(left.getRowArray(), right.getRowArray(), left.getRowLength()
      - rowCommonPrefix, right.getRowLength() - rowCommonPrefix, left.getRowOffset()
      + rowCommonPrefix, right.getRowOffset() + rowCommonPrefix);
}