HTableInterface hTable = services.getTable(tableRef.getTable().getName().getBytes());
try {
byte[] minKey = null, maxKey = null;
// Do a key-only scan to get the first row of a table. This is the min
// key for the table.
Scan scan = new Scan(HConstants.EMPTY_START_ROW, new KeyOnlyFilter());
ResultScanner scanner = hTable.getScanner(scan);
try {
Result r = scanner.next();
if (r != null) {
minKey = r.getRow();