https://github.com/google/cayley
Revision 4c9bdfbddae5b827a6c039909b34d4a4c96f07bf authored by Denys Smirnov on 16 November 2019, 17:51:10 UTC, committed by Denys Smirnov on 15 December 2019, 13:54:20 UTC
1 parent 083ef1c
Raw File
Tip revision: 4c9bdfbddae5b827a6c039909b34d4a4c96f07bf authored by Denys Smirnov on 16 November 2019, 17:51:10 UTC
linkedql: rename iterator files to have a common prefix
Tip revision: 4c9bdfb
imports.go
package cayley

import (
	"github.com/cayleygraph/cayley/graph"
	"github.com/cayleygraph/cayley/graph/iterator"
	_ "github.com/cayleygraph/cayley/graph/memstore"
	"github.com/cayleygraph/cayley/query/path"
	_ "github.com/cayleygraph/cayley/writer"
	"github.com/cayleygraph/quad"
)

var (
	StartMorphism = path.StartMorphism
	StartPath     = path.StartPath

	NewTransaction = graph.NewTransaction
)

type Iterator = iterator.Shape
type QuadStore = graph.QuadStore
type QuadWriter = graph.QuadWriter

type Path = path.Path

type Handle struct {
	graph.QuadStore
	graph.QuadWriter
}

func (h *Handle) Close() error {
	err := h.QuadWriter.Close()
	h.QuadStore.Close()
	return err
}

func Triple(subject, predicate, object interface{}) quad.Quad {
	return Quad(subject, predicate, object, nil)
}

func Quad(subject, predicate, object, label interface{}) quad.Quad {
	return quad.Make(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)
}
back to top