Documentation ¶
Overview ¶
Package combinator contains methods for performing logical operations on queries.
Index ¶
- Variables
- func BlockTransform(blockSize int) func(string) []string
- func HashCQR(representation cqr.CommonQueryRepresentation) uint64
- func NewLogicalTree(query pipeline.Query, ss stats.StatisticsSource, seen QueryCacher) (LogicalTree, QueryCacher, error)
- type AdjAtom
- type Atom
- type Clause
- type Combinator
- type DiskvQueryCache
- type Document
- type Documents
- type FileQueryCache
- type LogicalTree
- type LogicalTreeNode
- type MapQueryCache
- type Operator
- type QueryCacher
Constants ¶
This section is empty.
Variables ¶
var ( // OrOperator combines documents using `OR`. OrOperator = orOperator{} // AndOperator combines documents using `AND`. AndOperator = andOperator{} // NotOperator combines documents using `NOT`. NotOperator = notOperator{} )
var ErrCacheMiss = errors.New("cache miss error")
ErrCacheMiss indicates that a read did not fail, but the item was not present in the cache.
Functions ¶
func BlockTransform ¶
BlockTransform determines how diskv should partition folders.
func HashCQR ¶
func HashCQR(representation cqr.CommonQueryRepresentation) uint64
HashCQR creates a hash of the query.
func NewLogicalTree ¶
func NewLogicalTree(query pipeline.Query, ss stats.StatisticsSource, seen QueryCacher) (LogicalTree, QueryCacher, error)
NewLogicalTree creates a new logical tree. If the operator of the query is unknown (i.e. it is not one of `or`, `and`, `not`, or an `adj` operator) the default operator will be `or`.
Note that once one tree has been constructed, the returned map can be used to save processing.
Types ¶
type AdjAtom ¶
type AdjAtom struct {
Clause
}
AdjAtom is a special type of atom for adjacent queries.
func NewAdjAtom ¶
func NewAdjAtom(query cqr.BooleanQuery) AdjAtom
NewAdjAtom creates a new adjacent atom.
func (AdjAtom) Documents ¶
func (a AdjAtom) Documents(cache QueryCacher) Documents
Documents returns the documents retrieved by the adjacency operator.
func (AdjAtom) Query ¶
func (a AdjAtom) Query() cqr.CommonQueryRepresentation
Query returns the underlying query of the adjacency operator.
type Atom ¶
Atom is the smallest possible component of a query.
func (Atom) Documents ¶
func (a Atom) Documents(cache QueryCacher) Documents
Documents returns the documents retrieved by the atom.
func (Atom) Query ¶
func (a Atom) Query() cqr.CommonQueryRepresentation
Query returns the underlying query of the atom.
type Clause ¶
type Clause struct { Hash uint64 Query cqr.CommonQueryRepresentation }
Clause is the most basic component of a logical tree.
type Combinator ¶
type Combinator struct { Operator Clause Clauses []LogicalTreeNode N float64 R float64 }
Combinator is an operator in a query.
func NewCombinator ¶
func NewCombinator(query cqr.BooleanQuery, operator Operator, clauses ...LogicalTreeNode) Combinator
NewCombinator creates a new combinator.
func (Combinator) Documents ¶
func (c Combinator) Documents(cache QueryCacher) Documents
Documents returns the documents retrieved by the combinator.
func (Combinator) Query ¶
func (c Combinator) Query() cqr.CommonQueryRepresentation
Query returns the underlying query of the combinator.
type DiskvQueryCache ¶
DiskvQueryCache caches results using diskv.
func (DiskvQueryCache) Get ¶
func (d DiskvQueryCache) Get(query cqr.CommonQueryRepresentation) (Documents, error)
Get looks up results from disk.
func (DiskvQueryCache) Set ¶
func (d DiskvQueryCache) Set(query cqr.CommonQueryRepresentation, docs Documents) error
Set caches results to disk.
type Documents ¶
type Documents []Document
Documents are a group of retrieved documents.
func (Documents) Results ¶
func (d Documents) Results(query pipeline.Query, run string) trecresults.ResultList
Results converts the documents from the resulting logical operator tree into eval-compatible trec results.
type FileQueryCache ¶
type FileQueryCache struct {
// contains filtered or unexported fields
}
FileQueryCache caches results in a flat-file format in a single directory. This cacher will be faster than diskv as it does not use gob encoding.
func (FileQueryCache) Get ¶
func (f FileQueryCache) Get(query cqr.CommonQueryRepresentation) (Documents, error)
Get looks up results from disk.
func (FileQueryCache) Set ¶
func (f FileQueryCache) Set(query cqr.CommonQueryRepresentation, docs Documents) error
Set caches results to disk.
type LogicalTree ¶
type LogicalTree struct { Root LogicalTreeNode // contains filtered or unexported fields }
LogicalTree can compute the number of documents retrieved for atomic components.
func NewShallowLogicalTree ¶
func NewShallowLogicalTree(query pipeline.Query, s stats.StatisticsSource, relevant Documents) (LogicalTree, error)
func (LogicalTree) Documents ¶
func (root LogicalTree) Documents(cache QueryCacher) Documents
Documents returns the documents that the tree (query) would return if executed.
func (LogicalTree) ToCQR ¶
func (root LogicalTree) ToCQR() cqr.CommonQueryRepresentation
ToCQR creates a query backwards from a logical tree.
type LogicalTreeNode ¶
type LogicalTreeNode interface { Query() cqr.CommonQueryRepresentation Documents(cache QueryCacher) Documents String() string }
LogicalTreeNode is a node in a logical tree.
type MapQueryCache ¶
type MapQueryCache struct {
// contains filtered or unexported fields
}
MapQueryCache caches results to memory.
func (MapQueryCache) Get ¶
func (m MapQueryCache) Get(query cqr.CommonQueryRepresentation) (Documents, error)
Get looks up results in a map.
func (MapQueryCache) Set ¶
func (m MapQueryCache) Set(query cqr.CommonQueryRepresentation, docs Documents) error
Set caches results to a map.
type Operator ¶
type Operator interface { Combine(clauses []LogicalTreeNode, cache QueryCacher) Documents String() string }
Operator can combine different nodes of a tree together.
type QueryCacher ¶
type QueryCacher interface { Get(query cqr.CommonQueryRepresentation) (Documents, error) Set(query cqr.CommonQueryRepresentation, docs Documents) error }
QueryCacher models a way to cache (either persistent or not) queries and the documents they retrieve.
func NewDiskvQueryCache ¶
func NewDiskvQueryCache(dv *diskv.Diskv) QueryCacher
NewDiskvQueryCache creates a new on-disk cache with the specified diskv parameters.
func NewFileQueryCache ¶
func NewFileQueryCache(path string) QueryCacher
NewFileQueryCache creates a new disk-based file query cache.
func NewMapQueryCache ¶
func NewMapQueryCache() QueryCacher
NewMapQueryCache creates a query cache out of a regular go map.