convert to using real quads
This commit is contained in:
parent
c64acabee0
commit
6d4738cf0c
2 changed files with 9 additions and 9 deletions
|
|
@ -48,14 +48,14 @@ var ErrQuadNotExist = errors.New("Quad doesn't exist")
|
||||||
|
|
||||||
type QuadWriter interface {
|
type QuadWriter interface {
|
||||||
// Add a quad to the store.
|
// Add a quad to the store.
|
||||||
AddQuad(*quad.Quad) error
|
AddQuad(quad.Quad) error
|
||||||
|
|
||||||
// Add a set of quads to the store, atomically if possible.
|
// Add a set of quads to the store, atomically if possible.
|
||||||
AddQuadSet([]*quad.Quad) error
|
AddQuadSet([]quad.Quad) error
|
||||||
|
|
||||||
// Removes a quad matching the given one from the database,
|
// Removes a quad matching the given one from the database,
|
||||||
// if it exists. Does nothing otherwise.
|
// if it exists. Does nothing otherwise.
|
||||||
RemoveQuad(*quad.Quad) error
|
RemoveQuad(quad.Quad) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type NewQuadWriterFunc func(TripleStore, Options) (QuadWriter, error)
|
type NewQuadWriterFunc func(TripleStore, Options) (QuadWriter, error)
|
||||||
|
|
|
||||||
|
|
@ -44,23 +44,23 @@ func (s *Single) AcquireNextID() int64 {
|
||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Single) AddQuad(q *quad.Quad) error {
|
func (s *Single) AddQuad(q quad.Quad) error {
|
||||||
deltas := make([]*graph.Delta, 1)
|
deltas := make([]*graph.Delta, 1)
|
||||||
deltas[0] = &graph.Delta{
|
deltas[0] = &graph.Delta{
|
||||||
ID: s.AcquireNextID(),
|
ID: s.AcquireNextID(),
|
||||||
Quad: *q,
|
Quad: q,
|
||||||
Action: graph.Add,
|
Action: graph.Add,
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
}
|
}
|
||||||
return s.ts.ApplyDeltas(deltas)
|
return s.ts.ApplyDeltas(deltas)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Single) AddQuadSet(set []*quad.Quad) error {
|
func (s *Single) AddQuadSet(set []quad.Quad) error {
|
||||||
deltas := make([]*graph.Delta, len(set))
|
deltas := make([]*graph.Delta, len(set))
|
||||||
for i, q := range set {
|
for i, q := range set {
|
||||||
deltas[i] = &graph.Delta{
|
deltas[i] = &graph.Delta{
|
||||||
ID: s.AcquireNextID(),
|
ID: s.AcquireNextID(),
|
||||||
Quad: *q,
|
Quad: q,
|
||||||
Action: graph.Add,
|
Action: graph.Add,
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
}
|
}
|
||||||
|
|
@ -69,11 +69,11 @@ func (s *Single) AddQuadSet(set []*quad.Quad) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Single) RemoveQuad(q *quad.Quad) error {
|
func (s *Single) RemoveQuad(q quad.Quad) error {
|
||||||
deltas := make([]*graph.Delta, 1)
|
deltas := make([]*graph.Delta, 1)
|
||||||
deltas[0] = &graph.Delta{
|
deltas[0] = &graph.Delta{
|
||||||
ID: s.AcquireNextID(),
|
ID: s.AcquireNextID(),
|
||||||
Quad: *q,
|
Quad: q,
|
||||||
Action: graph.Delete,
|
Action: graph.Delete,
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue