Commit 13484edf authored by Jeromy's avatar Jeromy

rename Transaction to Batch

parent 91189388
...@@ -323,32 +323,32 @@ func (fs *Datastore) enumerateKeys(fi os.FileInfo, res []query.Entry) ([]query.E ...@@ -323,32 +323,32 @@ func (fs *Datastore) enumerateKeys(fi os.FileInfo, res []query.Entry) ([]query.E
return res, nil return res, nil
} }
type flatfsTransaction struct { type flatfsBatch struct {
puts map[datastore.Key]interface{} puts map[datastore.Key]interface{}
deletes map[datastore.Key]struct{} deletes map[datastore.Key]struct{}
ds *Datastore ds *Datastore
} }
func (fs *Datastore) StartBatchOp() datastore.Transaction { func (fs *Datastore) Batch() datastore.Batch {
return &flatfsTransaction{ return &flatfsBatch{
puts: make(map[datastore.Key]interface{}), puts: make(map[datastore.Key]interface{}),
deletes: make(map[datastore.Key]struct{}), deletes: make(map[datastore.Key]struct{}),
ds: fs, ds: fs,
} }
} }
func (bt *flatfsTransaction) Put(key datastore.Key, val interface{}) error { func (bt *flatfsBatch) Put(key datastore.Key, val interface{}) error {
bt.puts[key] = val bt.puts[key] = val
return nil return nil
} }
func (bt *flatfsTransaction) Delete(key datastore.Key) error { func (bt *flatfsBatch) Delete(key datastore.Key) error {
bt.deletes[key] = struct{}{} bt.deletes[key] = struct{}{}
return nil return nil
} }
func (bt *flatfsTransaction) Commit() error { func (bt *flatfsBatch) Commit() error {
if err := bt.ds.putMany(bt.puts); err != nil { if err := bt.ds.putMany(bt.puts); err != nil {
return err return err
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment