Beispiel #1
0
func (r *rocksDBBatch) Iterate(start, end proto.EncodedKey, f func(proto.RawKeyValue) (bool, error)) error {
	if bytes.Compare(start, end) >= 0 {
		return nil
	}
	it := &rocksDBIterator{
		iter: C.DBBatchNewIter(r.parent.rdb, r.batch),
	}
	defer it.Close()

	it.Seek(start)
	for ; it.Valid(); it.Next() {
		k := it.Key()
		if !it.Key().Less(end) {
			break
		}
		if done, err := f(proto.RawKeyValue{Key: k, Value: it.Value()}); done || err != nil {
			return err
		}
	}
	// Check for any errors during iteration.
	return it.Error()
}
Beispiel #2
0
func (r *rocksDBBatch) NewIterator() Iterator {
	return &rocksDBIterator{
		iter: C.DBBatchNewIter(r.parent.rdb, r.batch),
	}
}