Skip to content

Conversation

@CascadingRadium
Copy link
Member

  • Adapt to new SegmentEligibleDocuments interface which allows usage of visitor-pattern based iteration of eligible documents for filtered vector search.

Copy link

Copilot AI left a 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 eligibleDocumentList and eligibleDocumentIterator types to support the new visitor pattern
  • Updated VectorReader to use the new Count() method instead of directly checking slice length

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

vector.go Outdated
Comment on lines 64 to 74
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:]
Copy link

Copilot AI Dec 28, 2025

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.

Suggested change
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++

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants