path

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Path

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

Path represents either a morphism (a pre-defined path stored for later use), or a concrete path, consisting of a morphism and an underlying QuadStore.

func NewPath

func NewPath(qs graph.QuadStore) *Path

NewPath creates a new, empty Path.

func PathFromIterator

func PathFromIterator(qs graph.QuadStore, it graph.Iterator) *Path

PathFromIterator creates a new Path from a set of nodes contained in iterator.

func StartMorphism

func StartMorphism(nodes ...quad.Value) *Path

StartMorphism creates a new Path with no underlying QuadStore.

func StartPath

func StartPath(qs graph.QuadStore, nodes ...quad.Value) *Path

StartPath creates a new Path from a set of nodes and an underlying QuadStore.

func StartPathNodes added in v0.6.1

func StartPathNodes(qs graph.QuadStore, nodes ...graph.Value) *Path

StartPathNodes creates a new Path from a set of nodes and an underlying QuadStore.

func (*Path) And

func (p *Path) And(path *Path) *Path

And updates the current Path to represent the nodes that match both the current Path so far, and the given Path.

func (*Path) Back

func (p *Path) Back(tag string) *Path

Back returns to a previously tagged place in the path. Any constraints applied after the Tag will remain in effect, but traversal continues from the tagged point instead, not from the end of the chain.

For example:

// Will return "bob" iff "bob" is cool
StartPath(qs, "bob").Tag("person_tag").Out("status").Is("cool").Back("person_tag")

func (*Path) Both

func (p *Path) Both(via ...interface{}) *Path

Both updates this path following both inbound and outbound predicates.

For example:

// Return the list of nodes that follow or are followed by "B".
//
// Will return []string{"A", "C", "D", "F} if there are the appropriate
// edges from those nodes to "B" labelled "follows", in either direction.
StartPath(qs, "B").Both("follows")

func (*Path) BothWithTags added in v0.6.1

func (p *Path) BothWithTags(tags []string, via ...interface{}) *Path

BothWithTags is exactly like Both, except it tags the value of the predicate traversed with the tags provided.

func (*Path) BuildIterator

func (p *Path) BuildIterator() graph.Iterator

BuildIterator returns an iterator from this given Path. Note that you must call this with a full path (not a morphism), since a morphism does not have the ability to fetch the underlying quads. This function will panic if called with a morphism (i.e. if p.IsMorphism() is true).

func (*Path) BuildIteratorOn

func (p *Path) BuildIteratorOn(qs graph.QuadStore) graph.Iterator

BuildIteratorOn will return an iterator for this path on the given QuadStore.

func (*Path) Clone added in v0.6.0

func (p *Path) Clone() *Path

Clone returns a clone of the current path.

func (*Path) Count added in v0.6.0

func (p *Path) Count() *Path

Count will count a number of results as it's own result set.

func (*Path) Except

func (p *Path) Except(path *Path) *Path

Except updates the current Path to represent the all of the current nodes except those in the supplied Path.

For example:

// Will return []string{"B"}
StartPath(qs, "A", "B").Except(StartPath(qs, "A"))

func (*Path) Filter added in v0.6.0

func (p *Path) Filter(op iterator.Operator, node quad.Value) *Path

Filter represents the nodes that are passing comparison with provided value.

func (*Path) Filters added in v0.7.0

func (p *Path) Filters(filters ...shape.ValueFilter) *Path

Filters represents the nodes that are passing provided filters.

func (*Path) Follow

func (p *Path) Follow(path *Path) *Path

Follow allows you to stitch two paths together. The resulting path will start from where the first path left off and continue iterating down the path given.

func (*Path) FollowRecursive added in v0.6.1

func (p *Path) FollowRecursive(via interface{}, maxDepth int, depthTags []string) *Path

FollowRecursive will repeatedly follow the given string predicate or Path object starting from the given node(s), through the morphism or pattern provided, ignoring loops. For example, this turns "parent" into "all ancestors", by repeatedly following the "parent" connection on the result of the parent nodes.

The second argument, "maxDepth" is the maximum number of recursive steps before stopping and returning. If -1 is passed, it will have no limit. If 0 is passed, it will use the default value of 50 steps before returning. If 1 is passed, it will stop after 1 step before returning, and so on.

The third argument, "depthTags" is a set of tags that will return strings of numeric values relating to how many applications of the path were applied the first time the result node was seen.

This is a very expensive operation in practice. Be sure to use it wisely.

func (*Path) FollowReverse

func (p *Path) FollowReverse(path *Path) *Path

FollowReverse is the same as follow, except it will iterate backwards up the path given as argument.

func (*Path) Has

func (p *Path) Has(via interface{}, nodes ...quad.Value) *Path

Has limits the paths to be ones where the current nodes have some linkage to some known node.

func (*Path) HasFilter added in v0.7.0

func (p *Path) HasFilter(via interface{}, rev bool, filt ...shape.ValueFilter) *Path

HasFilter limits the paths to be ones where the current nodes have some linkage to some nodes that pass provided filters.

func (*Path) HasReverse added in v0.6.0

func (p *Path) HasReverse(via interface{}, nodes ...quad.Value) *Path

HasReverse limits the paths to be ones where some known node have some linkage to the current nodes.

func (*Path) In

func (p *Path) In(via ...interface{}) *Path

In updates this Path to represent the nodes that are adjacent to the current nodes, via the given inbound predicate.

For example:

// Return the list of nodes that follow "B".
//
// Will return []string{"A", "C", "D"} if there are the appropriate
// edges from those nodes to "B" labelled "follows".
StartPath(qs, "B").In("follows")

func (*Path) InPredicates

func (p *Path) InPredicates() *Path

InPredicates updates this path to represent the nodes of the valid inbound predicates from the current nodes.

For example:

// Returns a list of predicates valid from "bob"
//
// Will return []string{"follows"} if there are any things that "follow" Bob
StartPath(qs, "bob").InPredicates()

func (*Path) InWithTags

func (p *Path) InWithTags(tags []string, via ...interface{}) *Path

InWithTags is exactly like In, except it tags the value of the predicate traversed with the tags provided.

func (*Path) Is

func (p *Path) Is(nodes ...quad.Value) *Path

Is declares that the current nodes in this path are only the nodes passed as arguments.

func (*Path) IsMorphism

func (p *Path) IsMorphism() bool

IsMorphism returns whether this Path is a morphism.

func (*Path) Iterate added in v0.6.0

func (p *Path) Iterate(ctx context.Context) *graph.IterateChain

Iterate is an shortcut for graph.Iterate.

func (*Path) LabelContext

func (p *Path) LabelContext(via ...interface{}) *Path

LabelContext restricts the following operations (such as In, Out) to only traverse edges that match the given set of labels.

func (*Path) LabelContextWithTags

func (p *Path) LabelContextWithTags(tags []string, via ...interface{}) *Path

LabelContextWithTags is exactly like LabelContext, except it tags the value of the label used in the traversal with the tags provided.

func (*Path) Labels added in v0.7.0

func (p *Path) Labels() *Path

Labels updates this path to represent the nodes of the labels of inbound and outbound quads.

func (*Path) Limit added in v0.6.0

func (p *Path) Limit(v int64) *Path

Limit will limit a number of values in result set.

func (*Path) Morphism

func (p *Path) Morphism() graph.ApplyMorphism

Morphism returns the morphism of this path. The returned value is a function that, when given a QuadStore and an existing Iterator, will return a new Iterator that yields the subset of values from the existing iterator matched by the current Path.

func (*Path) Or

func (p *Path) Or(path *Path) *Path

Or updates the current Path to represent the nodes that match either the current Path so far, or the given Path.

func (*Path) Out

func (p *Path) Out(via ...interface{}) *Path

Out updates this Path to represent the nodes that are adjacent to the current nodes, via the given outbound predicate.

For example:

// Returns the list of nodes that "B" follows.
//
// Will return []string{"F"} if there is a predicate (edge) from "B"
// to "F" labelled "follows".
StartPath(qs, "A").Out("follows")

func (*Path) OutPredicates

func (p *Path) OutPredicates() *Path

OutPredicates updates this path to represent the nodes of the valid inbound predicates from the current nodes.

For example:

// Returns a list of predicates valid from "bob"
//
// Will return []string{"follows", "status"} if there are edges from "bob"
// labelled "follows", and edges from "bob" that describe his "status".
StartPath(qs, "bob").OutPredicates()

func (*Path) OutWithTags

func (p *Path) OutWithTags(tags []string, via ...interface{}) *Path

OutWithTags is exactly like In, except it tags the value of the predicate traversed with the tags provided.

func (*Path) Regex added in v0.6.0

func (p *Path) Regex(pattern *regexp.Regexp) *Path

Regex represents the nodes that are matching provided regexp pattern. It will only include Raw and String values.

func (*Path) RegexWithRefs added in v0.6.0

func (p *Path) RegexWithRefs(pattern *regexp.Regexp) *Path

RegexWithRefs is the same as Regex, but also matches 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 (*Path) Reverse

func (p *Path) Reverse() *Path

Reverse returns a new Path that is the reverse of the current one.

func (*Path) Save

func (p *Path) Save(via interface{}, tag string) *Path

Save will, from the current nodes in the path, retrieve the node one linkage away (given by either a path or a predicate), add the given tag, and propagate that to the result set.

For example:

// Will return []map[string]string{{"social_status: "cool"}}
StartPath(qs, "B").Save("status", "social_status"

func (*Path) SaveOptional

func (p *Path) SaveOptional(via interface{}, tag string) *Path

SaveOptional is the same as Save, but does not require linkage to exist.

func (*Path) SaveOptionalReverse

func (p *Path) SaveOptionalReverse(via interface{}, tag string) *Path

SaveOptionalReverse is the same as SaveReverse, but does not require linkage to exist.

func (*Path) SavePredicates added in v0.7.0

func (p *Path) SavePredicates(rev bool, tag string) *Path

SavePredicates saves either forward or reverse predicates of current node without changing path location.

func (*Path) SaveReverse

func (p *Path) SaveReverse(via interface{}, tag string) *Path

SaveReverse is the same as Save, only in the reverse direction (the subject of the linkage should be tagged, instead of the object).

func (*Path) Shape added in v0.7.0

func (p *Path) Shape() shape.Shape

func (*Path) ShapeFrom added in v0.7.0

func (p *Path) ShapeFrom(from shape.Shape) shape.Shape

func (*Path) Skip added in v0.6.0

func (p *Path) Skip(v int64) *Path

Skip will omit a number of values from result set.

func (*Path) Tag

func (p *Path) Tag(tags ...string) *Path

Tag adds tag strings to the nodes at this point in the path for each result path in the set.

func (*Path) Unique added in v0.6.0

func (p *Path) Unique() *Path

Unique updates the current Path to contain only unique nodes.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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