jojochuang commented on code in PR #9399:
URL: https://github.com/apache/ozone/pull/9399#discussion_r2819762820
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotDiffManager.java:
##########
@@ -545,39 +603,36 @@ SnapshotDiffReportOzone createPageResponse(
Pair<List<DiffReportEntry>, String> createPageResponse(
final SnapshotDiffJob snapDiffJob,
- final int index,
+ final String index,
final int pageSize
) throws IOException {
List<DiffReportEntry> diffReportList = new ArrayList<>();
- boolean hasMoreEntries = true;
-
byte[] lowerIndex = codecRegistry.asRawData(getReportKeyForIndex(
snapDiffJob.getJobId(), index));
- byte[] upperIndex = codecRegistry.asRawData(getReportKeyForIndex(
- snapDiffJob.getJobId(), index + pageSize));
- int idx = index;
+ String highestPossiblePrefix =
+
StringUtils.getLexicographicallyHigherString(DIFF_TYPE_STRING_MAP.values().stream()
+ .max(String::compareTo).get());
+ byte[] upperIndex =
codecRegistry.asRawData(getReportKeyForIndex(snapDiffJob.getJobId(),
highestPossiblePrefix));
try (ClosableIterator<Map.Entry<byte[], byte[]>> iterator =
- snapDiffReportTable.iterator(Optional.of(lowerIndex),
- Optional.of(upperIndex))) {
+ snapDiffReportTable.iterator(Optional.of(lowerIndex),
Optional.of(upperIndex))) {
int itemsFetched = 0;
+ String pageLastKey = "";
while (iterator.hasNext() && itemsFetched < pageSize) {
Map.Entry<byte[], byte[]> entry = iterator.next();
+ pageLastKey = StringCodec.get().fromPersistedFormat(entry.getKey());
byte[] bytes = entry.getValue();
- diffReportList.add(codecRegistry.asObject(bytes,
- DiffReportEntry.class));
- idx += 1;
+ diffReportList.add(codecRegistry.asObject(bytes,
DiffReportEntry.class));
itemsFetched += 1;
}
- if (diffReportList.size() < pageSize) {
- hasMoreEntries = false;
- }
+ // Next token
+ String nextTokenString = iterator.hasNext() ?
getIndexFromReportKey(pageLastKey) : null;
Review Comment:
this change broke the test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]