forked from cayleygraph/cayley
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imports.go
57 lines (46 loc) · 1.18 KB
/
imports.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
var (
StartMorphism = path.StartMorphism
StartPath = path.StartPath
RawNext = graph.Next
NewTransaction = graph.NewTransaction
)
type Handle struct {
graph.QuadStore
graph.QuadWriter
}
func Triple(subject, predicate, object string) quad.Quad {
return quad.Quad{subject, predicate, object, ""}
}
func Quad(subject, predicate, object, label string) quad.Quad {
return quad.Quad{subject, predicate, object, label}
}
func NewGraph(name, dbpath string, opts graph.Options) (*Handle, error) {
qs, err := graph.NewQuadStore(name, dbpath, opts)
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 NewMemoryGraph() (*Handle, error) {
return NewGraph("memstore", "", nil)
}
func (h *Handle) Close() {
h.QuadStore.Close()
h.QuadWriter.Close()
}