Improve Transaction: deduplicate quads, allow adding/removing a quad in the same tx

This commit is contained in:
Quentin Machu 2015-10-06 15:21:33 -04:00
parent b74f8f1340
commit 45d96e14ec
3 changed files with 105 additions and 19 deletions

View file

@ -109,9 +109,11 @@ func (s *Single) Close() error {
func (s *Single) ApplyTransaction(t *graph.Transaction) error {
ts := time.Now()
for i := 0; i < len(t.Deltas); i++ {
t.Deltas[i].ID = s.currentID.Next()
t.Deltas[i].Timestamp = ts
deltas := make([]graph.Delta, 0, len(t.Deltas))
for d := range t.Deltas {
d.ID = s.currentID.Next()
d.Timestamp = ts
deltas = append(deltas, d)
}
return s.qs.ApplyDeltas(t.Deltas, s.ignoreOpts)
return s.qs.ApplyDeltas(deltas, s.ignoreOpts)
}