Rework get-snapshots predicates#143161
Conversation
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.
|
Pinging @elastic/es-distributed (Team:Distributed) |
inespot
left a comment
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Should we add a quick unit test suite for this?
| * 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 { |
There was a problem hiding this comment.
Can AfterPredicates be package-private?
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.
…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) ...
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
SnapshotPredicatesclass actually only deals with the?from_sort_valuefilter, and the related?afterfilter wasimplemented within
SnapshotSortKeyitself. As a step towards adding apre-flight
?aftercheck this commit refactors the?afterfunctionality into a new
AfterPredicatesclass, and for the sake ofconsistency moves the
?from_sort_valuefunctionality to an adjacenttop-level
FromSortValuePredicatesclass.