private static void setScanFilter(Scan scan, List<MultiRowRangeFilter.RowRange> rowRangeList,
    boolean countDeleteMarkers) {
    List<Filter> filters = new ArrayList<>();

    // Apply filters for better performance.
    if (!countDeleteMarkers) {
      // We only need one cell per row, unless --countDeleteMarkers flag is set.
      filters.add(new FirstKeyOnlyFilter());

      // We're not interested in values. Use KeyOnlyFilter.
      // NOTE: Logically, KeyOnlyFilter should be okay for --countDeleteMarkers, because it should
      // only empty the values, but currently, having a filter changes the behavior of a raw scan.
      // So we don't use it. See {@link UserScanQueryMatcher#mergeFilterResponse} for more details.
      filters.add(new KeyOnlyFilter());
    }

    // Depending on the number of ranges, set start/stop row or apply MultiRowRangeFilter.
    final int size = rowRangeList == null ? 0 : rowRangeList.size();
    if (size == 1) {
      MultiRowRangeFilter.RowRange range = rowRangeList.get(0);
      scan.withStartRow(range.getStartRow()); // inclusive
      scan.withStopRow(range.getStopRow()); // exclusive
    } else if (size > 1) {
      filters.add(new MultiRowRangeFilter(rowRangeList));
    }

    if (filters.isEmpty()) {
      return;
    }
    scan.setFilter(filters.size() == 1 ? filters.get(0) : new FilterList(filters));
  }
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}. If
rowRangeList contains exactly one element, startRow and stopRow are set to the scan. Also,
method may apply {@link FirstKeyOnlyFilter} an {@link KeyOnlyFilter} for better performance.
hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/RowCounter.java