Skip to content

Rework get-snapshots predicates#143161

Merged
DaveCTurner merged 6 commits intoelastic:mainfrom
DaveCTurner:2026/02/26/get-snapshots-predicates
Feb 27, 2026
Merged

Rework get-snapshots predicates#143161
DaveCTurner merged 6 commits intoelastic:mainfrom
DaveCTurner:2026/02/26/get-snapshots-predicates

Conversation

@DaveCTurner
Copy link
Copy Markdown
Member

The inner SnapshotPredicates class actually only deals with the
?from_sort_value filter, and the related ?after filter was
implemented within SnapshotSortKey itself. As a step towards adding a
pre-flight ?after check this commit refactors the ?after
functionality into a new AfterPredicates class, and for the sake of
consistency moves the ?from_sort_value functionality to an adjacent
top-level FromSortValuePredicates class.

The inner `SnapshotPredicates` class actually only deals with the
`?from_sort_value` filter, and the related `?after` filter was
implemented within `SnapshotSortKey` itself. As a step towards adding a
pre-flight `?after` check this commit refactors the `?after`
functionality into a new `AfterPredicates` class, and for the sake of
consistency moves the `?from_sort_value` functionality to an adjacent
top-level `FromSortValuePredicates` class.
@DaveCTurner DaveCTurner added :Distributed/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs >refactoring v9.4.0 labels Feb 26, 2026
@elasticsearchmachine elasticsearchmachine added the Team:Distributed Meta label for distributed team. label Feb 26, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

@DaveCTurner DaveCTurner requested review from inespot and ywangd and removed request for inespot February 26, 2026 17:36
Copy link
Copy Markdown
Contributor

@inespot inespot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactor, the code is so much more readable now 🎉 A couple small comments/questions

private final SnapshotNamePredicate snapshotNamePredicate;
private final SnapshotPredicates fromSortValuePredicates;
private final FromSortValuePredicates fromSortValuePredicates;
private final Predicate<String> slmPolicyPredicate;
Copy link
Copy Markdown
Contributor

@inespot inespot Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also be declared SlmPolicyPredicate (might have to tweak the SlmPolicyPredicate a little to resemble the AfterPredicates) and we can move it out into its own class, to be consistent and make TransportGetSnapshotsAction more succinct? Maybe as a FLUP PR

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inclined to keep it like this for now - it doesn't depend on the sortBy so it's much simpler than the ?from_sort_value and ?after parameters.

* Predicate for the {@code ?after} filter of the get-snapshots action. The {@link #test(SnapshotInfo)} predicate is applied to
* {@link SnapshotInfo} instances to filter out those that sort before the cursor value (i.e. were returned on earlier pages of results).
*/
public final class AfterPredicates {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a quick unit test suite for this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done in 2a74423

* Predicate for the {@code ?after} filter of the get-snapshots action. The {@link #test(SnapshotInfo)} predicate is applied to
* {@link SnapshotInfo} instances to filter out those that sort before the cursor value (i.e. were returned on earlier pages of results).
*/
public final class AfterPredicates {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can AfterPredicates be package-private?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes good point

Copy link
Copy Markdown
Member

@ywangd ywangd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@DaveCTurner DaveCTurner enabled auto-merge (squash) February 27, 2026 11:05
@DaveCTurner DaveCTurner merged commit 85231f8 into elastic:main Feb 27, 2026
35 checks passed
PeteGillinElastic pushed a commit to PeteGillinElastic/elasticsearch that referenced this pull request Feb 27, 2026
The inner `SnapshotPredicates` class actually only deals with the
`?from_sort_value` filter, and the related `?after` filter was
implemented within `SnapshotSortKey` itself. As a step towards adding a
pre-flight `?after` check this commit refactors the `?after`
functionality into a new `AfterPredicates` class, and for the sake of
consistency moves the `?from_sort_value` functionality to an adjacent
top-level `FromSortValuePredicates` class.
szybia added a commit to szybia/elasticsearch that referenced this pull request Feb 27, 2026
…cations

* upstream/main: (35 commits)
  Create ARM bulk sqrI8 implementation (elastic#142461)
  Rework get-snapshots predicates (elastic#143161)
  Refactor downsampling fetchers and producers (elastic#140357)
  ESQL: Unmute test and add extra logging to generative test validation (elastic#143168)
  Fix metadata fields being nullified/loaded by unmapped_fields setting (elastic#143155)
  Determine remote cluster version (elastic#142494)
  Populate failure message for aborted clones (elastic#143206)
  Allow kibana_system role to read and manage logs streams (elastic#143053)
  Mute org.elasticsearch.xpack.esql.CsvIT test {csv-spec:eval.DocsLength} elastic#143224
  Mute org.elasticsearch.xpack.esql.CsvIT test {csv-spec:eval.DocsByteLength} elastic#143223
  Mute org.elasticsearch.xpack.esql.CsvIT test {csv-spec:docs.DocsBitLength} elastic#143222
  Fix FloatVectorScorerSupplier bulkScore bug (elastic#143211)
  ESQL: Add data node execution for external sources (elastic#143209)
  [ESQL] Cleanup commands docs (elastic#143058)
  [ML]Fix latest transforms disregarding updates when sort and sync fields are non-monotonic (elastic#142856)
  Mute org.elasticsearch.index.mapper.IpFieldMapperTests testSyntheticSourceInObject elastic#143212
  Tests: Fix StoreDirectoryMetricsIT (elastic#143084)
  ESQL: Add distribution strategy for external sources (elastic#143194)
  CSV IT spec (elastic#142585)
  Fix VectorScorerOSQBenchmark.score to read corrections properly (elastic#143137)
  ...
tballison pushed a commit to tballison/elasticsearch that referenced this pull request Mar 3, 2026
The inner `SnapshotPredicates` class actually only deals with the
`?from_sort_value` filter, and the related `?after` filter was
implemented within `SnapshotSortKey` itself. As a step towards adding a
pre-flight `?after` check this commit refactors the `?after`
functionality into a new `AfterPredicates` class, and for the sake of
consistency moves the `?from_sort_value` functionality to an adjacent
top-level `FromSortValuePredicates` class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs >refactoring Team:Distributed Meta label for distributed team. v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants