query

package
v0.0.0-...-9a66a57 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeFileMatch uint8 = iota
	TypeFileName
	TypeRepo
)

Variables

This section is empty.

Functions

func LowerRegexp

func LowerRegexp(r *syntax.Regexp) *syntax.Regexp

func VisitAtoms

func VisitAtoms(q Q, v func(q Q))

VisitAtoms runs `v` on all atom queries within `q`.

Types

type And

type And struct {
	Children []Q
}

And is matched when all its children are.

func (*And) String

func (q *And) String() string

type Branch

type Branch struct {
	Pattern string

	// exact is true if we want to Pattern to equal branch.
	Exact bool
}

Branch limits search to a specific branch.

func (*Branch) String

func (q *Branch) String() string

type BranchRepos

type BranchRepos struct {
	Branch string
	Repos  *roaring.Bitmap
}

BranchRepos is a (branch, sourcegraph repo ids bitmap) tuple. It is a Sourcegraph addition.

type BranchesRepos

type BranchesRepos struct {
	List []BranchRepos
}

BranchesRepos is a slice of BranchRepos to match. It is a Sourcegraph addition and only used in the RPC interface for efficient checking of large repo lists.

func NewSingleBranchesRepos

func NewSingleBranchesRepos(branch string, ids ...uint32) *BranchesRepos

NewSingleBranchesRepos is a helper for creating a BranchesRepos which searches a single branch.

func (BranchesRepos) MarshalBinary

func (q BranchesRepos) MarshalBinary() ([]byte, error)

MarshalBinary implements a specialized encoder for BranchesRepos.

func (*BranchesRepos) String

func (q *BranchesRepos) String() string

func (*BranchesRepos) UnmarshalBinary

func (q *BranchesRepos) UnmarshalBinary(b []byte) (err error)

UnmarshalBinary implements a specialized decoder for BranchesRepos.

type Const

type Const struct {
	Value bool
}

func (*Const) String

func (q *Const) String() string

type GobCache

type GobCache struct {
	Q
	// contains filtered or unexported fields
}

GobCache exists so we only pay the cost of marshalling a query once when we aggregate it out over all the replicas.

Our query and eval layer do not support GobCache. Instead, at the gob boundaries (RPC and Streaming) we check if the Q is a GobCache and unwrap it.

"I wish we could get rid of this code soon enough" - tomas

func (*GobCache) GobDecode

func (q *GobCache) GobDecode(data []byte) error

GobDecode implements gob.Decoder.

func (*GobCache) GobEncode

func (q *GobCache) GobEncode() ([]byte, error)

GobEncode implements gob.Encoder.

func (*GobCache) String

func (q *GobCache) String() string

type Language

type Language struct {
	Language string
}

func (*Language) String

func (l *Language) String() string

type Not

type Not struct {
	Child Q
}

Not inverts the meaning of its child.

func (*Not) String

func (q *Not) String() string

type Or

type Or struct {
	Children []Q
}

Or is matched when any of its children is matched.

func (*Or) String

func (q *Or) String() string

type Q

type Q interface {
	String() string
}

Q is a representation for a possibly hierarchical search query.

func ExpandFileContent

func ExpandFileContent(q Q) Q

Expand expands Substr queries into (OR file_substr content_substr) queries, and the same for Regexp queries..

func Map

func Map(q Q, f func(q Q) Q) Q

Map runs f over the q.

func NewAnd

func NewAnd(qs ...Q) Q

NewAnd is syntactic sugar for constructing And queries.

func NewOr

func NewOr(qs ...Q) Q

NewOr is syntactic sugar for constructing Or queries.

func Parse

func Parse(qStr string) (Q, error)

Parse parses a string into a query.

func RPCUnwrap

func RPCUnwrap(q Q) Q

RPCUnwrap processes q to remove RPC specific elements from q. This is needed because gob isn't flexible enough for us. This should be called by RPC servers at the client/server boundary so that q works with the rest of zoekt.

func Simplify

func Simplify(q Q) Q

type RawConfig

type RawConfig uint64

RawConfig filters repositories based on their encoded RawConfig map.

const (
	RcOnlyPublic   RawConfig = 1
	RcOnlyPrivate  RawConfig = 2
	RcOnlyForks    RawConfig = 1 << 2
	RcNoForks      RawConfig = 2 << 2
	RcOnlyArchived RawConfig = 1 << 4
	RcNoArchived   RawConfig = 2 << 4
)

func (RawConfig) String

func (r RawConfig) String() string

type Regexp

type Regexp struct {
	Regexp        *syntax.Regexp
	FileName      bool
	Content       bool
	CaseSensitive bool
}

RegexpQuery is a query looking for regular expressions matches.

func (*Regexp) GobDecode

func (q *Regexp) GobDecode(data []byte) error

GobDecode implements gob.Decoder.

func (Regexp) GobEncode

func (q Regexp) GobEncode() ([]byte, error)

GobEncode implements gob.Encoder.

func (*Regexp) String

func (q *Regexp) String() string

type Repo

type Repo struct {
	Regexp *regexp.Regexp
}

func (*Repo) String

func (q *Repo) String() string

type RepoRegexp

type RepoRegexp struct {
	Regexp *regexp.Regexp
}

RepoRegexp is a Sourcegraph addition which searches documents where the repository name matches Regexp.

func (*RepoRegexp) GobDecode

func (q *RepoRegexp) GobDecode(data []byte) error

GobDecode implements gob.Decoder.

func (*RepoRegexp) GobEncode

func (q *RepoRegexp) GobEncode() ([]byte, error)

GobEncode implements gob.Encoder.

func (*RepoRegexp) String

func (q *RepoRegexp) String() string

type RepoSet

type RepoSet struct {
	Set map[string]bool
}

RepoSet is a list of repos to match. It is a Sourcegraph addition and only used in the RPC interface for efficient checking of large repo lists.

func NewRepoSet

func NewRepoSet(repo ...string) *RepoSet

func (*RepoSet) String

func (q *RepoSet) String() string

type Substring

type Substring struct {
	Pattern       string
	CaseSensitive bool

	// Match only filename
	FileName bool

	// Match only content
	Content bool
}

Substring is the most basic query: a query for a substring.

func (*Substring) String

func (q *Substring) String() string

type Symbol

type Symbol struct {
	Expr Q
}

Symbol finds a string that is a symbol.

func (*Symbol) String

func (s *Symbol) String() string

type Type

type Type struct {
	Child Q
	Type  uint8
}

Type changes the result type returned.

func (*Type) String

func (q *Type) String() string

Jump to

Keyboard shortcuts

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