-
Notifications
You must be signed in to change notification settings - Fork 22
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
CNDB-12456: Add ANN_OPTIONS to CQL SELECT queries #1525
Conversation
7c35d1e
to
42a25dc
Compare
42a25dc
to
fbc3e21
Compare
fbc3e21
to
1c76376
Compare
The last commit tries the alternative approach mentioned above, placing the new |
Agreed
The flag makes sense to me
I like the last version - placing the new |
Thanks for the feedback. The patch is ready for review. |
16af975
to
25a8223
Compare
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.
Looks great, left some tiny comments/questions
src/java/org/apache/cassandra/cql3/statements/SelectOptions.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/db/commitlog/CommitLogDescriptor.java
Outdated
Show resolved
Hide resolved
25a8223
to
8d68bf4
Compare
Thanks for the feedback. I've addressed some of the suggestions, I hope to address the rest of them tomorrow. |
They all look good to me, thanks!
Just ping me when you are ready, thanks |
Set<InetAddressAndPort> badNodes = MessagingService.instance().endpointsWithVersionBelow(MessagingService.VERSION_DS_11); | ||
if (MessagingService.current_version < MessagingService.VERSION_DS_11) | ||
badNodes.add(FBUtilities.getBroadcastAddressAndPort()); |
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.
Oh, so we were missing the current one, good catch!
@@ -238,7 +238,7 @@ else if (fromHeader != null) | |||
descriptor = fromHeader; | |||
else descriptor = fromName; | |||
|
|||
if (descriptor.version > CommitLogDescriptor.current_version) | |||
if (descriptor.version > CommitLogDescriptor.CURRENT_VERSION) |
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.
nit: Sonar complains that now we need to remove the Visible for testing annotation. Feel free to do it on commit
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.
That seems unrelated to the changes, but removing 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.
Looks great, except after the latest changes shouldRejectANOptions
is failing with the error below. Please feel free to commit once you update that test. Thanks
java.lang.AssertionError:
Expecting throwable message:
"ANN options are not supported in clusters below DS 11."
to contain:
"SAI doesn't support ANN options yet."
but did not.
rangeRestrictedTest
- seems unrelated flaky; I just linked a ticket from Butler quickly.
And one more small comment that could be addressed on commit.
Side note: It would have been nice code coverage for new classes to report 100%, which I am surprised it does not for ANNOptions, but looking into the lines it seems ok?
The test results on the other PR seem to show some issue. Please hold on committing this one until we clarify them. Thanks |
That fails now because we have changed the current version. I'm simply removing the test because
I guess changing the casing of the |
Agreed about |
+1 |
Coverage report of |
1a158e3
to
2776f01
Compare
It seems we are on the same page
No |
7c28f40
to
601a78b
Compare
My +1 still stands with the latest changes, on clean CI here and the other branch. Thanks |
* Rename MessagingService.VERSION_SG_10 to MessagingService.VERSION_DS_10. * Add the new MessagingService.VERSION_DS_11 messaging version, which is not used as current yet. * Add a new `ds.current_messaging_version` system property to specify the current messaging version. To use the new messaging version, CC should be started with -Dds.current_messaging_version=101.
Add new CQL syntax to specify ANN options in ANN queries. The only available ANN option at the moment is `rerank_k`, which is the amplified limit for the ANN query to get more accurate results. This doesn't add support for ANN options to SAI, which is planned to be done separately. The new options are included in the ANN expression of the `RowFilter` of the `ReadCommand` that represents the query. Thus, they are included in the serialization of the command in the coordiantor and delivered to the replicas. The new ANN options require that the messaging version of all the nodes is at least VERSION_DS_11. That version is not yet used by default, to use it CC should be started with -Dds.current_messaging_version=101.
601a78b
to
08aef9d
Compare
|
✔️ Build ds-cassandra-pr-gate/PR-1525 approved by ButlerApproved by Butler |
Add
ANN_OPTIONS
to CQLSELECT
queries, as described in this document: https://docs.google.com/document/d/1Q2SkE1aBkcy25DnCWkdUqpCf8rZA6R_AOU6bbORbarIThe proposed syntax is:
The new options and not something specific to SAI, same as the
ORDER BY col ANN OF val
part.Internally, the ANN options are an attribute of the
RowFilter
included in everyReadCommand
. Every index implementation receives them as part of theReadCommand
passed in methods such asIndex.validate(ReadCommand)
,Index.Group.queryPlanFor(RowFilter)
orIndex.QueryPlan.searcherFor(ReadCommand)
.Currently SAI rejects queries with ANN options. I think consuming those options is something we can do in a separate ticket, keeping this one focused on the CQL and internode messaging part.
This patch increases the internode messaging version because the ANN options have to be included in the serialization of the
ReadCommand
they belong to. Hopefully we won't need to bump the messaging version again if we add new ANN options.I have chosen to include the options in the
RowFilter
because it seemed the cleaner approach, and so possibly less problematic when rebasing on Apache. The downside is that it adds a 32-bit int to the serialization of everySELECT
query. An alternative, possibly more convoluted approach to save us those 4 extra bytes could be placing the ANN options inside the relevant ANNRowFilter.Expression
. @jbellis @ekaterinadimitrova2 should I give a go to this alternative approach?Checklist before you submit for review
NoSpamLogger
for log lines that may appear frequently in the logs