CNDB-15423: Make TopKProcessor lazily load queryVector#2007
Merged
michaeljmarshall merged 1 commit intomainfrom Sep 22, 2025
Merged
CNDB-15423: Make TopKProcessor lazily load queryVector#2007michaeljmarshall merged 1 commit intomainfrom
michaeljmarshall merged 1 commit intomainfrom
Conversation
Checklist before you submit for review
|
|
✔️ Build ds-cassandra-pr-gate/PR-2007 approved by ButlerApproved by Butler |
eolivelli
approved these changes
Sep 20, 2025
eolivelli
left a comment
There was a problem hiding this comment.
Lgtm
Great catch.
I don't think we need additional unit tests in this case.
This change is actually fixing broken tests
k-rus
approved these changes
Sep 20, 2025
Member
k-rus
left a comment
There was a problem hiding this comment.
To me it looks good. My understanding is that the condition on the synthetic score was added by @adelapena, thus I mention him if he wants to see the fix in retrospective.
michaelsembwever
pushed a commit
that referenced
this pull request
Sep 25, 2025
…2007) Fixes: riptano/cndb#15423 CNDB test: riptano/cndb#15427 This PR fixes a subtle bug exposed by the `FeaturesVersionSupportCATest.testANN` test, as well as other similarly named `FeaturesVersionSupport*Test` tests. The central issue is whether to create the `queryVector` object. The currently logic does so only when `useSyntheticScore()` is false. However, if a peer has it set to false and this node has it on true, we'll end up with an easily avoided NPE. I propose instead that we lazily load the vector when it is needed. This removes an unnecessary switch as well as removing an unnecessary ordering requirement on upgrades. ``` java.lang.NullPointerException at io.github.jbellis.jvector.vector.VectorUtil.squareL2Distance(VectorUtil.java:85) at io.github.jbellis.jvector.vector.VectorSimilarityFunction$1.compare(VectorSimilarityFunction.java:40) at org.apache.cassandra.index.sai.plan.TopKProcessor.getScoreForRow(TopKProcessor.java:333) at org.apache.cassandra.index.sai.plan.TopKProcessor.processScoredPartition(TopKProcessor.java:276) at org.apache.cassandra.index.sai.plan.TopKProcessor.reorder(TopKProcessor.java:145) at org.apache.cassandra.index.sai.plan.StorageAttachedIndexQueryPlan.lambda$postProcessor$2(StorageAttachedIndexQueryPlan.java:233) at org.apache.cassandra.db.ReadCommand.postReconciliationProcessing(ReadCommand.java:566) at org.apache.cassandra.service.reads.range.RangeCommands.partitions(RangeCommands.java:60) ```
michaelsembwever
pushed a commit
that referenced
this pull request
Sep 26, 2025
…2007) Fixes: riptano/cndb#15423 CNDB test: riptano/cndb#15427 This PR fixes a subtle bug exposed by the `FeaturesVersionSupportCATest.testANN` test, as well as other similarly named `FeaturesVersionSupport*Test` tests. The central issue is whether to create the `queryVector` object. The currently logic does so only when `useSyntheticScore()` is false. However, if a peer has it set to false and this node has it on true, we'll end up with an easily avoided NPE. I propose instead that we lazily load the vector when it is needed. This removes an unnecessary switch as well as removing an unnecessary ordering requirement on upgrades. ``` java.lang.NullPointerException at io.github.jbellis.jvector.vector.VectorUtil.squareL2Distance(VectorUtil.java:85) at io.github.jbellis.jvector.vector.VectorSimilarityFunction$1.compare(VectorSimilarityFunction.java:40) at org.apache.cassandra.index.sai.plan.TopKProcessor.getScoreForRow(TopKProcessor.java:333) at org.apache.cassandra.index.sai.plan.TopKProcessor.processScoredPartition(TopKProcessor.java:276) at org.apache.cassandra.index.sai.plan.TopKProcessor.reorder(TopKProcessor.java:145) at org.apache.cassandra.index.sai.plan.StorageAttachedIndexQueryPlan.lambda$postProcessor$2(StorageAttachedIndexQueryPlan.java:233) at org.apache.cassandra.db.ReadCommand.postReconciliationProcessing(ReadCommand.java:566) at org.apache.cassandra.service.reads.range.RangeCommands.partitions(RangeCommands.java:60) ```
michaelsembwever
pushed a commit
that referenced
this pull request
Feb 6, 2026
…2007) Fixes: riptano/cndb#15423 CNDB test: riptano/cndb#15427 This PR fixes a subtle bug exposed by the `FeaturesVersionSupportCATest.testANN` test, as well as other similarly named `FeaturesVersionSupport*Test` tests. The central issue is whether to create the `queryVector` object. The currently logic does so only when `useSyntheticScore()` is false. However, if a peer has it set to false and this node has it on true, we'll end up with an easily avoided NPE. I propose instead that we lazily load the vector when it is needed. This removes an unnecessary switch as well as removing an unnecessary ordering requirement on upgrades. ``` java.lang.NullPointerException at io.github.jbellis.jvector.vector.VectorUtil.squareL2Distance(VectorUtil.java:85) at io.github.jbellis.jvector.vector.VectorSimilarityFunction$1.compare(VectorSimilarityFunction.java:40) at org.apache.cassandra.index.sai.plan.TopKProcessor.getScoreForRow(TopKProcessor.java:333) at org.apache.cassandra.index.sai.plan.TopKProcessor.processScoredPartition(TopKProcessor.java:276) at org.apache.cassandra.index.sai.plan.TopKProcessor.reorder(TopKProcessor.java:145) at org.apache.cassandra.index.sai.plan.StorageAttachedIndexQueryPlan.lambda$postProcessor$2(StorageAttachedIndexQueryPlan.java:233) at org.apache.cassandra.db.ReadCommand.postReconciliationProcessing(ReadCommand.java:566) at org.apache.cassandra.service.reads.range.RangeCommands.partitions(RangeCommands.java:60) ```
michaelsembwever
pushed a commit
that referenced
this pull request
Feb 10, 2026
…2007) Fixes: riptano/cndb#15423 CNDB test: riptano/cndb#15427 This PR fixes a subtle bug exposed by the `FeaturesVersionSupportCATest.testANN` test, as well as other similarly named `FeaturesVersionSupport*Test` tests. The central issue is whether to create the `queryVector` object. The currently logic does so only when `useSyntheticScore()` is false. However, if a peer has it set to false and this node has it on true, we'll end up with an easily avoided NPE. I propose instead that we lazily load the vector when it is needed. This removes an unnecessary switch as well as removing an unnecessary ordering requirement on upgrades. ``` java.lang.NullPointerException at io.github.jbellis.jvector.vector.VectorUtil.squareL2Distance(VectorUtil.java:85) at io.github.jbellis.jvector.vector.VectorSimilarityFunction$1.compare(VectorSimilarityFunction.java:40) at org.apache.cassandra.index.sai.plan.TopKProcessor.getScoreForRow(TopKProcessor.java:333) at org.apache.cassandra.index.sai.plan.TopKProcessor.processScoredPartition(TopKProcessor.java:276) at org.apache.cassandra.index.sai.plan.TopKProcessor.reorder(TopKProcessor.java:145) at org.apache.cassandra.index.sai.plan.StorageAttachedIndexQueryPlan.lambda$postProcessor$2(StorageAttachedIndexQueryPlan.java:233) at org.apache.cassandra.db.ReadCommand.postReconciliationProcessing(ReadCommand.java:566) at org.apache.cassandra.service.reads.range.RangeCommands.partitions(RangeCommands.java:60) ``` (Rebase of commit be64177)
michaelsembwever
pushed a commit
that referenced
this pull request
Feb 11, 2026
…2007) Fixes: riptano/cndb#15423 CNDB test: riptano/cndb#15427 This PR fixes a subtle bug exposed by the `FeaturesVersionSupportCATest.testANN` test, as well as other similarly named `FeaturesVersionSupport*Test` tests. The central issue is whether to create the `queryVector` object. The currently logic does so only when `useSyntheticScore()` is false. However, if a peer has it set to false and this node has it on true, we'll end up with an easily avoided NPE. I propose instead that we lazily load the vector when it is needed. This removes an unnecessary switch as well as removing an unnecessary ordering requirement on upgrades. ``` java.lang.NullPointerException at io.github.jbellis.jvector.vector.VectorUtil.squareL2Distance(VectorUtil.java:85) at io.github.jbellis.jvector.vector.VectorSimilarityFunction$1.compare(VectorSimilarityFunction.java:40) at org.apache.cassandra.index.sai.plan.TopKProcessor.getScoreForRow(TopKProcessor.java:333) at org.apache.cassandra.index.sai.plan.TopKProcessor.processScoredPartition(TopKProcessor.java:276) at org.apache.cassandra.index.sai.plan.TopKProcessor.reorder(TopKProcessor.java:145) at org.apache.cassandra.index.sai.plan.StorageAttachedIndexQueryPlan.lambda$postProcessor$2(StorageAttachedIndexQueryPlan.java:233) at org.apache.cassandra.db.ReadCommand.postReconciliationProcessing(ReadCommand.java:566) at org.apache.cassandra.service.reads.range.RangeCommands.partitions(RangeCommands.java:60) ``` (Rebase of commit be64177)
michaelsembwever
pushed a commit
that referenced
this pull request
Feb 12, 2026
…2007) Fixes: riptano/cndb#15423 CNDB test: riptano/cndb#15427 This PR fixes a subtle bug exposed by the `FeaturesVersionSupportCATest.testANN` test, as well as other similarly named `FeaturesVersionSupport*Test` tests. The central issue is whether to create the `queryVector` object. The currently logic does so only when `useSyntheticScore()` is false. However, if a peer has it set to false and this node has it on true, we'll end up with an easily avoided NPE. I propose instead that we lazily load the vector when it is needed. This removes an unnecessary switch as well as removing an unnecessary ordering requirement on upgrades. ``` java.lang.NullPointerException at io.github.jbellis.jvector.vector.VectorUtil.squareL2Distance(VectorUtil.java:85) at io.github.jbellis.jvector.vector.VectorSimilarityFunction$1.compare(VectorSimilarityFunction.java:40) at org.apache.cassandra.index.sai.plan.TopKProcessor.getScoreForRow(TopKProcessor.java:333) at org.apache.cassandra.index.sai.plan.TopKProcessor.processScoredPartition(TopKProcessor.java:276) at org.apache.cassandra.index.sai.plan.TopKProcessor.reorder(TopKProcessor.java:145) at org.apache.cassandra.index.sai.plan.StorageAttachedIndexQueryPlan.lambda$postProcessor$2(StorageAttachedIndexQueryPlan.java:233) at org.apache.cassandra.db.ReadCommand.postReconciliationProcessing(ReadCommand.java:566) at org.apache.cassandra.service.reads.range.RangeCommands.partitions(RangeCommands.java:60) ``` (Rebase of commit be64177)
michaelsembwever
pushed a commit
that referenced
this pull request
Feb 14, 2026
…2007) Fixes: riptano/cndb#15423 CNDB test: riptano/cndb#15427 This PR fixes a subtle bug exposed by the `FeaturesVersionSupportCATest.testANN` test, as well as other similarly named `FeaturesVersionSupport*Test` tests. The central issue is whether to create the `queryVector` object. The currently logic does so only when `useSyntheticScore()` is false. However, if a peer has it set to false and this node has it on true, we'll end up with an easily avoided NPE. I propose instead that we lazily load the vector when it is needed. This removes an unnecessary switch as well as removing an unnecessary ordering requirement on upgrades. ``` java.lang.NullPointerException at io.github.jbellis.jvector.vector.VectorUtil.squareL2Distance(VectorUtil.java:85) at io.github.jbellis.jvector.vector.VectorSimilarityFunction$1.compare(VectorSimilarityFunction.java:40) at org.apache.cassandra.index.sai.plan.TopKProcessor.getScoreForRow(TopKProcessor.java:333) at org.apache.cassandra.index.sai.plan.TopKProcessor.processScoredPartition(TopKProcessor.java:276) at org.apache.cassandra.index.sai.plan.TopKProcessor.reorder(TopKProcessor.java:145) at org.apache.cassandra.index.sai.plan.StorageAttachedIndexQueryPlan.lambda$postProcessor$2(StorageAttachedIndexQueryPlan.java:233) at org.apache.cassandra.db.ReadCommand.postReconciliationProcessing(ReadCommand.java:566) at org.apache.cassandra.service.reads.range.RangeCommands.partitions(RangeCommands.java:60) ``` (Rebase of commit be64177)
michaelsembwever
pushed a commit
that referenced
this pull request
Feb 16, 2026
…2007) Fixes: riptano/cndb#15423 CNDB test: riptano/cndb#15427 This PR fixes a subtle bug exposed by the `FeaturesVersionSupportCATest.testANN` test, as well as other similarly named `FeaturesVersionSupport*Test` tests. The central issue is whether to create the `queryVector` object. The currently logic does so only when `useSyntheticScore()` is false. However, if a peer has it set to false and this node has it on true, we'll end up with an easily avoided NPE. I propose instead that we lazily load the vector when it is needed. This removes an unnecessary switch as well as removing an unnecessary ordering requirement on upgrades. ``` java.lang.NullPointerException at io.github.jbellis.jvector.vector.VectorUtil.squareL2Distance(VectorUtil.java:85) at io.github.jbellis.jvector.vector.VectorSimilarityFunction$1.compare(VectorSimilarityFunction.java:40) at org.apache.cassandra.index.sai.plan.TopKProcessor.getScoreForRow(TopKProcessor.java:333) at org.apache.cassandra.index.sai.plan.TopKProcessor.processScoredPartition(TopKProcessor.java:276) at org.apache.cassandra.index.sai.plan.TopKProcessor.reorder(TopKProcessor.java:145) at org.apache.cassandra.index.sai.plan.StorageAttachedIndexQueryPlan.lambda$postProcessor$2(StorageAttachedIndexQueryPlan.java:233) at org.apache.cassandra.db.ReadCommand.postReconciliationProcessing(ReadCommand.java:566) at org.apache.cassandra.service.reads.range.RangeCommands.partitions(RangeCommands.java:60) ``` (Rebase of commit be64177)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What is the issue
Fixes: https://github.com/riptano/cndb/issues/15423
CNDB test: https://github.com/riptano/cndb/pull/15427
What does this PR fix and why was it fixed
This PR fixes a subtle bug exposed by the
FeaturesVersionSupportCATest.testANNtest, as well as other similarly namedFeaturesVersionSupport*Testtests. The central issue is whether to create thequeryVectorobject. The currently logic does so only whenuseSyntheticScore()is false. However, if a peer has it set to false and this node has it on true, we'll end up with an easily avoided NPE. I propose instead that we lazily load the vector when it is needed. This removes an unnecessary switch as well as removing an unnecessary ordering requirement on upgrades.