Skip to content

Commit

Permalink
implementing the Count() API for the postings list, updated todos
Browse files Browse the repository at this point in the history
  • Loading branch information
Thejas-bhat committed Aug 9, 2023
1 parent 5af86b8 commit 165d9a5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/blevesearch/vellum"
)

const Version uint32 = 16
const Version uint32 = 15

const Type string = "zap"

Expand Down
4 changes: 4 additions & 0 deletions section_vector_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ func (vo *vectorIndexOpaque) writeVectorIndexes(w *CountHashWriter) (offset uint

// fixme: this can cause a write amplification. need to improve this.
// todo: might need to a reformating to optimize according to mmap needs.
// reformating idea: storing all the IDs mapping towards the end of the
// section would be help avoiding in paging in this data as part of a page
// (which is to load a non-cacheable info like index). this could help the
// paging costs
for vecID, docIDs := range docIDsMap {
// write the vecID
_, err := writeUvarints(w, vecID)
Expand Down
12 changes: 10 additions & 2 deletions vector_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ func (vp *VecPosting) Size() int {
// the score is actually a float32 value and in order to store it as a uint32 in
// the bitmap, we use the IEEE 754 floating point format.
type VecPostingsList struct {
// todo: perhaps we don't even need to store a bitmap if there is only
// one similar vector the query, but rather store it as a field value
// in the struct
except *roaring64.Bitmap
postings *roaring64.Bitmap
}
Expand Down Expand Up @@ -90,8 +93,13 @@ func (vpl *VecPostingsList) Size() int {
return 0
}

func (vpl *VecPostingsList) Count() uint64 {
return 0
func (p *VecPostingsList) Count() uint64 {
n := p.postings.GetCardinality()
var e uint64
if p.except != nil {
e = p.postings.AndCardinality(p.except)
}
return n - e
}

func (vpl *VecPostingsList) ResetBytesRead(val uint64) {
Expand Down

0 comments on commit 165d9a5

Please sign in to comment.