func (db RocksDB) BatchPut(writes []Write) error { wb := rocksdb.NewWriteBatch() defer wb.Close() for _, w := range writes { if w.Value == nil { wb.Delete(w.Key) continue } wb.Put(w.Key, w.Value) } return db.db.Write(db.wopts, wb) }
func (db RocksDB) Del(start, finish []byte) error { wb := rocksdb.NewWriteBatch() defer wb.Close() itr := db.Iterator() defer itr.Close() for itr.Seek(start); itr.Valid(); itr.Next() { k := itr.Key() if bytes.Compare(k, finish) > 0 { break } wb.Delete(k) } if err := itr.Error(); err != nil { return err } return db.db.Write(db.wopts, wb) }