graph/path: Add LabelContext to the path query language.
This commit is contained in:
parent
7a5e206539
commit
36d0f48d15
4 changed files with 73 additions and 14 deletions
|
|
@ -23,7 +23,6 @@ type morphism struct {
|
|||
Reversal func(*context) (morphism, *context)
|
||||
Apply applyMorphism
|
||||
tags []string
|
||||
context context
|
||||
}
|
||||
|
||||
// context allows a high-level change to the way paths are constructed. Some
|
||||
|
|
@ -51,6 +50,12 @@ type context struct {
|
|||
labelSet *Path
|
||||
}
|
||||
|
||||
func (c context) copy() context {
|
||||
return context{
|
||||
labelSet: c.labelSet,
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
type Path struct {
|
||||
|
|
@ -266,6 +271,13 @@ func (p *Path) Has(via interface{}, nodes ...string) *Path {
|
|||
return p
|
||||
}
|
||||
|
||||
// LabelContext restricts the following operations (such as In, Out) to only
|
||||
// traverse edges that match the given set of labels.
|
||||
func (p *Path) LabelContext(via ...interface{}) *Path {
|
||||
p.stack = append(p.stack, labelContextMorphism(via...))
|
||||
return p
|
||||
}
|
||||
|
||||
// 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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue