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)) }) }
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 }
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 }
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 }
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 }
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 }
func (b *BpTree) Has(key []byte) (bool, error) { b.mutex.Lock() defer b.mutex.Unlock() return b.bpt.Has(bytes_subgraph.Identity(key)) }
func (b *BpTree) Count(key []byte) (int, error) { b.mutex.Lock() defer b.mutex.Unlock() return b.bpt.Count(bytes_subgraph.Identity(key)) }
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)) }
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)) }
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)) }
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)) }