Exemple #1
0
func (r *rocksDBBatch) Commit() error {
	if r.batch == nil {
		panic("this batch was already committed")
	}
	if err := statusToError(C.DBWrite(r.parent.rdb, r.batch)); err != nil {
		return err
	}
	C.DBBatchDestroy(r.batch)
	r.batch = nil

	// On success, run the deferred functions in reverse order.
	for i := len(r.defers) - 1; i >= 0; i-- {
		r.defers[i]()
	}
	r.defers = nil

	return nil
}
Exemple #2
0
func (r *rocksDBBatch) Close() {
	if r.batch != nil {
		C.DBBatchDestroy(r.batch)
	}
}