-
Notifications
You must be signed in to change notification settings - Fork 2
MB-69881: Re-architect vector search #32
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
base: master
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR refactors the vector search architecture to adopt a visitor-pattern based iteration model for eligible documents in filtered vector searches. The change adapts the existing code to implement the new SegmentEligibleDocuments interface from the bleve_index_api package.
Key Changes:
- Replaced direct slice return (
SegmentEligibleDocs) with an iterator-based approach (SegmentEligibleDocuments) - Introduced
eligibleDocumentListandeligibleDocumentIteratortypes to support the new visitor pattern - Updated
VectorReaderto use the newCount()method instead of directly checking slice length
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
vector.go
Outdated
| return eligibleDocumentIterator(edl.docNums) | ||
| } | ||
|
|
||
| type eligibleDocumentIterator []uint64 | ||
|
|
||
| func (edi eligibleDocumentIterator) Next() (uint64, bool) { | ||
| if len(edi) == 0 { | ||
| return 0, false | ||
| } | ||
| rv := edi[0] | ||
| edi = edi[1:] |
Copilot
AI
Dec 28, 2025
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.
The Iterator method returns a value type (eligibleDocumentIterator) that shares the underlying array with docNums. If the caller mutates the iterator's slice, it could inadvertently modify the original eligibleDocumentList's data. Consider returning a pointer to avoid this potential issue and to support proper state management in the iterator's Next method.
| return eligibleDocumentIterator(edl.docNums) | |
| } | |
| type eligibleDocumentIterator []uint64 | |
| func (edi eligibleDocumentIterator) Next() (uint64, bool) { | |
| if len(edi) == 0 { | |
| return 0, false | |
| } | |
| rv := edi[0] | |
| edi = edi[1:] | |
| return &eligibleDocumentIterator{ | |
| docNums: edl.docNums, | |
| pos: 0, | |
| } | |
| } | |
| type eligibleDocumentIterator struct { | |
| docNums []uint64 | |
| pos int | |
| } | |
| func (edi *eligibleDocumentIterator) Next() (uint64, bool) { | |
| if edi == nil || edi.pos >= len(edi.docNums) { | |
| return 0, false | |
| } | |
| rv := edi.docNums[edi.pos] | |
| edi.pos++ |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
SegmentEligibleDocumentsinterface which allows usage of visitor-pattern based iteration of eligible documents for filtered vector search.