Exemple #1
0
func (b *BpTree) Remove(key []byte, where func(int32) bool) error {
	b.mutex.Lock()
	defer b.mutex.Unlock()
	return b.bpt.Remove(bytes_subgraph.Identity(key), func(bytes []byte) bool {
		return where(int_int.DeserializeInt32(bytes))
	})
}
Exemple #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))
	})
}
Exemple #3
0
func (b *BpTree) keyIter(raw fs2.ItemIterator) (it KeyIterator) {
	it = func() (key int32, err error, _ KeyIterator) {
		b.mutex.Lock()
		defer b.mutex.Unlock()
		var i []byte
		i, err, raw = raw()
		if err != nil {
			return 0, err, nil
		}
		if raw == nil {
			return 0, nil, nil
		}
		key = int_int.DeserializeInt32(i)
		return key, nil, it
	}
	return it
}
Exemple #4
0
func (b *BpTree) valueIter(raw fs2.ItemIterator) (it ValueIterator) {
	it = func() (value int32, err error, _ ValueIterator) {
		b.mutex.Lock()
		defer b.mutex.Unlock()
		var i []byte
		i, err, raw = raw()
		if err != nil {
			return 0, err, nil
		}
		if raw == nil {
			return 0, nil, nil
		}
		value = int_int.DeserializeInt32(i)
		return value, nil, it
	}
	return it
}
Exemple #5
0
func (b *BpTree) kvIter(kvi fs2.Iterator) (it Iterator) {
	it = func() (key int32, value map[string]interface{}, err error, _ Iterator) {
		b.mutex.Lock()
		defer b.mutex.Unlock()
		var k, v []byte
		k, v, err, kvi = kvi()
		if err != nil {
			return 0, nil, err, nil
		}
		if kvi == nil {
			return 0, nil, nil, nil
		}
		key = int_int.DeserializeInt32(k)
		value = DeserializeJson(v)
		return key, value, nil, it
	}
	return it
}
Exemple #6
0
func (b *BpTree) kvIter(kvi fs2.Iterator) (it Iterator) {
	it = func() (key int32, value subgraph.Edge, err error, _ Iterator) {
		b.mutex.Lock()
		defer b.mutex.Unlock()
		var k, v []byte
		k, v, err, kvi = kvi()
		if err != nil {
			return 0, subgraph.Edge{}, err, nil
		}
		if kvi == nil {
			return 0, subgraph.Edge{}, nil, nil
		}
		key = int_int.DeserializeInt32(k)
		value = DeserializeEdge(v)
		return key, value, nil, it
	}
	return it
}
Exemple #7
0
func (b *BpTree) kvIter(kvi fs2.Iterator) (it Iterator) {
	it = func() (key []byte, value int32, err error, _ Iterator) {
		b.mutex.Lock()
		defer b.mutex.Unlock()
		var k, v []byte
		k, v, err, kvi = kvi()
		if err != nil {
			return nil, 0, err, nil
		}
		if kvi == nil {
			return nil, 0, nil, nil
		}
		key = bytes_subgraph.Identity(k)
		value = int_int.DeserializeInt32(v)
		return key, value, nil, it
	}
	return it
}