Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CascadingRadium committed Dec 9, 2024
1 parent 877152d commit 8bbd323
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 8 deletions.
2 changes: 1 addition & 1 deletion section_synonym.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ func mergeSynonyms(synItr *SynonymsIterator, newDocNums []uint64, newRoaring *ro
synTermMap map[uint32]string, termSynMap map[string]uint32, newSynonymID uint32) (uint32, error) {
next, err := synItr.Next()
for next != nil && err == nil {
synNewDocNum := newDocNums[next.DocNum()]
synNewDocNum := newDocNums[next.Number()]
if synNewDocNum == docDropped {
return 0, fmt.Errorf("see hit with dropped docNum")
}
Expand Down
10 changes: 3 additions & 7 deletions synonym_posting.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func init() {
var si SynonymsIterator
reflectStaticSizeSynonymsIterator = int(reflect.TypeOf(si).Size())
var s Synonym
reflectStaticSizePosting = int(reflect.TypeOf(s).Size())
reflectStaticSizeSynonym = int(reflect.TypeOf(s).Size())
}

type SynonymsList struct {
Expand Down Expand Up @@ -205,7 +205,7 @@ type Synonym struct {
}

func (p *Synonym) Size() int {
sizeInBytes := reflectStaticSizePosting + SizeOfPtr +
sizeInBytes := reflectStaticSizeSynonym + SizeOfPtr +
len(p.term)

return sizeInBytes
Expand All @@ -215,11 +215,7 @@ func (s *Synonym) Term() string {
return s.term
}

func (s *Synonym) SynonymID() uint32 {
return s.synID
}

func (s *Synonym) DocNum() uint32 {
func (s *Synonym) Number() uint32 {
return s.docNum
}

Expand Down
45 changes: 45 additions & 0 deletions thesaurus.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"

"github.com/RoaringBitmap/roaring"
index "github.com/blevesearch/bleve_index_api"
segment "github.com/blevesearch/scorch_segment_api/v2"
"github.com/blevesearch/vellum"
)
Expand Down Expand Up @@ -112,3 +113,47 @@ func (t *Thesaurus) Contains(key []byte) (bool, error) {
}
return false, nil
}

// AutomatonIterator returns an iterator which only visits terms
// having the the vellum automaton and start/end key range
func (t *Thesaurus) AutomatonIterator(a segment.Automaton,
startKeyInclusive, endKeyExclusive []byte) segment.ThesaurusIterator {

Check failure on line 120 in thesaurus.go

View workflow job for this annotation

GitHub Actions / test (1.21.x, ubuntu-latest)

undefined: segment.ThesaurusIterator

Check failure on line 120 in thesaurus.go

View workflow job for this annotation

GitHub Actions / test (1.21.x, macos-latest)

undefined: segment.ThesaurusIterator

Check failure on line 120 in thesaurus.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, ubuntu-latest)

undefined: segment.ThesaurusIterator

Check failure on line 120 in thesaurus.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, macos-latest)

undefined: segment.ThesaurusIterator

Check failure on line 120 in thesaurus.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, ubuntu-latest)

undefined: segment.ThesaurusIterator
if t.fst != nil {
rv := &ThesaurusIterator{
t: t,
}

itr, err := t.fst.Search(a, startKeyInclusive, endKeyExclusive)
if err == nil {
rv.itr = itr
} else if err != vellum.ErrIteratorDone {
rv.err = err
}

return rv
}
return emptyThesaurusIterator
}

var emptyThesaurusIterator = &ThesaurusIterator{}

// ThesaurusIterator is an iterator for term dictionary
type ThesaurusIterator struct {
t *Thesaurus
itr vellum.Iterator
err error
entry index.ThesaurusEntry

Check failure on line 145 in thesaurus.go

View workflow job for this annotation

GitHub Actions / test (1.21.x, ubuntu-latest)

undefined: index.ThesaurusEntry

Check failure on line 145 in thesaurus.go

View workflow job for this annotation

GitHub Actions / test (1.21.x, macos-latest)

undefined: index.ThesaurusEntry

Check failure on line 145 in thesaurus.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, ubuntu-latest)

undefined: index.ThesaurusEntry

Check failure on line 145 in thesaurus.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, macos-latest)

undefined: index.ThesaurusEntry

Check failure on line 145 in thesaurus.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, ubuntu-latest)

undefined: index.ThesaurusEntry
}

// Next returns the next entry in the dictionary
func (i *ThesaurusIterator) Next() (*index.ThesaurusEntry, error) {

Check failure on line 149 in thesaurus.go

View workflow job for this annotation

GitHub Actions / test (1.21.x, ubuntu-latest)

undefined: index.ThesaurusEntry

Check failure on line 149 in thesaurus.go

View workflow job for this annotation

GitHub Actions / test (1.21.x, macos-latest)

undefined: index.ThesaurusEntry

Check failure on line 149 in thesaurus.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, ubuntu-latest)

undefined: index.ThesaurusEntry

Check failure on line 149 in thesaurus.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, macos-latest)

undefined: index.ThesaurusEntry

Check failure on line 149 in thesaurus.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, ubuntu-latest)

undefined: index.ThesaurusEntry
if i.err != nil && i.err != vellum.ErrIteratorDone {
return nil, i.err
} else if i.itr == nil || i.err == vellum.ErrIteratorDone {
return nil, nil
}
term, _ := i.itr.Current()
i.entry.Term = string(term)
i.err = i.itr.Next()
return &i.entry, nil
}

0 comments on commit 8bbd323

Please sign in to comment.