Map<Bytes, Map<Column, Bytes>> scan() {
long waitTime = SnapshotScanner.INITIAL_WAIT_TIME;
long startTime = System.currentTimeMillis();
Map<Bytes, Map<Column, Bytes>> ret = new HashMap<>();
while (true) {
List<Entry<Key, Value>> locks = new ArrayList<>();
scan(ret, locks);
if (locks.size() > 0) {
boolean resolvedAll = LockResolver.resolveLocks(env, startTs, stats, locks, startTime);
if (!resolvedAll) {
UtilWaitThread.sleep(waitTime);
stats.incrementLockWaitTime(waitTime);
waitTime = Math.min(SnapshotScanner.MAX_WAIT_TIME, waitTime * 2);
}
HashSet<Bytes> lockedRows = new HashSet<>();
for (Entry<Key, Value> entry : locks) {
lockedRows.add(ByteUtil.toBytes(entry.getKey().getRowData()));
}
unscannedRows.retainAll(lockedRows);
continue;
}
for (Map<Column, Bytes> cols : ret.values()) {
stats.incrementEntriesReturned(cols.size());
}
return ret;
}
}