[#128] metabase: Use static byte prefix for calculating non-empty keys

It is no longer necessary to make different prefixes to generate non-empty
keys for buckets.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-10-29 14:40:53 +03:00 committed by Leonard Lyubich
parent 5f78a18a4f
commit 2d319aa29c

View file

@ -62,7 +62,7 @@ func (db *DB) Put(obj *object.Object) error {
v := []byte(indices[i].val)
// create address bucket for the value
valBucket, err := keyBucket.CreateBucketIfNotExists(keyWithPrefix(v, true))
valBucket, err := keyBucket.CreateBucketIfNotExists(nonEmptyKeyBytes(v))
if err != nil {
return errors.Wrapf(err, "(%T) could not create bucket for header value", db)
}
@ -77,13 +77,8 @@ func (db *DB) Put(obj *object.Object) error {
})
}
func keyWithPrefix(key []byte, bucket bool) []byte {
b := byte(0)
if bucket {
b = 1
}
return append([]byte{b}, key...)
func nonEmptyKeyBytes(key []byte) []byte {
return append([]byte{0}, key...)
}
func cutKeyBytes(key []byte) []byte {