Commit 59faf8a
authored
CNDB-12922: Implement rerank_k in SAI ANN queries (#1562)
### What is the issue
Fixes riptano/cndb#12922
### What does this PR fix and why was it fixed
This PR follows up on #1525 by integrating the CQL configured `rerank_k`
in to SAI so that the ANN query can take the user input and let it
influence query execution.
Key changes:
* Bump `MessagingService` to `VERSION_DS_11`
* Fixes implementation of
`MessagingService.instance().endpointsWithVersionBelow` by using the
`keyspace` variant, which is necessary for CNDB.
* When configured, the `rerank_k` is used as the graph's `rerankK`
parameter. The only detail worth mentioning here is that we ignore the
segment proportionality computation if `rerank_k` is provided. This
diverges from the smart default design, but not too greatly.
* Added a guardrail for `rerank_k` to prevent it from exceeding 4 times
the `cassandra.sai.vector_search.max_top_k`. This is debatable and
easily changed, so please let me know if we want something different.
* Made the in memory brute force cost comparison logic use the `rerankK`
value instead of the `limit`. I am pretty sure this is correct, but
please review closely.
Instead of validating `rerank_k`'s value within the query, I added a
test that ensures that as we increase the rerank k, we increase the
recall.
CNDB pr: riptano/cndb#130951 parent cc92316 commit 59faf8a
File tree
20 files changed
+357
-81
lines changed- src/java/org/apache/cassandra
- config
- cql3/statements
- db/filter
- guardrails
- index/sai
- disk
- v1
- v2
- vector
- plan
- net
- test
- distributed/org/apache/cassandra/distributed/test/sai
- unit/org/apache/cassandra
- db/filter
- guardrails
- index/sai
- cql
- memory
20 files changed
+357
-81
lines changedLines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
588 | 588 | | |
589 | 589 | | |
590 | 590 | | |
591 | | - | |
| 591 | + | |
592 | 592 | | |
593 | 593 | | |
594 | 594 | | |
| |||
602 | 602 | | |
603 | 603 | | |
604 | 604 | | |
605 | | - | |
606 | 605 | | |
607 | 606 | | |
608 | 607 | | |
| |||
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
42 | | - | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | | - | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| 51 | + | |
| 52 | + | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
436 | | - | |
| 436 | + | |
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
63 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
64 | 69 | | |
65 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
66 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
67 | 85 | | |
68 | 86 | | |
69 | 87 | | |
| |||
74 | 92 | | |
75 | 93 | | |
76 | 94 | | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | 95 | | |
85 | 96 | | |
86 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
123 | 134 | | |
124 | 135 | | |
125 | 136 | | |
| |||
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| 85 | + | |
| 86 | + | |
84 | 87 | | |
85 | 88 | | |
86 | 89 | | |
| |||
165 | 168 | | |
166 | 169 | | |
167 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
168 | 176 | | |
169 | 177 | | |
170 | 178 | | |
| |||
269 | 277 | | |
270 | 278 | | |
271 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
272 | 284 | | |
273 | 285 | | |
274 | 286 | | |
| |||
Lines changed: 0 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
717 | 717 | | |
718 | 718 | | |
719 | 719 | | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
724 | 720 | | |
725 | 721 | | |
726 | 722 | | |
| |||
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | | - | |
| 208 | + | |
209 | 209 | | |
210 | | - | |
211 | | - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
212 | 213 | | |
213 | 214 | | |
214 | 215 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
210 | 212 | | |
211 | 213 | | |
212 | 214 | | |
| |||
Lines changed: 5 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
431 | | - | |
| 431 | + | |
432 | 432 | | |
433 | | - | |
434 | 433 | | |
435 | 434 | | |
436 | 435 | | |
| |||
472 | 471 | | |
473 | 472 | | |
474 | 473 | | |
475 | | - | |
| 474 | + | |
476 | 475 | | |
477 | 476 | | |
478 | 477 | | |
| |||
611 | 610 | | |
612 | 611 | | |
613 | 612 | | |
614 | | - | |
| 613 | + | |
615 | 614 | | |
616 | | - | |
| 615 | + | |
617 | 616 | | |
618 | 617 | | |
619 | 618 | | |
| |||
0 commit comments