metabase: store associated object field in bytes #3971
metabase: store associated object field in bytes #3971
Conversation
Signed-off-by: Andrey Butusov <andrey@nspcc.io>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3971 +/- ##
==========================================
+ Coverage 27.72% 28.06% +0.34%
==========================================
Files 676 680 +4
Lines 44962 45390 +428
==========================================
+ Hits 12465 12740 +275
- Misses 31367 31459 +92
- Partials 1130 1191 +61 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| case object.FilterPhysical, object.FilterRoot: | ||
| // Not real attributes, ignored. | ||
| default: | ||
| if string(attrKey) == object.AttributeAssociatedObject && len(attrVal) == oid.Size { |
There was a problem hiding this comment.
But it's a natural part of the switch above, isn't it?
| cnr := cidtest.ID() | ||
|
|
||
| o := objecttest.Object() | ||
| o.ResetRelations() |
There was a problem hiding this comment.
Maybe we need to fix objecttest or have some local regular test object function?
There was a problem hiding this comment.
Used existing helpers.
| target := obj.AssociatedObject() | ||
| if target.IsZero() { | ||
| return nil | ||
| return fmt.Errorf("%s object has zero associated object", obj.Type()) |
There was a problem hiding this comment.
Somewhat different problem, this nil was relevant before 5675b9d, now it's obsolete, yes.
|
|
||
| func migrateAssociatedObjectValueToIDBytes(l *zap.Logger, _ *bbolt.Tx, b *bbolt.Bucket, cnr cid.ID, afterKey []byte, rem uint) (uint, []byte, error) { | ||
| c := b.Cursor() | ||
| k, _ := c.First() |
There was a problem hiding this comment.
Position to associated ID prefix immediately, then you have AttrID and you can get IDAttr to change from it as well. You don't want to scan the whole DB, in fact this attribute is pretty rare.
Store `__NEOFS__ASSOCIATE` in metabase as raw OID bytes instead of Base58.
Reject non-OID values for this attribute, add migration, update read/search
paths and cover the new layout in tests.
```
goos: linux
goarch: amd64
pkg: github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase
cpu: AMD Ryzen 7 PRO 4750U with Radeon Graphics
│ old.txt │ new.txt │
│ sec/op │ sec/op vs base │
Search/user_attribute-16 17.76µ ± 2% 15.10µ ± 2% -15.00% (p=0.000 n=10)
Search/associated_object_with_attribute-16 13.25µ ± 2% 15.20µ ± 8% +14.68% (p=0.000 n=10)
IsLocked/locked-16 11.464µ ± 2% 5.303µ ± 5% -53.75% (p=0.000 n=10)
IsLocked/unlocked-16 6.117µ ± 18% 3.112µ ± 2% -49.12% (p=0.000 n=10)
geomean 11.33µ 7.844µ -30.79%
│ old.txt │ new.txt │
│ B/op │ B/op vs base │
Search/user_attribute-16 2.547Ki ± 0% 2.445Ki ± 0% -3.99% (p=0.000 n=10)
Search/associated_object_with_attribute-16 2.203Ki ± 0% 2.305Ki ± 0% +4.61% (p=0.000 n=10)
IsLocked/locked-16 1.455Ki ± 0% 1.250Ki ± 0% -14.09% (p=0.000 n=10)
IsLocked/unlocked-16 945.0 ± 0% 840.0 ± 0% -11.11% (p=0.000 n=10)
geomean 1.657Ki 1.550Ki -6.42%
│ old.txt │ new.txt │
│ allocs/op │ allocs/op vs base │
Search/user_attribute-16 52.00 ± 0% 50.00 ± 0% -3.85% (p=0.000 n=10)
Search/associated_object_with_attribute-16 46.00 ± 0% 47.00 ± 0% +2.17% (p=0.000 n=10)
IsLocked/locked-16 33.00 ± 0% 29.00 ± 0% -12.12% (p=0.000 n=10)
IsLocked/unlocked-16 20.00 ± 0% 18.00 ± 0% -10.00% (p=0.000 n=10)
geomean 35.45 33.28 -6.11%
```
Closes #3926.
Signed-off-by: Andrey Butusov <andrey@nspcc.io>
789c655 to
bec2d00
Compare
Closes #3926.