Beispiel #1
0
func (b *BpTree) Range(from, to []int32) (it Iterator, err error) {
	b.mutex.Lock()
	defer b.mutex.Unlock()
	raw, err := b.bpt.Range(ints_ints.SerializeInt32s(from), ints_ints.SerializeInt32s(to))
	if err != nil {
		return nil, err
	}
	return b.kvIter(raw), nil
}
Beispiel #2
0
func (b *BpTree) Remove(key []int32, where func(int32) bool) error {
	b.mutex.Lock()
	defer b.mutex.Unlock()
	return b.bpt.Remove(ints_ints.SerializeInt32s(key), func(bytes []byte) bool {
		return where(int_int.DeserializeInt32(bytes))
	})
}
Beispiel #3
0
func (b *BpTree) Find(key []int32) (it Iterator, err error) {
	b.mutex.Lock()
	defer b.mutex.Unlock()
	raw, err := b.bpt.Find(ints_ints.SerializeInt32s(key))
	if err != nil {
		return nil, err
	}
	return b.kvIter(raw), nil
}
Beispiel #4
0
func (b *BpTree) Has(key []int32) (bool, error) {
	b.mutex.Lock()
	defer b.mutex.Unlock()
	return b.bpt.Has(ints_ints.SerializeInt32s(key))
}
Beispiel #5
0
func (b *BpTree) Count(key []int32) (int, error) {
	b.mutex.Lock()
	defer b.mutex.Unlock()
	return b.bpt.Count(ints_ints.SerializeInt32s(key))
}
Beispiel #6
0
func (b *BpTree) Add(key []int32, val int32) error {
	b.mutex.Lock()
	defer b.mutex.Unlock()
	return b.bpt.Add(ints_ints.SerializeInt32s(key), int_int.SerializeInt32(val))
}