Create quads hierarchy
* Move nquads into quad. * Create cquads simplified parser in quad. * Move Triple (renamed Quad) to quad. Also made sure mongo actually implements BulkLoader.
This commit is contained in:
parent
01bc63810b
commit
401c58426f
51 changed files with 13400 additions and 5495 deletions
|
|
@ -23,7 +23,9 @@ package graph
|
|||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/barakmich/glog"
|
||||
"github.com/google/cayley/quad"
|
||||
)
|
||||
|
||||
// Defines an opaque "triple store value" type. However the backend wishes to
|
||||
|
|
@ -38,21 +40,21 @@ type Value interface{}
|
|||
|
||||
type TripleStore interface {
|
||||
// Add a triple to the store.
|
||||
AddTriple(*Triple)
|
||||
AddTriple(*quad.Quad)
|
||||
|
||||
// Add a set of triples to the store, atomically if possible.
|
||||
AddTripleSet([]*Triple)
|
||||
AddTripleSet([]*quad.Quad)
|
||||
|
||||
// Removes a triple matching the given one from the database,
|
||||
// if it exists. Does nothing otherwise.
|
||||
RemoveTriple(*Triple)
|
||||
RemoveTriple(*quad.Quad)
|
||||
|
||||
// Given an opaque token, returns the triple for that token from the store.
|
||||
Triple(Value) *Triple
|
||||
Quad(Value) *quad.Quad
|
||||
|
||||
// Given a direction and a token, creates an iterator of links which have
|
||||
// that node token in that directional field.
|
||||
TripleIterator(Direction, Value) Iterator
|
||||
TripleIterator(quad.Direction, Value) Iterator
|
||||
|
||||
// Returns an iterator enumerating all nodes in the graph.
|
||||
NodesAllIterator() Iterator
|
||||
|
|
@ -89,8 +91,8 @@ type TripleStore interface {
|
|||
// gives the TripleStore the opportunity to make this optimization.
|
||||
//
|
||||
// Iterators will call this. At worst, a valid implementation is
|
||||
// ts.IdFor(ts.Triple(triple_id).Get(dir))
|
||||
TripleDirection(triple_id Value, d Direction) Value
|
||||
// ts.IdFor(ts.quad.Quad(id).Get(dir))
|
||||
TripleDirection(id Value, d quad.Direction) Value
|
||||
}
|
||||
|
||||
type Options map[string]interface{}
|
||||
|
|
@ -122,14 +124,10 @@ func (d Options) StringKey(key string) (string, bool) {
|
|||
var ErrCannotBulkLoad = errors.New("triplestore: cannot bulk load")
|
||||
|
||||
type BulkLoader interface {
|
||||
// BulkLoad loads Triples from a TripleUnmarshaler in bulk to the TripleStore.
|
||||
// BulkLoad loads Quads from a quad.Unmarshaler in bulk to the TripleStore.
|
||||
// It returns ErrCannotBulkLoad if bulk loading is not possible. For example if
|
||||
// you cannot load in bulk to a non-empty database, and the db is non-empty.
|
||||
BulkLoad(TripleUnmarshaler) error
|
||||
}
|
||||
|
||||
type TripleUnmarshaler interface {
|
||||
Unmarshal() (*Triple, error)
|
||||
BulkLoad(quad.Unmarshaler) error
|
||||
}
|
||||
|
||||
type NewStoreFunc func(string, Options) (TripleStore, error)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue