Search in sources :

Example 1 with MultiRowRangeFilter

use of org.apache.hadoop.hbase.filter.MultiRowRangeFilter in project hbase by apache.

the class RowCounter method setScanFilter.

/**
   * Sets filter {@link FilterBase} to the {@link Scan} instance.
   * If provided rowRangeList contains more than one element,
   * method sets filter which is instance of {@link MultiRowRangeFilter}.
   * Otherwise, method sets filter which is instance of {@link FirstKeyOnlyFilter}.
   * If rowRangeList contains exactly one element, startRow and stopRow are set to the scan.
   * @param scan
   * @param rowRangeList
   */
private static void setScanFilter(Scan scan, List<MultiRowRangeFilter.RowRange> rowRangeList) {
    final int size = rowRangeList == null ? 0 : rowRangeList.size();
    if (size <= 1) {
        scan.setFilter(new FirstKeyOnlyFilter());
    }
    if (size == 1) {
        MultiRowRangeFilter.RowRange range = rowRangeList.get(0);
        //inclusive
        scan.setStartRow(range.getStartRow());
        //exclusive
        scan.setStopRow(range.getStopRow());
    } else if (size > 1) {
        scan.setFilter(new MultiRowRangeFilter(rowRangeList));
    }
}
Also used : FirstKeyOnlyFilter(org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter) MultiRowRangeFilter(org.apache.hadoop.hbase.filter.MultiRowRangeFilter)

Aggregations

FirstKeyOnlyFilter (org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter)1 MultiRowRangeFilter (org.apache.hadoop.hbase.filter.MultiRowRangeFilter)1