-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return Total Result Count and Remaining Count in Get Snapshots Response #76150
Return Total Result Count and Remaining Count in Get Snapshots Response #76150
Conversation
Add total result count and remaining count to get snapshots response.
@@ -156,12 +156,23 @@ private void getMultipleReposSnapshotInfo( | |||
.collect(Collectors.toMap(Tuple::v1, Tuple::v2)); | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, dropped hasMore
completely now :)
Pinging @elastic/es-distributed (Team:Distributed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, left a few minor comments, really all optional.
@@ -156,12 +156,23 @@ private void getMultipleReposSnapshotInfo( | |||
.collect(Collectors.toMap(Tuple::v1, Tuple::v2)); | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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! |
…se (elastic#76150) Add total result count and remaining count to get snapshots response.
Add total result count and remaining count to get snapshots response.