use of com.alipay.sofa.jraft.rhea.storage.KVEntry in project sofa-jraft by sofastack.
the class DefaultRheaIterator method hasNext.
@Override
public synchronized boolean hasNext() {
if (this.buf.isEmpty()) {
while (this.endKey == null || BytesUtil.compare(this.cursorKey, this.endKey) < 0) {
final List<KVEntry> kvEntries = this.rheaKVStore.singleRegionScan(this.cursorKey, this.endKey, this.bufSize, this.readOnlySafe, this.returnValue);
if (kvEntries.isEmpty()) {
// cursorKey jump to next region's startKey
this.cursorKey = this.pdClient.findStartKeyOfNextRegion(this.cursorKey, false);
if (cursorKey == null) {
// current is the last region
break;
}
} else {
final KVEntry last = kvEntries.get(kvEntries.size() - 1);
// cursorKey++
this.cursorKey = BytesUtil.nextBytes(last.getKey());
this.buf.addAll(kvEntries);
break;
}
}
return !this.buf.isEmpty();
}
return true;
}
Aggregations