Return Total Result Count and Remaining Count in Get Snapshots Response#76150
Return Total Result Count and Remaining Count in Get Snapshots Response#76150original-brownbear merged 3 commits intoelastic:masterfrom original-brownbear:track-total-count
Conversation
Add total result count and remaining count to get snapshots response.
| final SnapshotsInRepo snInfos = sortSnapshots(allSnapshots, sortBy, after, size, order); | ||
| final List<SnapshotInfo> snapshotInfos = snInfos.snapshotInfos; | ||
| final int remaining; | ||
| final boolean hasMore = snInfos.hasMore || responses.stream().anyMatch(r -> r.v2() != null && r.v2().hasMore); |
There was a problem hiding this comment.
The logic for all this counting could be made for nicer obviously, but for now I went with the shortest route to getting this implemented on top of the existing functionality as we will be changing how this works under the hood soon anyway.
There was a problem hiding this comment.
Will remaining not anyway become 0 if hasMore==false? Meaning that we can skip calculating this boolean and just sum up remaining always? And then use that instead of hasMore below? Just seems nicer without too much rewrite.
There was a problem hiding this comment.
Right, dropped hasMore completely now :)
|
Pinging @elastic/es-distributed (Team:Distributed) |
henningandersen
left a comment
There was a problem hiding this comment.
LGTM, left a few minor comments, really all optional.
| final SnapshotsInRepo snInfos = sortSnapshots(allSnapshots, sortBy, after, size, order); | ||
| final List<SnapshotInfo> snapshotInfos = snInfos.snapshotInfos; | ||
| final int remaining; | ||
| final boolean hasMore = snInfos.hasMore || responses.stream().anyMatch(r -> r.v2() != null && r.v2().hasMore); |
There was a problem hiding this comment.
Will remaining not anyway become 0 if hasMore==false? Meaning that we can skip calculating this boolean and just sum up remaining always? And then use that instead of hasMore below? Just seems nicer without too much rewrite.
...n/java/org/elasticsearch/action/admin/cluster/snapshots/get/TransportGetSnapshotsAction.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java
Outdated
Show resolved
Hide resolved
...n/java/org/elasticsearch/action/admin/cluster/snapshots/get/TransportGetSnapshotsAction.java
Show resolved
Hide resolved
...src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java
Outdated
Show resolved
Hide resolved
|
Thanks Henning! |
Add total result count and remaining count to get snapshots response.