use of org.apache.accumulo.proxy.thrift.NoMoreEntriesException in project accumulo by apache.
the class ProxyServer method nextK.
@Override
public ScanResult nextK(String scanner, int k) throws NoMoreEntriesException, UnknownScanner, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
// fetch the scanner
ScannerPlusIterator spi = getScanner(scanner);
Iterator<Map.Entry<Key, Value>> batchScanner = spi.iterator;
// synchronized to prevent race conditions
synchronized (batchScanner) {
ScanResult ret = new ScanResult();
ret.setResults(new ArrayList<>());
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);
throw new org.apache.accumulo.proxy.thrift.AccumuloSecurityException(ex.toString());
}
return ret;
}
}
Aggregations