Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index/file_category.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ func decodeCategory(c byte) (FileCategory, error) {
default:
return FileCategoryMissing, errors.New("unrecognized file category")
}
}
}
16 changes: 16 additions & 0 deletions index/indexdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ type indexData struct {

// rawConfigMasks contains the encoded RawConfig for each repository
rawConfigMasks []uint8

//topic
topic String
}

type symbolData struct {
Expand Down Expand Up @@ -188,6 +191,19 @@ func (d *indexData) getCategory(idx uint32) FileCategory {
return category
}

func (d *indexData) geTopic(idx uint32) String {
if len(d.topic) == 0 {
// So return 'Error'
return Error
}

topic, err := decodeTopic(d.topic[idx])
if err != nil {
return None
}
return topic
}

// calculates stats for files in the range [start, end).
func (d *indexData) calculateStatsForFileRange(start, end uint32) zoekt.RepoStats {
if start >= end {
Expand Down
13 changes: 13 additions & 0 deletions index/matchtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,19 @@ func (d *indexData) newMatchTree(q query.Q, opt matchTreeOpt) (matchTree, error)
},
}, nil

case *query.topic:
code, ok := d.metaData.LanguageMap[s.Language]
if !ok {
return &noMatchTree{Why: "topic"}, nil
}
return &docMatchTree{
reason: "topic",
numDocs: d.numDocs(),
predicate: func(docID uint32) bool {
return d.geTopic(docID) == code //replace getLanguage by getTopic
},
}, nil

case query.RawConfig:
return &docMatchTree{
reason: s.String(),
Expand Down
4 changes: 4 additions & 0 deletions index/toc.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ type indexTOC struct {
reposIDsBitmap simpleSection

ranks simpleSection

topic simpleSection
}

func (t *indexTOC) sections() []section {
Expand Down Expand Up @@ -132,6 +134,7 @@ func (t *indexTOC) sections() []section {
&t.contentChecksums,
&t.languages,
&t.runeDocSections,
&t.topic,
}
}

Expand Down Expand Up @@ -185,6 +188,7 @@ func (t *indexTOC) sectionsTaggedList() []taggedSection {
{"runeDocSections", &t.runeDocSections},
{"repos", &t.repos},
{"reposIDsBitmap", &t.reposIDsBitmap},
{"topic", &t.topic},

// We no longer write these sections, but we still return them here to avoid
// warnings about unknown sections.
Expand Down