Fix ProfileScorer.getChildren() to expose wrapped scorer in scorer tree#20607
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR modifies ProfileScorer to expose the wrapped scorer as a child through the getChildren() method, which now returns a singleton list containing a ChildScorable with "PROFILED" relationship instead of delegating to the wrapped scorer's children. Includes corresponding test coverage and changelog documentation. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
c5a7642 to
6fddaa4
Compare
|
❌ Gradle check result for 6fddaa4: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
Looks like rarely failing test, not related to this change, passes in my local environment |
server/src/test/java/org/opensearch/search/profile/query/ProfileScorerTests.java
Outdated
Show resolved
Hide resolved
|
❌ Gradle check result for d9166f3: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
5b8fbf1 to
39bf65d
Compare
owaiskazi19
left a comment
There was a problem hiding this comment.
Looks good. Thanks @martin-gaievski . Will wait for @jainankitk to take a look before merging in
|
❕ Gradle check result for 39bf65d: UNSTABLE Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure. |
server/src/main/java/org/opensearch/search/profile/query/WrappedScorerAccessor.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Martin Gaievski <gaievski@amazon.com>
Signed-off-by: Martin Gaievski <gaievski@amazon.com>
Signed-off-by: Martin Gaievski <gaievski@amazon.com>
Signed-off-by: Martin Gaievski <gaievski@amazon.com>
39bf65d to
8245b9f
Compare
|
❌ Gradle check result for 8245b9f: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Martin Gaievski <gaievski@amazon.com>
8245b9f to
bc1d39e
Compare
jainankitk
left a comment
There was a problem hiding this comment.
Thanks @martin-gaievski for addressing the review comment. Can we implement this interface for ProfilingAggregator, ProfileCollector and any other class providing access to the delegate?
…tCollector Signed-off-by: Martin Gaievski <gaievski@amazon.com>
We can add the interface to ProfilingAggregator and ProfilingLeafBucketCollector, just pushed new commit with corresponding change |
…ee (opensearch-project#20607) * Fix ProfileScorer.getChildren() to expose wrapped scorer in scorer tree Signed-off-by: Martin Gaievski <gaievski@amazon.com> * Changed approach to use new ScoreWrapper interface Signed-off-by: Martin Gaievski <gaievski@amazon.com> * Renamed interface to WrappedScorerAccessor, added unit test Signed-off-by: Martin Gaievski <gaievski@amazon.com> * Improving tests, corrected changelog Signed-off-by: Martin Gaievski <gaievski@amazon.com> * Changed to generic interface ProfilingWrapper Signed-off-by: Martin Gaievski <gaievski@amazon.com> * Adding ProfilingWrapper to ProfilingAggregator and ProfilingLeafBucketCollector Signed-off-by: Martin Gaievski <gaievski@amazon.com> --------- Signed-off-by: Martin Gaievski <gaievski@amazon.com>
Description
ProfileScorer.getChildren()currently delegates directly to the wrapped scorer'sgetChildren(),which skips the
ProfileScorerlevel in the scorer tree. This makes the wrapped scorer invisible toany code traversing the scorer hierarchy via the standard Lucene
Scorable.getChildren()API.This change makes
ProfileScorerexpose the wrapped scorer as a child with the"PROFILED"relationship label, allowing plugins and custom collectors to discover wrapped scorers through
profiling wrappers using standard tree traversal — without requiring reflection.
Changes
ProfileScorer.java: ChangedgetChildren()fromreturn scorer.getChildren()toreturn Collections.singletonList(new ChildScorable(scorer, "PROFILED"))ProfileScorerTests.java: AddedtestGetChildren_exposesWrappedScorerAsChild()to verifythe new behavior
Related Issues
Resolves #20548
PR #20549 added
getWrappedScorer()— a public method onProfileScorerthat returns the wrapped scorer. This was intended to let neural-search unwrapProfileScorerto findHybridQueryScorer.When implementing the neural-search side, we discovered that
getWrappedScorer()alone doesn't solve the problem becauseProfileScoreris a package-privatefinal class. Even thoughgetWrappedScorer()is apublicmethod, Java's access control system blocksMethod.invoke()from external modules (plugins) on methods of non-public classes. The plugin code gets:This means the neural-search plugin had to use
method.setAccessible(true)+@SuppressForbiddento callgetWrappedScorer()via reflection — defeating the purpose of having a clean public API.Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.