Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
CascadingRadium committed Dec 13, 2024
1 parent cdad5b4 commit 3609ffc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 11 additions & 4 deletions segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,14 +479,22 @@ func (sb *SegmentBase) dictionary(field string) (rv *Dictionary, err error) {
}

// Thesaurus returns the thesaurus with the specified name, or an empty thesaurus if not found.
func (sb *SegmentBase) Thesaurus(name string) (segment.Thesaurus, error) {
func (s *SegmentBase) Thesaurus(name string) (segment.Thesaurus, error) {
thesaurus, err := s.thesaurus(name)
if err == nil && thesaurus == nil {
return emptyThesaurus, nil
}
return thesaurus, err
}

func (sb *SegmentBase) thesaurus(name string) (rv *Thesaurus, err error) {
fieldIDPlus1 := sb.fieldsMap[name]
if fieldIDPlus1 == 0 {
return nil, nil
}
thesaurusStart := sb.fieldsSectionsMap[fieldIDPlus1-1][SectionSynonymIndex]
if thesaurusStart > 0 {
rv := &Thesaurus{
rv = &Thesaurus{
sb: sb,
name: name,
fieldID: fieldIDPlus1 - 1,
Expand All @@ -507,9 +515,8 @@ func (sb *SegmentBase) Thesaurus(name string) (segment.Thesaurus, error) {
if err != nil {
return nil, fmt.Errorf("thesaurus name %s vellum reader err: %v", name, err)
}
return rv, nil
}
return emptyThesaurus, nil
return rv, nil
}

// visitDocumentCtx holds data structures that are reusable across
Expand Down
6 changes: 3 additions & 3 deletions zap.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ In a synonyms index, the relationship between a term and its synonyms is represe
Each 64-bit entry consists of two parts: the first 32 bits represent the Term ID (TID),
and the next 32 bits represent the Document Number (DN).

[{~~~~~+~~~~~}{~~~~~+~~~~~}...{~~~~~+~~~~~}]
| TID | DN || TID | DN | | TID | DN |
[{~~~~~+~~~~~}{~~~~~+~~~~~}...{~~~~~+~~~~~}]
[{~~~~~+~~~~}{~~~~~+~~~~}...{~~~~~+~~~~}]
| TID | DN || TID | DN | | TID | DN |
[{~~~~~+~~~~}{~~~~~+~~~~}...{~~~~~+~~~~}]

TID - Term ID (32-bit)
DN - Document Number (32-bit)
Expand Down

0 comments on commit 3609ffc

Please sign in to comment.