index

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2015 License: MIT, BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func File

func File() string

File returns the name of the index file to use. It is either $CSEARCHINDEX or $HOME/.csearchindex.

func Merge

func Merge(dst, src1, src2 string)

Merge creates a new index in the file dst that corresponds to merging the two indices src1 and src2. If both src1 and src2 claim responsibility for a path, src2 is assumed to be newer and is given preference.

Types

type Index

type Index struct {
	Verbose bool
	// contains filtered or unexported fields
}

An Index implements read-only access to a trigram index.

func Open

func Open(file string) *Index

func (*Index) Close

func (ix *Index) Close() error

func (*Index) Name

func (ix *Index) Name(fileid uint32) string

Name returns the name corresponding to the given fileid.

func (*Index) NameBytes

func (ix *Index) NameBytes(fileid uint32) []byte

NameBytes returns the name corresponding to the given fileid.

func (*Index) Paths

func (ix *Index) Paths() []string

Paths returns the list of indexed paths.

func (*Index) PostingAnd

func (ix *Index) PostingAnd(list []uint32, trigram uint32) []uint32

func (*Index) PostingList

func (ix *Index) PostingList(trigram uint32) []uint32

func (*Index) PostingOr

func (ix *Index) PostingOr(list []uint32, trigram uint32) []uint32

func (*Index) PostingQuery

func (ix *Index) PostingQuery(q *Query) []uint32

type IndexWriter

type IndexWriter struct {
	LogSkip bool // log information about skipped files
	Verbose bool // log status using package log
	// contains filtered or unexported fields
}

An IndexWriter creates an on-disk index corresponding to a set of files.

func Create

func Create(file string) *IndexWriter

Create returns a new IndexWriter that will write the index to file.

func (*IndexWriter) Add

func (ix *IndexWriter) Add(name string, f io.Reader) string

Add adds the file f to the index under the given name. It logs errors using package log.

func (*IndexWriter) AddFile

func (ix *IndexWriter) AddFile(name string)

AddFile adds the file with the given name (opened using os.Open) to the index. It logs errors using package log.

func (*IndexWriter) AddPaths

func (ix *IndexWriter) AddPaths(paths []string)

AddPaths adds the given paths to the index's list of paths.

func (*IndexWriter) Flush

func (ix *IndexWriter) Flush()

Flush flushes the index entry to the target file.

type Query

type Query struct {
	Op      QueryOp
	Trigram []string
	Sub     []*Query
}

A Query is a matching machine, like a regular expression, that matches some text and not other text. When we compute a Query from a regexp, the Query is a conservative version of the regexp: it matches everything the regexp would match, and probably quite a bit more. We can then filter target files by whether they match the Query (using a trigram index) before running the comparatively more expensive regexp machinery.

func RegexpQuery

func RegexpQuery(re *syntax.Regexp) *Query

RegexpQuery returns a Query for the given regexp.

func (*Query) String

func (q *Query) String() string

type QueryOp

type QueryOp int
const (
	QAll  QueryOp = iota // Everything matches
	QNone                // Nothing matches
	QAnd                 // All in Sub and Trigram must match
	QOr                  // At least one in Sub or Trigram must match
)

Jump to

Keyboard shortcuts

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