traversal

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package traversal contains the struct for a graph traversal and its steps.

The traversal contains various steps which all have their own file associated with them individually. Each step can be used modular-ly to construct a query.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Custom

type Custom string

Custom is used for bindings in a query.

func (Custom) String

func (c Custom) String() string

type Parameter

type Parameter interface {
	String() string
}

Parameter is used for handling all Gremlin types.

type String

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

String is used to construct commands for the Grammes API when querying type String string

func NewCustomTraversal

func NewCustomTraversal(str string) (g String)

NewCustomTraversal could be used when you need to specifically need to change some property of the traversal. This can be something such as:

// ==> graph.traversal().withoutStrategies(LazyBarrierStrategy)

func NewTraversal

func NewTraversal() (g String)

NewTraversal will return a new Query with a default value of 'g' to start a command.

func (String) AddE

func (g String) AddE(param interface{}) String

AddE (map/sideEffect) adds a new edge between two vertices on the graph. Signatures: AddE(string) AddE(*String)

func (*String) AddStep

func (g *String) AddStep(step string, params ...interface{})

AddStep will add a new step to the traversal string using a list of parameters.

func (String) AddV

func (g String) AddV(params ...interface{}) String

AddV (map/sideEffect) is used to add vertices to the graph. Signatures: AddV() AddV(string) AddV(*String (Traversal))

func (String) Aggregate

func (g String) Aggregate(str string) String

Aggregate (sideEffect) is used to aggregate all the objects in a particular point of traversal into a Collection. The step uses eager evaluation in that no objects continue on until all previous objects have been fully aggregated (as opposed to Store() which lazily files a collection). Signatures: Aggregate(string)

func (String) And

func (g String) And(params ...String) String

And (filter) ensures that all provided traversals yield a result. Signatures: And() And(...*String (Traversal))

func (String) As

func (g String) As(labels ...string) String

As (step modulator) similar to By() & Option(). With As(), it is possible to provide a label to the step that can later be accessed by steps and data structures that make use of such labels. Signatures: As(string) As(string, string...)

func (String) Barrier

func (g String) Barrier(param ...interface{}) String

Barrier (barrier) turns the lazy traversal pipeline into a bulk-synchronous pipeline. Signatures: Barrier() Barrier(string (Consumer)) Barrier(int)

func (String) Both

func (g String) Both(labels ...string) String

Both moves to both the incoming and outgoing adjacent vertices given the edge labels.

func (String) BothE

func (g String) BothE(labels ...string) String

BothE moves to both the incoming and outgoing incident edges given the edge labels.

func (String) BothV

func (g String) BothV() String

BothV moves to both vertices.

func (String) By

func (g String) By(params ...interface{}) String

By (step modulator) similar to As() & Option(). If a step is able to accept traversals, functions, comparator, etc. then By() is the means by which they are added. The general pattern is step().By()...By(). Some steps can only accept one By() while others can take an arbitrary amount Signatures: By() By(string) By(...interface{})

func (String) Cap

func (g String) Cap(str string, optStrings ...string) String

Cap (barrier) iterates the traversal up to itself and emits the sideEffect referenced by the provided key. If multiple keys are provided, then a Map<String, Object> of sideEffects is emitted. Signatures: Cap(string, ...string)

func (String) Choose

func (g String) Choose(first interface{}, optTraversals ...String) String

Choose (branch) routes the current traverser to a particular traversal branch option. Note: Signatures: Choose(string (Function)) Choose(string (Predicate), *String (Traversal)) Choose(string (Predicate), *String (Traversal), *String (Traversal)) Choose(*String (Traversal), *String (Traversal)) Choose(*String (Traversal), *String (Traversal), *String (Traversal)) Choose(*String (Traversal))

func (String) Coalesce

func (g String) Coalesce(traversals ...String) String

Coalesce evaluates the provided traversals in order and returns the first traversal that emits at least one element. Signatures: Coalesce(...*String (Traversal))

func (String) Coin

func (g String) Coin(bias float32) String

Coin (filter) randomly filters out a traverser. Signatures: Coin(float32)

func (String) Constant

func (g String) Constant(obj string) String

Constant (map) is used to specify a constant value for a traverser. Signatures: Constant(string (Object))

func (String) Count

func (g String) Count(scope ...scope.Scope) String

Count (map) counts the total number of represented traversers in the stream. Signatures: Count() Count(Scope)

func (String) CyclicPath

func (g String) CyclicPath() String

CyclicPath (filter) analyzes the path of the traverser thus far and if there are any repeats, the traverser is filtered out over the traersal computation. Signatures: CyclicPath()

func (String) Dedup

func (g String) Dedup(params ...interface{}) String

Dedup (filter) repeatedly seen objects are removed from the traversal stream. Signatures: Dedup(Scope, ...string) Dedup(...string)

func (String) Drop

func (g String) Drop() String

Drop (filter/sideEffect) will remove an element and properties from the graph. Signatures: Drop()

func (String) E

func (g String) E(params ...interface{}) String

E is to access the edges of the traversal.

func (String) Emit

func (g String) Emit(predOrTrav ...interface{}) String

Emit (step modulator) for Repeat() Signatures: Emit() Emit(string (Predicate)) Emit(*String (Traversal))

func (String) Explain

func (g String) Explain() String

Explain (terminal) will return a TraversalExplanation. Signatures: Explain()

func (String) Fold

func (g String) Fold(params ...interface{}) String

Fold (map) is used when the traversal stream needs a "barrier" to aggregate all the objects and emite a computation that is a function of the aggregate. Signatures: Fold() Fold(interface{} (Object)) Fold(interface{} (Object), interface{} (BiFunction))

func (String) From

func (g String) From(param interface{}) String

From (step-modulator) similar to As() and By(). If a step is able to accept traversal or strings then From() is the means by which they are added. Note:

  • From does not handle string formatting. If you wish to input a string then you must format it with single quotes beforehand.

Signatures: From(string) From(*String (Traversal)) From(string (Vertex))

func (String) Group

func (g String) Group(str ...string) String

Group (map/sideEffect) is one such sideEffect that organizes the objects according to some function of the object. Then, if required, that organization (a list) is reduced. Signatures: Group() Group(string)

func (String) GroupCount

func (g String) GroupCount(str ...string) String

GroupCount (map/sideEffect) is the amount of times a particular object has been at a particular part of a traversal. Signatures: Group() Group(string)

func (String) Has

func (g String) Has(first interface{}, params ...interface{}) String

Has (filter) filters vertices, edges, and vertex properties based on their properties. Signatures: Has(string) Has(string, string (Object)) Has(string, string (P)) Has(string, string, string (Object)) Has(string, string, string (P)) Has(string, *String (Traversal)) Has(Token, string (Object)) Has(Token, string (P)) Has(Token, *String (Traversal))

func (String) HasID

func (g String) HasID(objOrP interface{}, objs ...string) String

HasID (filter) filters vertices, edges, and vertex properties based on their properties. In this case the ID. Signatures: HasID(string (Object), ...string (Object)) HasID(string (P))

func (String) HasKey

func (g String) HasKey(pOrStr interface{}, handledStrings ...string) String

HasKey (filter) filters vertices, edges, and vertex properties based on their properties. In this case the Key. Signatures: HasKey(string (Predicate)) HasKey(string, ...string)

func (String) HasLabel

func (g String) HasLabel(pOrStr interface{}, handledStrings ...string) String

HasLabel (filter) filters vertices, edges, and vertex properties based on their properties. In this case the Label. Signatures: HasLabel(string (Predicate)) HasLabel(string, ...string)

func (String) HasNot

func (g String) HasNot(str string) String

HasNot (filter) filters vertices, edges, and vertex properties based on their properties. In this case if it doesn't have this property. Signatures: HasNot(string)

func (String) HasValue

func (g String) HasValue(objOrP interface{}, objs ...string) String

HasValue (filter) filters vertices, edges, and vertex properties based on their properties. In this case the Value. Signatures: HasValue(string (Object), ...string (Object)) HasValue(string (P))

func (String) ID

func (g String) ID() String

ID (map) takes an Element and extracts its identifier from it. Signatures: ID()

func (String) Identity

func (g String) Identity() String

Identity (map) is an identity function which maps the current object to itself. Signatures: Identity()

func (String) In

func (g String) In(labels ...string) String

In moves to the incoming adjacent vertices given the edge labels

func (String) InE

func (g String) InE(labels ...string) String

InE moves to the incoming incident edges given the edge labels.

func (String) InV

func (g String) InV() String

InV moves to the incoming vertex.

func (String) Inject

func (g String) Inject(obj string) String

Inject (sideEffect) makes it possible to insert objects arbitrarily into a traversal stream. Signatures: Inject(string (Object))

func (String) Is

func (g String) Is(objOrP interface{}) String

Is (filter) makes it possible to filter scalar values. Signatures: Is(string (Object)) Is(string (P))

func (String) Key

func (g String) Key() String

Key (map) takes a Property and extracts the key from it. Signatures: Key()

func (String) Label

func (g String) Label() String

Label (map) takes an element and extracts its label from it. Signatures: Label()

func (String) Limit

func (g String) Limit(params ...interface{}) String

Limit (analogous to range) except the minimum will always be 0 there are two typical parameters for Limit. (Scope, MaxLimit) Signatures: Limit(int) Limit(Scope, int)

func (String) Local

func (g String) Local(traversal String) String

Local (branch) allows for object-local traversal computations. Signatures: Local(*String (Traversal))

func (String) Loops

func (g String) Loops() String

Loops (map) extracts the number of times the traverser has gone through a current loop. Signatures: Loops()

func (String) Match

func (g String) Match(traversals ...String) String

Match (map) provides a more declarative form of graph querying based on the notion of pattern matching. With Match(), the user provides a collection of "traversal fragments," called patterns, that have variables defined that must hold true throughout the duration of the Match(). Signatures: Match(...*String (Traversal))

func (String) Math

func (g String) Math(str string) String

Math (math) neables scientific calculator functionality within Gremlin. This step deviates from the common function composition and nesting formalisms to provide an easy to read string-based math processor. Variables within the equation map to scopes in Gremlin (e.g. path labels), side-effects, or incoming map keys. Signatures: Math(string)

func (String) Max

func (g String) Max(scopes ...scope.Scope) String

Max (map) operates on a stream of numbers and determines which is the largest number in the stream. Signatures: Max() Max(Scope)

func (String) Mean

func (g String) Mean(scopes ...scope.Scope) String

Mean (map) operates on a stream of numbers and determines the average of those two numbers. Signatures: Mean() Mean(Scope)

func (String) Min

func (g String) Min(scopes ...scope.Scope) String

Min (map) operates on astream of numbers and determines which is the smallest number in the stream. Signatures: Min() Min(Scope)

func (String) Not

func (g String) Not(traversal String) String

Not (filter) removes objects from the traversal stream when the traversal provided as an argument does not return any objects. Signatures: Not(*String (Traversal))

func (String) Option

func (g String) Option(params ...string) String

Option (step modulator) is an 'option' to a Branch() or Choose() Signatures: Option(string) Option(string, string)

func (String) Optional

func (g String) Optional(traversal String) String

Optional (branch/filterMap) returns the result of the specified traversal if it yields a result else it returns the calling element i.e. the Indentity(). Signatures: Optional(String (Traversal))

func (String) Or

func (g String) Or(traversals ...String) String

Or (filter) ensures that at least of the provided traversals yield a result. Signatures: Or() Or(...*String (Traversal))

func (String) Order

func (g String) Order(scope ...scope.Scope) String

Order (map) sorts the objects of the traversal stream. Signatures: Order() Order(Scope)

func (String) OtherV

func (g String) OtherV() String

OtherV moves to the vertex that was not the vertex that was moved from.

func (String) Out

func (g String) Out(labels ...string) String

Out moves to the outgoing adjacent vertices given the edge labels.

func (String) OutE

func (g String) OutE(labels ...string) String

OutE moves to the outgoing incident edges given the edge labels.

func (String) OutV

func (g String) OutV() String

OutV moves to the outgoing vertex.

func (String) PageRank

func (g String) PageRank(args ...float32) String

PageRank (map/sideEffect) calculates PageRank using PageRankVertexProgram. Signatures: PageRank() PageRank(float32)

func (String) Path

func (g String) Path() String

Path (map) realizes the history of the traverser and its path. Signatures: Path()

func (String) PeerPressure

func (g String) PeerPressure() String

PeerPressure (map/sideEffect) clusters vertices using PeerPressureVertexProgram. Signatures: PeerPressure()

func (String) Profile

func (g String) Profile(str ...string) String

Profile (sideEffect) exists to allow developers to profile their traversals to determine statistical information like step runtime, counts, etc. Signatures: Profile() Profile(string)

func (String) Program

func (g String) Program(vertexProgram interface{}) String

Program (map/sideEffect) is the "lambda" step for GraphComputer jobs. The step takes a VertexProgram as an argument and will process the incoming graph accordingly. Thus, the user can create their own VertexProgram and have it execute within a traversal. Signatures: Program(VertexProgram)

func (String) Project

func (g String) Project(str string, extraStrings ...string) String

Project (map) projects the current object into a Map<string, object> keyed by provided labels. It is similar to Select(), save that instead of retrieving and modulating historic traverser state, it modulates the current state of the traverser. Signatures: Project(string, ...string)

func (String) Properties

func (g String) Properties(str ...string) String

Properties (map) extracts properties from an Element in the traversal stream. Signatures: Properties() Properties(...string)

func (String) Property

func (g String) Property(objOrCard interface{}, obj interface{}, params ...interface{}) String

Property (sideEffect) unlike AddV() and AddE(), Property() is a full sideEffect step in that it does not return the property that it created, but the element that streamed into it. Note:

  • This function does not handle your string formatting because of the Cardinality parameter.

Signatures: Property(interface{} (Object), interface{} (Object), ...interface{} (Object)) Property(Cardinality, string (Object), interface{} (Object), ...interface{} (Object))

func (String) PropertyMap

func (g String) PropertyMap(str ...string) String

PropertyMap (map) extracts properties from an Element in the traversal stream. Signatures: PropertyMap(...string)

func (String) Range

func (g String) Range(params ...interface{}) String

Range (filter) allows for filtering on a low-end and high-end when objects are being iterated. -1 on the high range will emit remaining traversers after the low range begins. Signatures: Range(int, int) Range(Scope, int, int)

func (String) Raw

func (g String) Raw() String

Raw will return the raw traversal commands to be used as a parameter for other steps.

func (String) Repeat

func (g String) Repeat(traversal String) String

Repeat (branch) is used for loopping over a traversal given some break predicate. Signatures: Repeat(*String (Traversal))

func (String) Sack

func (g String) Sack(operator ...operator.Operator) String

Sack (sideEffect or map) is used to read and write sacks. Signatures: Sack() Sack(string (Bifunction))

func (String) Sample

func (g String) Sample(params ...interface{}) String

Sample (step-modulator) is useful for sampling some number of traversers previous in the traversal. Signatures: Sample(int) Sample(Scope, int)

func (String) Select

func (g String) Select(first interface{}, extras ...interface{}) String

Select (map) Can go back in a traversal in the previously seen area of computation. Note:

  • Select does not handle any string formatting. If you wish to input a normal string as a parameter then you must add single-quotes around the string beforehand.

Signatures: Select(string (Column)) Select(Pop, string) Select(string) Select(string, string, ...string) Select(*String (Traversal)) Select(Pop, *String (Traversal))

func (String) SimplePath

func (g String) SimplePath() String

SimplePath (filter) should be used when it's important that the traverser should not repeat its path through the graph. Signatures: SimplePath()

func (String) Skip

func (g String) Skip(first interface{}, extraFloat ...float32) String

Skip (filter) is analogous to Range() save that the higher end range is set to -1. Signatures: Skip(float32) Skip(Scope, float32)

func (String) Store

func (g String) Store(str string) String

Store (sideEffect) should be bused over Aggregate() when lazy aggregation is needed. Signatures: Store(string)

func (String) String

func (g String) String() string

func (String) SubGraph

func (g String) SubGraph(str string) String

SubGraph (sideEffect) provides a way to produce an edge-induced subgraph from virtually any traversal. Signatures: SubGraph(string)

func (String) Sum

func (g String) Sum(scopes ...scope.Scope) String

Sum (map) operates on a stream of numbers and sums the numbers together to yield a double. Signatures: Sum() Sum(Scope)

func (String) Tail

func (g String) Tail(first interface{}, extraFloat ...float32) String

Tail (filter) is analogous to Limit(), except that it emits the last n-objects instead of the first n-objects. Signatures: Tail() Tail(float32) Tail(Scope) Tail(Scope, float32)

func (String) TimeLimit

func (g String) TimeLimit(limit float32) String

TimeLimit (filter) should be used if you wish the traversal to execute within a certain time. Signatures: TimeLimit(float32)

func (String) To

func (g String) To(first interface{}, extraStrings ...string) String

To (step-modulator) similar to As() and By(). If a step is able to accept traversals or strings then To() is the means by which they are added. Note:

  • To does not handle any string formatting for you. If you wish to pass a regular string as a parameter you must add single-quotes around it beforehand.

Signatures: To(Direction, ...string) To(string) To(*String (Traversal)) To(string Vertex)

func (String) ToE

func (g String) ToE(dir direction.Direction, str string) String

ToE (step-modulator) is a part of To() Signatures: ToE(Direction, string)

func (String) ToV

func (g String) ToV(dir direction.Direction) String

ToV (step-modulator) is a part of To() Signatures: ToV(Direction)

func (String) ToVId

func (g String) ToVId(vertexID interface{}) String

ToVId can be used to make a string query that will take a vertex id as a parameter, and can be used to point an edge towards this vertex ID.

func (String) Tree

func (g String) Tree(str ...string) String

Tree (sideEffect) is used when the emanating paths from an element can be aggregated to form a tree. Signatures: Tree() Tree(string)

func (String) Unfold

func (g String) Unfold() String

Unfold (flatMap) is an iterator, iterable, or map, then it is unrolled into a linear form. If not, then the object is simply emitted. Signatures: Unfold()

func (String) Union

func (g String) Union(traversals ...String) String

Union (branch) supports the merging of the results of an arbitrary number of traversers. When a traverser reaches a Union(), it is copied of its internal steps. The traverser emitted from Union are the outputs of the respective internal traversals. Signatures: Union() Union(...*String (Traversal))

func (String) Until

func (g String) Until(predOrTrav interface{}) String

Until (step-modulator) for Repeat() Signatures: Until(string (Predicate)) Until(*String (Traversal))

func (String) V

func (g String) V(params ...interface{}) String

V will return the vertices that belong to this graph traversal. Optional parameter is the index of a specific vertex on the graph. Signatures: V() V(int...)

func (String) Value

func (g String) Value() String

Value (map) takes a property and extracts the value from it. Signatures: Value()

func (String) ValueMap

func (g String) ValueMap(boolOrStrings ...interface{}) String

ValueMap (map) yields a map representation of the properties of an element. Signatures: ValueMap() ValueMap(bool, string...) ValueMap(string...)

func (String) Values

func (g String) Values(strs ...string) String

Values (map) extracts the values of properties from an element in the traversal stream. Signatures: Values() Values(string...)

func (String) Where

func (g String) Where(first interface{}, extra ...string) String

Where (filter) filters the current objects based on either the object itself or the path history of the object. Notes:

  • Where does not handle string formatting. If you wish to input a string has a parameter you must surround it with single-quotes beforehand.

Signatures: Where(string (P)) Where(string, string (P)) Where(*String (Traversal))

func (String) WithSack

func (g String) WithSack(sackVal float32) String

WithSack (sideEffect or map) is used to read and write sacks. Signatures: Sack() Sack(string (Bifunction))

Jump to

Keyboard shortcuts

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