Documentation ¶
Index ¶
- Variables
- func BuildIterator(qs graph.QuadStore, s Shape) graph.Iterator
- func IsNull(s Shape) bool
- func Iterate(ctx context.Context, qs graph.QuadStore, s Shape) *graph.IterateChain
- func One(s Shape) (graph.Ref, bool)
- func Walk(s Shape, fnc WalkFunc)
- type AllNodes
- type Comparison
- type Composite
- type Count
- type Except
- type Filter
- type Fixed
- type FixedTags
- type InternalQuad
- type Intersect
- type IntersectOpt
- type Lookup
- type Materialize
- type NodesFrom
- type Null
- type Optimizer
- type Page
- type QuadFilter
- type QuadIndexer
- type Quads
- type QuadsAction
- func (s QuadsAction) BuildIterator(qs graph.QuadStore) graph.Iterator
- func (s QuadsAction) Clone() QuadsAction
- func (s QuadsAction) Optimize(r Optimizer) (Shape, bool)
- func (s *QuadsAction) SetFilter(d quad.Direction, v graph.Ref)
- func (s QuadsAction) Simplify() Shape
- func (s QuadsAction) SimplifyFrom(quads Shape) Shape
- type Regexp
- type Save
- type Shape
- func AddFilters(nodes Shape, filters ...ValueFilter) Shape
- func Compare(nodes Shape, op iterator.Operator, v quad.Value) Shape
- func FilterQuads(subject, predicate, object, label []quad.Value) Shape
- func Has(from, via, nodes Shape, rev bool) Shape
- func HasLabels(from, via, nodes, labels Shape, rev bool) Shape
- func In(from, via, labels Shape, tags ...string) Shape
- func IntersectOptional(s, opt Shape) Shape
- func IntersectShapes(s1, s2 Shape) Shape
- func Labels(from Shape) Shape
- func Optimize(s Shape, qs graph.QuadStore) (Shape, bool)
- func Out(from, via, labels Shape, tags ...string) Shape
- func Predicates(from Shape, in bool) Shape
- func SavePredicates(from Shape, in bool, tag string) Shape
- func SaveVia(from, via Shape, tag string, rev, opt bool) Shape
- func SaveViaLabels(from, via, labels Shape, tag string, rev, opt bool) Shape
- type Sort
- type Union
- type Unique
- type ValueFilter
- type WalkFunc
- type Wildcard
Constants ¶
This section is empty.
Variables ¶
var MaterializeThreshold = 100 // TODO: tune
Functions ¶
func BuildIterator ¶
BuildIterator optimizes the shape and builds a corresponding iterator tree.
func IsNull ¶
IsNull safely checks if shape represents an empty set. It accounts for both Null and nil.
Types ¶
type Comparison ¶
Comparison is a value filter that evaluates binary operation in reference to a fixed value.
func (Comparison) BuildIterator ¶
type Composite ¶
type Composite interface {
Simplify() Shape
}
Composite shape can be simplified to a tree of more basic shapes.
type Count ¶
type Count struct {
Values Shape
}
Count returns a count of objects in source as a single value. It always returns exactly one value.
type Except ¶
type Except struct { Exclude Shape // nodes to exclude From Shape // a set of all nodes to exclude from; nil means AllNodes }
Except excludes a set on nodes from a source. If source is nil, AllNodes is assumed.
type Filter ¶
type Filter struct { From Shape // source that will be filtered Filters []ValueFilter // filters to apply }
Filter filters all values from the source using a list of operations.
type FixedTags ¶
FixedTags adds a set of fixed tag values to query results. It does not affect query execution in any other way.
Shape implementations should try to push these objects up the tree during optimization process.
func (FixedTags) BuildIterator ¶
type InternalQuad ¶
InternalQuad is an internal representation of quad index in QuadStore.
type Intersect ¶
type Intersect []Shape
Intersect computes an intersection of nodes between multiple queries. Similar to And iterator.
func (Intersect) BuildIterator ¶
type IntersectOpt ¶ added in v0.7.6
IntersectOpt is like Intersect but it also joins optional query shapes to the main query.
func (*IntersectOpt) Add ¶ added in v0.7.6
func (s *IntersectOpt) Add(arr ...Shape)
func (*IntersectOpt) AddOptional ¶ added in v0.7.6
func (s *IntersectOpt) AddOptional(arr ...Shape)
func (IntersectOpt) BuildIterator ¶ added in v0.7.6
func (s IntersectOpt) BuildIterator(qs graph.QuadStore) graph.Iterator
type Materialize ¶
Materialize loads results of sub-query into memory during execution to speedup iteration.
func (Materialize) BuildIterator ¶
func (s Materialize) BuildIterator(qs graph.QuadStore) graph.Iterator
type NodesFrom ¶
NodesFrom extracts nodes on a given direction from source quads. Similar to HasA iterator.
func (NodesFrom) BuildIterator ¶
type Null ¶
type Null struct{}
Null represent an empty set. Mostly used as a safe alias for nil shape.
type QuadFilter ¶
QuadFilter is a constraint used to filter quads that have a certain set of values on a given direction. Analog of LinksTo iterator.
type QuadIndexer ¶
type QuadIndexer interface { // SizeOfIndex returns a size of a quad index with given constraints. SizeOfIndex(c map[quad.Direction]graph.Ref) (int64, bool) // LookupQuadIndex finds a quad that matches a given constraint. // It returns false if quad was not found, or there are multiple quads matching constraint. LookupQuadIndex(c map[quad.Direction]graph.Ref) (InternalQuad, bool) }
QuadIndexer is an optional interface for quad stores that keep an index of quad directions.
It is used to optimize shapes based on stats from these indexes.
type Quads ¶
type Quads []QuadFilter
Quads is a selector of quads with a given set of node constraints. Empty or nil Quads is equivalent to AllQuads. Equivalent to And(AllQuads,LinksTo*) iterator tree.
func (*Quads) Intersect ¶
func (s *Quads) Intersect(q ...QuadFilter)
type QuadsAction ¶
type QuadsAction struct { Size int64 // approximate size; zero means undefined Result quad.Direction Save map[quad.Direction][]string Filter map[quad.Direction]graph.Ref }
QuadsAction represents a set of actions that can be done to a set of quads in a single scan pass. It filters quads according to Filter constraints (equivalent of LinksTo), tags directions using tags in Save field and returns a specified quad direction as result of the iterator (equivalent of HasA). Optionally, Size field may be set to indicate an approximate number of quads that will be returned by this query.
func (QuadsAction) BuildIterator ¶
func (s QuadsAction) BuildIterator(qs graph.QuadStore) graph.Iterator
func (QuadsAction) Clone ¶
func (s QuadsAction) Clone() QuadsAction
func (QuadsAction) Simplify ¶
func (s QuadsAction) Simplify() Shape
func (QuadsAction) SimplifyFrom ¶ added in v0.7.6
func (s QuadsAction) SimplifyFrom(quads Shape) Shape
type Regexp ¶
Regexp filters values using regular expression.
Since regexp patterns can not be optimized in most cases, Wildcard should be used if possible.
type Shape ¶
type Shape interface { // BuildIterator constructs an iterator tree from a given shapes and binds it to QuadStore. BuildIterator(qs graph.QuadStore) graph.Iterator // Optimize runs an optimization pass over a query shape. // // It returns a bool that indicates if shape was replaced and should always return a copy of shape in this case. // In case no optimizations were made, it returns the same unmodified shape. // // If Optimizer is specified, it will be used instead of default optimizations. Optimize(r Optimizer) (Shape, bool) }
Shape represent a query tree shape.
func AddFilters ¶
func AddFilters(nodes Shape, filters ...ValueFilter) Shape
func FilterQuads ¶ added in v0.7.6
func IntersectOptional ¶ added in v0.7.6
func IntersectShapes ¶
func Optimize ¶
Optimize applies generic optimizations for the tree. If quad store is specified it will also resolve Lookups and apply any specific optimizations. Should not be used with Simplify - it will fold query to a compact form again.
func Predicates ¶
type Sort ¶ added in v0.7.6
type Sort struct {
From Shape
}
func (Sort) BuildIterator ¶ added in v0.7.6
type Union ¶
type Union []Shape
Union joins results of multiple queries together. It does not make results unique.
func UnionShapes ¶
type ValueFilter ¶
ValueFilter is an interface for iterator wrappers that can filter node values.
type WalkFunc ¶
WalkFunc is used to visit all shapes in the tree. If false is returned, branch will not be traversed further.
type Wildcard ¶ added in v0.7.1
type Wildcard struct {
Pattern string // allowed wildcards are: % and ?
}
Wildcard is a filter for string patterns.
% - zero or more characters ? - exactly one character