Example #1
0
func (b *BpTree) Remove(key []byte, where func([]byte) bool) error {
	b.mutex.Lock()
	defer b.mutex.Unlock()
	return b.bpt.Remove(bytes_subgraph.Identity(key), func(bytes []byte) bool {
		return where(bytes_subgraph.Identity(bytes))
	})
}
Example #2
0
func (b *BpTree) Range(from, to []byte) (it Iterator, err error) {
	b.mutex.Lock()
	defer b.mutex.Unlock()
	raw, err := b.bpt.Range(bytes_subgraph.Identity(from), bytes_subgraph.Identity(to))
	if err != nil {
		return nil, err
	}
	return b.kvIter(raw), nil
}
Example #3
0
func (b *BpTree) Find(key []byte) (it Iterator, err error) {
	b.mutex.Lock()
	defer b.mutex.Unlock()
	raw, err := b.bpt.Find(bytes_subgraph.Identity(key))
	if err != nil {
		return nil, err
	}
	return b.kvIter(raw), nil
}
Example #4
0
func (b *BpTree) kvIter(kvi fs2.Iterator) (it Iterator) {
	it = func() (key []byte, value []byte, err error, _ Iterator) {
		b.mutex.Lock()
		defer b.mutex.Unlock()
		var k, v []byte
		k, v, err, kvi = kvi()
		if err != nil {
			return nil, nil, err, nil
		}
		if kvi == nil {
			return nil, nil, nil, nil
		}
		key = bytes_subgraph.Identity(k)
		value = bytes_subgraph.Identity(v)
		return key, value, nil, it
	}
	return it
}
Example #5
0
func (b *BpTree) valueIter(raw fs2.ItemIterator) (it ValueIterator) {
	it = func() (value []byte, err error, _ ValueIterator) {
		b.mutex.Lock()
		defer b.mutex.Unlock()
		var i []byte
		i, err, raw = raw()
		if err != nil {
			return nil, err, nil
		}
		if raw == nil {
			return nil, nil, nil
		}
		value = bytes_subgraph.Identity(i)
		return value, nil, it
	}
	return it
}
Example #6
0
func (b *BpTree) keyIter(raw fs2.ItemIterator) (it KeyIterator) {
	it = func() (key []byte, err error, _ KeyIterator) {
		b.mutex.Lock()
		defer b.mutex.Unlock()
		var i []byte
		i, err, raw = raw()
		if err != nil {
			return nil, err, nil
		}
		if raw == nil {
			return nil, nil, nil
		}
		key = bytes_subgraph.Identity(i)
		return key, nil, it
	}
	return it
}
Example #7
0
func (b *BpTree) Has(key []byte) (bool, error) {
	b.mutex.Lock()
	defer b.mutex.Unlock()
	return b.bpt.Has(bytes_subgraph.Identity(key))
}
Example #8
0
func (b *BpTree) Count(key []byte) (int, error) {
	b.mutex.Lock()
	defer b.mutex.Unlock()
	return b.bpt.Count(bytes_subgraph.Identity(key))
}
Example #9
0
func (b *BpTree) Add(key []byte, val []byte) error {
	b.mutex.Lock()
	defer b.mutex.Unlock()
	return b.bpt.Add(bytes_subgraph.Identity(key), bytes_subgraph.Identity(val))
}
Example #10
0
func (b *BpTree) Add(key []byte, val *subgraph.Extension) error {
	b.mutex.Lock()
	defer b.mutex.Unlock()
	return b.bpt.Add(bytes_subgraph.Identity(key), SerializeExtension(val))
}
Example #11
0
func (b *BpTree) Add(key []byte, val float64) error {
	b.mutex.Lock()
	defer b.mutex.Unlock()
	return b.bpt.Add(bytes_subgraph.Identity(key), SerializeFloat64(val))
}
Example #12
0
func (b *BpTree) Add(key []byte, val int32) error {
	b.mutex.Lock()
	defer b.mutex.Unlock()
	return b.bpt.Add(bytes_subgraph.Identity(key), int_int.SerializeInt32(val))
}