ret.setResults(new ArrayList<KeyValue>());
int numRead = 0;
try {
while (batchScanner.hasNext() && numRead < k) {
Map.Entry<Key,Value> next = batchScanner.next();
ret.addToResults(new KeyValue(Util.toThrift(next.getKey()), ByteBuffer.wrap(next.getValue().get())));
numRead++;
}
ret.setMore(numRead == k);
} catch (Exception ex) {
closeScanner(scanner);