iterator

package
v0.7.7 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2019 License: Apache-2.0 Imports: 9 Imported by: 513

Documentation

Index

Constants

View Source
const MaterializeLimit = 1000

Variables

View Source
var DefaultMaxRecursiveSteps = 50

Functions

func IsNull added in v0.7.6

func IsNull(it graph.Iterator) bool

func IsNull2 added in v0.7.6

func IsNull2(it graph.IteratorShape) bool

func NewComparison

func NewComparison(sub graph.Iterator, op Operator, val quad.Value, qs graph.Namer) graph.Iterator

func NewRegex added in v0.6.0

func NewRegex(sub graph.Iterator, re *regexp.Regexp, qs graph.Namer) graph.Iterator

NewRegex returns an unary operator -- a filter across the values in the relevant subiterator. It works similarly to gremlin's filter{it.matches('exp')}, reducing the iterator set to values whose string representation passes a regular expression test.

func NewRegexWithRefs added in v0.7.6

func NewRegexWithRefs(sub graph.Iterator, re *regexp.Regexp, qs graph.Namer) graph.Iterator

NewRegexWithRefs is like NewRegex but allows regexp iterator to match IRIs and BNodes.

Consider using it carefully. In most cases it's better to reconsider your graph structure instead of relying on slow unoptimizable regexp.

An example of incorrect usage is to match IRIs:

<http://example.org/page>
<http://example.org/page/foo>

Via regexp like:

http://example.org/page.*

The right way is to explicitly link graph nodes and query them by this relation:

<http://example.org/page/foo> <type> <http://example.org/page>

func OutputQueryShapeForIterator

func OutputQueryShapeForIterator(it graph.Iterator, qs graph.Namer, outputMap map[string]interface{})

func RunFloatOp added in v0.6.0

func RunFloatOp(a quad.Float, op Operator, b quad.Float) bool

func RunIntOp

func RunIntOp(a quad.Int, op Operator, b quad.Int) bool

func RunStrOp added in v0.5.0

func RunStrOp(a string, op Operator, b string) bool

func RunTimeOp added in v0.6.0

func RunTimeOp(a time.Time, op Operator, b time.Time) bool

func Tag added in v0.7.6

func Tag(it graph.Iterator, tag string) graph.Iterator

func TagShape added in v0.7.6

func TagShape(it graph.IteratorShape, tag string) graph.IteratorShape

Types

type And

type And struct {
	graph.Iterator
	// contains filtered or unexported fields
}

The And iterator. Consists of a number of subiterators, the primary of which will be Next()ed if next is called.

func NewAnd

func NewAnd(sub ...graph.Iterator) *And

NewAnd creates an And iterator. `qs` is only required when needing a handle for QuadStore-specific optimizations, otherwise nil is acceptable.

func (*And) AddOptionalIterator added in v0.7.6

func (it *And) AddOptionalIterator(sub graph.Iterator) *And

AddOptionalIterator adds an iterator that will only be Contain'ed and will not affect iteration results. Only tags will be propagated from this iterator.

func (*And) AddSubIterator

func (it *And) AddSubIterator(sub graph.Iterator)

Add a subiterator to this And iterator.

The first iterator that is added becomes the primary iterator. This is important. Calling Optimize() is the way to change the order based on subiterator statistics. Without Optimize(), the order added is the order used.

func (*And) AsShape added in v0.7.6

func (it *And) AsShape() graph.IteratorShape

type Count added in v0.6.0

type Count struct {
	graph.Iterator
	// contains filtered or unexported fields
}

Count iterator returns one element with size of underlying iterator.

func NewCount added in v0.6.0

func NewCount(sub graph.Iterator, qs graph.Namer) *Count

NewCount creates a new iterator to count a number of results from a provided subiterator. qs may be nil - it's used to check if count Contains (is) a given value.

func (*Count) AsShape added in v0.7.6

func (it *Count) AsShape() graph.IteratorShape

type Error added in v0.7.0

type Error struct {
	// contains filtered or unexported fields
}

Error iterator always returns a single error with no other results.

func NewError added in v0.7.0

func NewError(err error) *Error

func (*Error) Close added in v0.7.0

func (it *Error) Close() error

func (*Error) Contains added in v0.7.0

func (it *Error) Contains(ctx context.Context, v graph.Ref) bool

func (*Error) Err added in v0.7.0

func (it *Error) Err() error

func (*Error) Next added in v0.7.0

func (it *Error) Next(ctx context.Context) bool

func (*Error) NextPath added in v0.7.0

func (it *Error) NextPath(ctx context.Context) bool

func (*Error) Optimize added in v0.7.0

func (it *Error) Optimize() (graph.Iterator, bool)

func (*Error) Reset added in v0.7.0

func (it *Error) Reset()

func (*Error) Result added in v0.7.0

func (it *Error) Result() graph.Ref

func (*Error) Size added in v0.7.0

func (it *Error) Size() (int64, bool)

func (*Error) Stats added in v0.7.0

func (it *Error) Stats() graph.IteratorStats

func (*Error) String added in v0.7.0

func (it *Error) String() string

func (*Error) SubIterators added in v0.7.0

func (it *Error) SubIterators() []graph.Iterator

func (*Error) TagResults added in v0.7.0

func (it *Error) TagResults(dst map[string]graph.Ref)

Fill the map based on the tags assigned to this iterator.

type Fixed

type Fixed struct {
	graph.Iterator
	// contains filtered or unexported fields
}

A Fixed iterator consists of it's values, an index (where it is in the process of Next()ing) and an equality function.

func NewFixed added in v0.4.1

func NewFixed(vals ...graph.Ref) *Fixed

Creates a new Fixed iterator with a custom comparator.

func (*Fixed) Add

func (it *Fixed) Add(v graph.Ref)

Add a value to the iterator. The array now contains this value. TODO(barakmich): This ought to be a set someday, disallowing repeated values.

func (*Fixed) AsShape added in v0.7.6

func (it *Fixed) AsShape() graph.IteratorShape

func (*Fixed) Values added in v0.7.1

func (it *Fixed) Values() []graph.Ref

Values returns a list of values stored in iterator. Slice should not be modified.

type HasA

type HasA struct {
	graph.Iterator
	// contains filtered or unexported fields
}

A HasA consists of a reference back to the graph.QuadStore that it references, a primary subiterator, a direction in which the quads for that subiterator point, and a temporary holder for the iterator generated on Contains().

func NewHasA

func NewHasA(qs graph.QuadIndexer, subIt graph.Iterator, d quad.Direction) *HasA

Construct a new HasA iterator, given the quad subiterator, and the quad direction for which it stands.

func (*HasA) AsShape added in v0.7.6

func (it *HasA) AsShape() graph.IteratorShape

func (*HasA) Direction

func (it *HasA) Direction() quad.Direction

Direction accessor.

type Int64Node added in v0.6.0

type Int64Node int64

func (Int64Node) IsNode added in v0.6.0

func (Int64Node) IsNode() bool

func (Int64Node) Key added in v0.7.0

func (v Int64Node) Key() interface{}

type Limit added in v0.6.0

type Limit struct {
	graph.Iterator
	// contains filtered or unexported fields
}

Limit iterator will stop iterating if certain a number of values were encountered. Zero and negative limit values means no limit.

func NewLimit added in v0.6.0

func NewLimit(primaryIt graph.Iterator, limit int64) *Limit

func (*Limit) AsShape added in v0.7.6

func (it *Limit) AsShape() graph.IteratorShape
type Link struct {
	Source   int `json:"source"`
	Target   int `json:"target"`
	Pred     int `json:"type"`
	LinkNode int `json:"link_node"`
}

type LinksTo

type LinksTo struct {
	graph.Iterator
	// contains filtered or unexported fields
}

A LinksTo has a reference back to the graph.QuadStore (to create the iterators for each node) the subiterator, and the direction the iterator comes from. `next_it` is the tempoarary iterator held per result in `primary_it`.

func NewLinksTo

func NewLinksTo(qs graph.QuadIndexer, sub graph.Iterator, d quad.Direction) *LinksTo

Construct a new LinksTo iterator around a direction and a subiterator of nodes.

func (*LinksTo) AsShape added in v0.7.6

func (it *LinksTo) AsShape() graph.IteratorShape

func (*LinksTo) Direction

func (it *LinksTo) Direction() quad.Direction

Return the direction under consideration.

type Materialize added in v0.4.0

type Materialize struct {
	graph.Iterator
	// contains filtered or unexported fields
}

func NewMaterialize added in v0.4.0

func NewMaterialize(sub graph.Iterator) *Materialize

func NewMaterializeWithSize added in v0.7.0

func NewMaterializeWithSize(sub graph.Iterator, size int64) *Materialize

func (*Materialize) AsShape added in v0.7.6

func (it *Materialize) AsShape() graph.IteratorShape

type Morphism added in v0.7.6

type Morphism func(graph.Iterator) graph.Iterator

type Morphism2 added in v0.7.6

type Morphism2 func(graph.IteratorShape) graph.IteratorShape

type Node

type Node struct {
	ID         int      `json:"id"`
	Tags       []string `json:"tags,omitempty"`
	Values     []string `json:"values,omitempty"`
	IsLinkNode bool     `json:"is_link_node"`
	IsFixed    bool     `json:"is_fixed"`
}

type Not added in v0.4.1

type Not struct {
	graph.Iterator
	// contains filtered or unexported fields
}

Not iterator acts like a complement for the primary iterator. It will return all the vertices which are not part of the primary iterator.

func NewNot added in v0.4.1

func NewNot(primaryIt, allIt graph.Iterator) *Not

func (*Not) AsShape added in v0.7.6

func (it *Not) AsShape() graph.IteratorShape

type Null

type Null struct{}

Here we define the simplest iterator -- the Null iterator. It contains nothing. It is the empty set. Often times, queries that contain one of these match nothing, so it's important to give it a special iterator.

func NewNull

func NewNull() *Null

Fairly useless New function.

func (*Null) Close

func (it *Null) Close() error

func (*Null) Contains

func (it *Null) Contains(ctx context.Context, v graph.Ref) bool

func (*Null) Err added in v0.4.1

func (it *Null) Err() error

func (*Null) Next

func (it *Null) Next(ctx context.Context) bool

func (*Null) NextPath added in v0.4.0

func (it *Null) NextPath(ctx context.Context) bool

func (*Null) Optimize

func (it *Null) Optimize() (graph.Iterator, bool)

A good iterator will close itself when it returns true. Null has nothing it needs to do.

func (*Null) Reset

func (it *Null) Reset()

func (*Null) Result

func (it *Null) Result() graph.Ref

func (*Null) Size

func (it *Null) Size() (int64, bool)

func (*Null) Stats

func (it *Null) Stats() graph.IteratorStats

A null iterator costs nothing. Use it!

func (*Null) String added in v0.7.0

func (it *Null) String() string

func (*Null) SubIterators

func (it *Null) SubIterators() []graph.Iterator

func (*Null) TagResults

func (it *Null) TagResults(dst map[string]graph.Ref)

Fill the map based on the tags assigned to this iterator.

type Operator

type Operator int
const (
	CompareLT Operator = iota
	CompareLTE
	CompareGT
	CompareGTE
)

func (Operator) String added in v0.7.1

func (op Operator) String() string

type Or

type Or struct {
	graph.Iterator
	// contains filtered or unexported fields
}

func NewOr

func NewOr(sub ...graph.Iterator) *Or

func NewShortCircuitOr

func NewShortCircuitOr(sub ...graph.Iterator) *Or

func (*Or) AddSubIterator

func (it *Or) AddSubIterator(sub graph.Iterator)

Add a subiterator to this Or graph.iterator. Order matters.

func (*Or) AsShape added in v0.7.6

func (it *Or) AsShape() graph.IteratorShape

type Recursive added in v0.6.1

type Recursive struct {
	graph.Iterator
	// contains filtered or unexported fields
}

Recursive iterator takes a base iterator and a morphism to be applied recursively, for each result.

func NewRecursive added in v0.6.1

func NewRecursive(sub graph.Iterator, morphism Morphism, maxDepth int) *Recursive

func (*Recursive) AddDepthTag added in v0.6.1

func (it *Recursive) AddDepthTag(s string)

func (*Recursive) AsShape added in v0.7.6

func (it *Recursive) AsShape() graph.IteratorShape

type Resolver added in v0.7.5

type Resolver struct {
	graph.Iterator
	// contains filtered or unexported fields
}

A Resolver iterator consists of it's order, an index (where it is in the, process of iterating) and a store to resolve values from.

func NewResolver added in v0.7.5

func NewResolver(qs graph.QuadStore, nodes ...quad.Value) *Resolver

Creates a new Resolver iterator.

func (*Resolver) AsShape added in v0.7.6

func (it *Resolver) AsShape() graph.IteratorShape

type Save added in v0.7.6

type Save struct {
	graph.Iterator
	// contains filtered or unexported fields
}

func NewSave added in v0.7.6

func NewSave(on graph.Iterator, tags ...string) *Save

func (*Save) AddFixedTag added in v0.7.6

func (it *Save) AddFixedTag(tag string, value graph.Ref)

func (*Save) AddTags added in v0.7.6

func (it *Save) AddTags(tag ...string)

Add a tag to the iterator.

func (*Save) AsShape added in v0.7.6

func (it *Save) AsShape() graph.IteratorShape

func (*Save) CopyFromTagger added in v0.7.6

func (it *Save) CopyFromTagger(st graph.TaggerBase)

func (*Save) FixedTags added in v0.7.6

func (it *Save) FixedTags() map[string]graph.Ref

Fixed returns the fixed tags held in the tagger. The returned value must not be mutated.

func (*Save) Tags added in v0.7.6

func (it *Save) Tags() []string

Tags returns the tags held in the tagger. The returned value must not be mutated.

type Skip added in v0.6.0

type Skip struct {
	graph.Iterator
	// contains filtered or unexported fields
}

Skip iterator will skip certain number of values from primary iterator.

func NewSkip added in v0.6.0

func NewSkip(primaryIt graph.Iterator, skip int64) *Skip

func (*Skip) AsShape added in v0.7.6

func (it *Skip) AsShape() graph.IteratorShape

type Sort added in v0.7.6

type Sort struct {
	graph.Iterator
	// contains filtered or unexported fields
}

Sort iterator orders values from it's subiterator.

func NewSort added in v0.7.6

func NewSort(namer graph.Namer, it graph.Iterator) *Sort

NewSort creates a new Sort iterator. TODO(dennwc): This iterator must not be used inside And: it may be moved to a Contains branch and won't do anything.

We should make And/Intersect account for this.

func (*Sort) AsShape added in v0.7.6

func (it *Sort) AsShape() graph.IteratorShape

AsShape returns Sort's underlying iterator shape

type Unique added in v0.5.0

type Unique struct {
	graph.Iterator
	// contains filtered or unexported fields
}

Unique iterator removes duplicate values from it's subiterator.

func NewUnique added in v0.5.0

func NewUnique(subIt graph.Iterator) *Unique

func (*Unique) AsShape added in v0.7.6

func (it *Unique) AsShape() graph.IteratorShape

type ValueFilter added in v0.7.6

type ValueFilter struct {
	graph.Iterator
	// contains filtered or unexported fields
}

func NewValueFilter added in v0.7.6

func NewValueFilter(qs graph.Namer, sub graph.Iterator, filter ValueFilterFunc) *ValueFilter

func (*ValueFilter) AsShape added in v0.7.6

func (it *ValueFilter) AsShape() graph.IteratorShape

type ValueFilterFunc added in v0.7.6

type ValueFilterFunc func(quad.Value) (bool, error)

Jump to

Keyboard shortcuts

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