Add imports file to root; expansion welcome
This commit is contained in:
parent
b8a214bd94
commit
fa9945ed92
3 changed files with 52 additions and 8 deletions
|
|
@ -194,7 +194,7 @@ func isMorphism(nodes ...string) morphism {
|
|||
}
|
||||
sub = fixed
|
||||
}
|
||||
and := iterator.NewAnd()
|
||||
and := iterator.NewAnd(qs)
|
||||
and.AddSubIterator(sub)
|
||||
and.AddSubIterator(it)
|
||||
return and
|
||||
|
|
@ -240,8 +240,8 @@ func iteratorMorphism(it graph.Iterator) morphism {
|
|||
return morphism{
|
||||
"iterator",
|
||||
func() morphism { return iteratorMorphism(it) },
|
||||
func(_ graph.QuadStore, subIt graph.Iterator) graph.Iterator {
|
||||
and := iterator.NewAnd()
|
||||
func(qs graph.QuadStore, subIt graph.Iterator) graph.Iterator {
|
||||
and := iterator.NewAnd(qs)
|
||||
and.AddSubIterator(it)
|
||||
and.AddSubIterator(subIt)
|
||||
return and
|
||||
|
|
@ -255,7 +255,7 @@ func andMorphism(p *Path) morphism {
|
|||
func() morphism { return andMorphism(p) },
|
||||
func(qs graph.QuadStore, it graph.Iterator) graph.Iterator {
|
||||
subIt := p.BuildIteratorOn(qs)
|
||||
and := iterator.NewAnd()
|
||||
and := iterator.NewAnd(qs)
|
||||
and.AddSubIterator(it)
|
||||
and.AddSubIterator(subIt)
|
||||
return and
|
||||
|
|
@ -294,7 +294,7 @@ func exceptMorphism(p *Path) morphism {
|
|||
func(qs graph.QuadStore, base graph.Iterator) graph.Iterator {
|
||||
subIt := p.BuildIteratorOn(qs)
|
||||
notIt := iterator.NewNot(subIt, qs.NodesAllIterator())
|
||||
and := iterator.NewAnd()
|
||||
and := iterator.NewAnd(qs)
|
||||
and.AddSubIterator(base)
|
||||
and.AddSubIterator(notIt)
|
||||
return and
|
||||
|
|
@ -308,7 +308,7 @@ func inOutIterator(viaPath *Path, it graph.Iterator, reverse bool) graph.Iterato
|
|||
in, out = out, in
|
||||
}
|
||||
lto := iterator.NewLinksTo(viaPath.qs, it, in)
|
||||
and := iterator.NewAnd()
|
||||
and := iterator.NewAnd(viaPath.qs)
|
||||
and.AddSubIterator(iterator.NewLinksTo(viaPath.qs, viaPath.BuildIterator(), quad.Predicate))
|
||||
and.AddSubIterator(lto)
|
||||
return iterator.NewHasA(viaPath.qs, and, out)
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ type Delta struct {
|
|||
}
|
||||
|
||||
type Handle struct {
|
||||
QuadStore QuadStore
|
||||
QuadWriter QuadWriter
|
||||
QuadStore
|
||||
QuadWriter
|
||||
}
|
||||
|
||||
type IgnoreOpts struct {
|
||||
|
|
|
|||
44
imports.go
Normal file
44
imports.go
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
package cayley
|
||||
|
||||
import (
|
||||
"github.com/google/cayley/graph"
|
||||
_ "github.com/google/cayley/graph/memstore"
|
||||
"github.com/google/cayley/graph/path"
|
||||
"github.com/google/cayley/quad"
|
||||
_ "github.com/google/cayley/writer"
|
||||
)
|
||||
|
||||
type Iterator graph.Iterator
|
||||
type QuadStore graph.QuadStore
|
||||
type QuadWriter graph.QuadWriter
|
||||
|
||||
type Path path.Path
|
||||
|
||||
type Quad quad.Quad
|
||||
|
||||
var StartMorphism = path.StartMorphism
|
||||
var StartPath = path.StartPath
|
||||
|
||||
var RawNext = graph.Next
|
||||
|
||||
type Handle struct {
|
||||
graph.QuadStore
|
||||
graph.QuadWriter
|
||||
}
|
||||
|
||||
func NewMemoryGraph() (*Handle, error) {
|
||||
qs, err := graph.NewQuadStore("memstore", "", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qw, err := graph.NewQuadWriter("single", qs, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Handle{qs, qw}, nil
|
||||
}
|
||||
|
||||
func (h *Handle) Close() {
|
||||
h.QuadStore.Close()
|
||||
h.QuadWriter.Close()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue