private Result[] scanNVersions(Table ht, byte[] cf, int startRowIdx, int endRowIdx,
    List<Long> versions) throws IOException {
    byte startRow[] = Bytes.toBytes("row:" + startRowIdx);
    byte endRow[] = Bytes.toBytes("row:" + endRowIdx + 1); // exclusive
    Filter filter = new TimestampsFilter(versions);
    Scan scan = new Scan().withStartRow(startRow).withStopRow(endRow);
    scan.setFilter(filter);
    scan.readAllVersions();
    ResultScanner scanner = ht.getScanner(scan);
    return scanner.next(endRowIdx - startRowIdx + 1);
  }
Uses the TimestampFilter on a Scan to request a specified list of versions for the rows from
startRowIdx to endRowIdx (both inclusive).
hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestTimestampsFilter.java