func (pdb *PrefixDB) ReverseIterator(start, end []byte) (Iterator, error) {
	if (start != nil && len(start) == 0) || (end != nil && len(end) == 0) {
		return nil, ErrKeyEmpty
	}
	pdb.mtx.Lock()
	defer pdb.mtx.Unlock()
	var pstart, pend []byte
	pstart = append(cp(pdb.prefix), start...)
	if end == nil {
		pend = cpIncr(pdb.prefix)
	} else {
		pend = append(cp(pdb.prefix), end...)
	}
	ritr, err := pdb.db.ReverseIterator(pstart, pend)
	if err != nil {
		return nil, err
	}
	return newPrefixIterator(pdb.prefix, start, end, ritr)
}
ReverseIterator implements DB.
package db
import (
	"fmt"
	"sync"
)
type PrefixDB struct {
	mtx    sync.Mutex
	prefix []byte
	db     DB
}
var _ DB = (*PrefixDB)(nil)
func NewPrefixDB(db DB, prefix []byte) *PrefixDB {
	return &PrefixDB{
		prefix: prefix,
		db:     db,
	}
}
func (pdb *PrefixDB) Get(key []byte) ([]byte, error) {
	if len(key) == 0 {
		return nil, ErrKeyEmpty
	}
	pdb.mtx.Lock()
	defer pdb.mtx.Unlock()
	pkey := pdb.prefixed(key)
	value, err := pdb.db.Get(pkey)
	if err != nil {
		return nil, err
	}
	return value, nil
}
func (pdb *PrefixDB) Has(key []byte) (bool, error) {
	if len(key) == 0 {
		return false, ErrKeyEmpty
	}
	pdb.mtx.Lock()
	defer pdb.mtx.Unlock()
	ok, err := pdb.db.Has(pdb.prefixed(key))
	if err != nil {
		return ok, err
	}
	return ok, nil
}
func (pdb *PrefixDB) Set(key []byte, value []byte) error {
	if len(key) == 0 {
		return ErrKeyEmpty
	}
	if value == nil {
		return ErrValueNil
	}
	pdb.mtx.Lock()
	defer pdb.mtx.Unlock()
	pkey := pdb.prefixed(key)
	if err := pdb.db.Set(pkey, value); err != nil {
		return err
	}
	return nil
}
func (pdb *PrefixDB) SetSync(key []byte, value []byte) error {
	if len(key) == 0 {
		return ErrKeyEmpty
	}
	if value == nil {
		return ErrValueNil
	}
	pdb.mtx.Lock()
	defer pdb.mtx.Unlock()
	return pdb.db.SetSync(pdb.prefixed(key), value)
}
func (pdb *PrefixDB) Delete(key []byte) error {
	if len(key) == 0 {
		return ErrKeyEmpty
	}
	pdb.mtx.Lock()
	defer pdb.mtx.Unlock()
	return pdb.db.Delete(pdb.prefixed(key))
}
func (pdb *PrefixDB) DeleteSync(key []byte) error {
	if len(key) == 0 {
		return ErrKeyEmpty
	}
	pdb.mtx.Lock()
	defer pdb.mtx.Unlock()
	return pdb.db.DeleteSync(pdb.prefixed(key))
}
func (pdb *PrefixDB) Iterator(start, end []byte) (Iterator, error) {
	if (start != nil && len(start) == 0) || (end != nil && len(end) == 0) {
		return nil, ErrKeyEmpty
	}
	pdb.mtx.Lock()
	defer pdb.mtx.Unlock()
	var pstart, pend []byte
	pstart = append(cp(pdb.prefix), start...)
	if end == nil {
		pend = cpIncr(pdb.prefix)
	} else {
		pend = append(cp(pdb.prefix), end...)
	}
	itr, err := pdb.db.Iterator(pstart, pend)
	if err != nil {
		return nil, err
	}
	return newPrefixIterator(pdb.prefix, start, end, itr)
}