forked from TrueCloudLab/frostfs-node
[#128] metabase: Do not create leaves in indexed header bucket
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
85aacbbb10
commit
5f78a18a4f
2 changed files with 8 additions and 15 deletions
|
@ -61,11 +61,6 @@ func (db *DB) Put(obj *object.Object) error {
|
|||
// 1. add prefix byte (0 if empty);
|
||||
v := []byte(indices[i].val)
|
||||
|
||||
// put value to key bucket (it is needed for iteration over all values (Select))
|
||||
if err := keyBucket.Put(keyWithPrefix(v, false), nil); err != nil {
|
||||
return errors.Wrapf(err, "(%T) could not put header value", db)
|
||||
}
|
||||
|
||||
// create address bucket for the value
|
||||
valBucket, err := keyBucket.CreateBucketIfNotExists(keyWithPrefix(v, true))
|
||||
if err != nil {
|
||||
|
@ -91,8 +86,8 @@ func keyWithPrefix(key []byte, bucket bool) []byte {
|
|||
return append([]byte{b}, key...)
|
||||
}
|
||||
|
||||
func keyWithoutPrefix(key []byte) ([]byte, bool) {
|
||||
return key[1:], key[0] == 1
|
||||
func cutKeyBytes(key []byte) []byte {
|
||||
return key[1:]
|
||||
}
|
||||
|
||||
func addressKey(addr *objectSDK.Address) []byte {
|
||||
|
|
|
@ -39,15 +39,13 @@ func (db *DB) Select(fs object.SearchFilters) ([]*object.Address, error) {
|
|||
|
||||
// iterate over all existing values for the key
|
||||
if err := keyBucket.ForEach(func(k, _ []byte) error {
|
||||
if k, bucket := keyWithoutPrefix(k); !bucket {
|
||||
if !matchFunc(string(k), fVal) {
|
||||
// exclude all addresses with this value
|
||||
return keyBucket.Bucket(keyWithPrefix(k, true)).ForEach(func(k, _ []byte) error {
|
||||
mAddr[string(k)] = struct{}{}
|
||||
if !matchFunc(string(cutKeyBytes(k)), fVal) {
|
||||
// exclude all addresses with this value
|
||||
return keyBucket.Bucket(k).ForEach(func(k, _ []byte) error {
|
||||
mAddr[string(k)] = struct{}{}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue