0
0

added Close() method to KVBatch interface

This commit is contained in:
Steve Yen 2016-01-07 17:54:21 -08:00
parent 2b947e8c14
commit 70105477cf
5 changed files with 21 additions and 0 deletions

View File

@ -51,3 +51,7 @@ func (b *EmulatedBatch) Merge(key, val []byte) {
func (b *EmulatedBatch) Reset() {
b.Ops = b.Ops[:0]
}
func (b *EmulatedBatch) Close() error {
return nil
}

View File

@ -36,3 +36,10 @@ func (b *Batch) Reset() {
b.batch.Reset()
b.merge = store.NewEmulatedMerge(b.store.mo)
}
func (b *Batch) Close() error {
b.batch.Reset()
b.batch = nil
b.merge = nil
return nil
}

View File

@ -118,4 +118,7 @@ type KVBatch interface {
// Reset frees resources for this batch and allows reuse
Reset()
// Close frees resources
Close() error
}

View File

@ -24,3 +24,9 @@ func (b *Batch) Merge(key, val []byte) {
func (b *Batch) Reset() {
b.o.Reset()
}
func (b *Batch) Close() error {
err := b.o.Close()
b.o = nil
return err
}

View File

@ -84,6 +84,7 @@ func (i *batch) Set(key, val []byte) {}
func (i *batch) Delete(key []byte) {}
func (i *batch) Merge(key, val []byte) {}
func (i *batch) Reset() {}
func (i *batch) Close() error { return nil }
type writer struct{}