Version: v0.0.0-...-c88c75b Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2022 License: BSD-3-Clause Imports: 10 Imported by: 0



Post-ranking happens on the source backend (because it has the source files in the kernel’s page cache). In the post-ranking phase we can do (limited) source file level analysis, such as in which scope the query string was matched (comment, top-level, sub-level).

Pre-ranking happens on dcs-web after the index backends provided their results. Without looking at file contents at all, we assign a preliminary ranking to each file based on its database entries and whether the query string matches parts of the filename.




This section is empty.


This section is empty.


func PostRank

func PostRank(opts RankingOpts, match *regexp.Match, querystr *QueryStr) float32

func ReadRankingData

func ReadRankingData(path string) error

ReadRankingData reads the pre-computed rankings from |path|. It must be called before ResultPath.Rank() is called, otherwise Rank() won’t return meaningful results.


type QueryStr

type QueryStr struct {
	// contains filtered or unexported fields

Represents a query string with pre-compiled regular expressions for faster matching.

func NewQueryStr

func NewQueryStr(query string) QueryStr

func (*QueryStr) Match

func (qs *QueryStr) Match(path *string) float32

type RankingOpts

type RankingOpts struct {
	// Map of file suffix (e.g. ".c") ranking. This is filled in based on the
	// filetype= parameter (which is extracted from the query string).
	Suffixes map[string]float32
	// Same thing, but for the nfiletype parameter (from the -filetype:
	// keywords in the query).
	Nsuffixes map[string]float32

	// pre-ranking: amount of reverse dependencies
	Rdep bool

	// pre-ranking: popcon installation count
	Inst bool

	// pre-ranking: filetype
	Filetype bool

	// pre-ranking: does the search query match the path?
	Pathmatch bool

	// pre-ranking: does the search query match the source package name?
	Sourcepkgmatch bool

	// post-ranking: in which scope is the match?
	Scope bool

	// post-ranking: does the search query (with enforced word boundaries)
	// match the line?
	Linematch bool

	// meta: turns on all rankings and uses 'optimal' weights (as determined in
	// the thesis).
	Weighted bool

func RankingOptsFromQuery

func RankingOptsFromQuery(query url.Values) RankingOpts

type ResultPath

type ResultPath struct {
	Path         string
	Position     int
	SourcePkgIdx [2]int
	Ranking      float32

The regular expression trigram index provides us a path to a potential result. This data structure represents such a path and allows for ranking and sorting each path.

func (*ResultPath) Rank

func (rp *ResultPath) Rank(opts *RankingOpts)

type ResultPaths

type ResultPaths []ResultPath

func (ResultPaths) Len

func (r ResultPaths) Len() int

func (ResultPaths) Less

func (r ResultPaths) Less(i, j int) bool

func (ResultPaths) Swap

func (r ResultPaths) Swap(i, j int)

type StoredRanking

type StoredRanking struct {
	Inst float32
	Rdep float32

Represents an entry from our ranking database (determined by using the meta information about source packages).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL