func (kv *KVTree) RangeDelete(start, end []byte) {
	kv.Lock()
	var items []btree.Item
	item := &treeItem{key: start}
	kv.tree.AscendGreaterOrEqual(item, func(i btree.Item) bool {
		target := i.(*treeItem)
		if bytes.Compare(target.key, end) < 0 {
			items = append(items, i)
			return true
		}
		return false
	})
	for _, target := range items {
		kv.tree.Delete(target)
	}
	kv.Unlock()
}
RangeDelete deletes key in [start, end)
package util
import (
	"bytes"
	"sync"
	"github.com/google/btree"
)
type treeItem struct {
	key   []byte
	value []byte
}
func (item *treeItem) Less(other btree.Item) bool {
	left := item.key
	right := other.(*treeItem).key
	return bytes.Compare(right, left) > 0
}
func (item *treeItem) Equals(other btree.Item) bool {
	left := item.key
	right := other.(*treeItem).key
	return bytes.Equal(right, left)
}
type KVTree struct {
	sync.RWMutex
	tree *btree.BTree
}
func NewKVTree() *KVTree {
	return &KVTree{
		tree: btree.New(defaultBTreeDegree),
	}
}
func (kv *KVTree) Put(key, value []byte) {
	kv.Lock()
	kv.tree.ReplaceOrInsert(&treeItem{
		key:   key,
		value: value,
	})
	kv.Unlock()
}
func (kv *KVTree) Delete(key []byte) bool {
	kv.Lock()
	item := &treeItem{key: key}
	ok := nil != kv.tree.Delete(item)
	kv.Unlock()
	return ok
}