diff --git a/pkg/local_object_storage/metabase/metadata.go b/pkg/local_object_storage/metabase/metadata.go index a0095d17df..abdd2adea8 100644 --- a/pkg/local_object_storage/metabase/metadata.go +++ b/pkg/local_object_storage/metabase/metadata.go @@ -46,9 +46,9 @@ func invalidMetaBucketKeyErr(key []byte, cause error) error { return fmt.Errorf("invalid meta bucket key (prefix 0x%X): %w", key[0], cause) } -// TODO: fill on migration -// TODO: ROOT and PHY props -// TODO: cleaning on obj removal +// TODO: fill on migration. +// TODO: ROOT and PHY props. +// TODO: cleaning on obj removal. func putMetadata(tx *bbolt.Tx, cnr cid.ID, id oid.ID, ver version.Version, owner user.ID, typ object.Type, creationEpoch uint64, payloadLen uint64, pldHash, pldHmmHash, splitID []byte, parentID, firstID oid.ID, attrs []object.Attribute) error { metaBkt, err := tx.CreateBucketIfNotExists(metaBucketKey(cnr)) @@ -651,7 +651,7 @@ func prepareMetaIDAttrKey(buf *keyBuffer, id oid.ID, attr string, valLen int) [] k[0] = metaPrefixIDAttr off := 1 + copy(k[1:], id[:]) off += copy(k[off:], attr) - off += copy(k[off:], utf8Delimiter) + copy(k[off:], utf8Delimiter) return k } diff --git a/pkg/local_object_storage/metabase/metadata_test.go b/pkg/local_object_storage/metabase/metadata_test.go index 98f0f8a25b..0726b90c5b 100644 --- a/pkg/local_object_storage/metabase/metadata_test.go +++ b/pkg/local_object_storage/metabase/metadata_test.go @@ -196,7 +196,7 @@ func TestApplyFilter(t *testing.T) { check(anyData, anyData, true) check(anyData, anyData[:len(anyData)-1], true) check(anyData, append(anyData, 1), false) - for i := range len(anyData) { + for i := range anyData { check(anyData, anyData[:i], true) changed := slices.Concat(anyData[:i], []byte{anyData[i] + 1}, anyData[i+1:]) check(anyData, changed[:i+1], false) @@ -311,6 +311,7 @@ func TestIntBucketOrder(t *testing.T) { } return nil }) + require.NoError(t, err) require.Equal(t, []string{ "-115792089237316195423570985008687907853269984665640564039457584007913129639935", @@ -1092,19 +1093,19 @@ func TestDB_SearchObjects(t *testing.T) { } heightSorted := []objectcore.SearchResultItem{ // attribute takes 1st order priority - {ids[9], []string{"0", otherAttrs[0]}}, - {ids[8], []string{"1", otherAttrs[1]}}, - {ids[7], []string{"50", otherAttrs[2]}}, - {ids[6], []string{"100", otherAttrs[3]}}, + {ID: ids[9], Attributes: []string{"0", otherAttrs[0]}}, + {ID: ids[8], Attributes: []string{"1", otherAttrs[1]}}, + {ID: ids[7], Attributes: []string{"50", otherAttrs[2]}}, + {ID: ids[6], Attributes: []string{"100", otherAttrs[3]}}, // but if attribute equals, items are sorted by IDs. Secondary attributes have // no effect, otherwise the order would not be reversed - {ids[3], []string{"101", otherAttrs[6]}}, - {ids[4], []string{"101", otherAttrs[5]}}, - {ids[5], []string{"101", otherAttrs[4]}}, + {ID: ids[3], Attributes: []string{"101", otherAttrs[6]}}, + {ID: ids[4], Attributes: []string{"101", otherAttrs[5]}}, + {ID: ids[5], Attributes: []string{"101", otherAttrs[4]}}, // attribute takes power again - {ids[2], []string{"102", otherAttrs[7]}}, - {ids[1], []string{"150", otherAttrs[8]}}, - {ids[0], []string{"4294967295", otherAttrs[9]}}, + {ID: ids[2], Attributes: []string{"102", otherAttrs[7]}}, + {ID: ids[1], Attributes: []string{"150", otherAttrs[8]}}, + {ID: ids[0], Attributes: []string{"4294967295", otherAttrs[9]}}, } // store cnr := cidtest.ID() @@ -1164,9 +1165,9 @@ func TestDB_SearchObjects(t *testing.T) { require.Empty(t, res[i].Attributes) } require.NotEmpty(t, cursor) + //nolint:staticcheck // drop with t.Skip res, cursor, err = db.Search(cnr, fs, nil, cursor, 6) require.NoError(t, err) - // TODO: issue t.Skip("paging is broken when prim attribute is not requested, see also https://github.com/nspcc-dev/neofs-node/issues/3058#issuecomment-2553193094") require.Len(t, res, 6) for i := range 6 { @@ -1240,6 +1241,7 @@ func TestDB_SearchObjects(t *testing.T) { require.Empty(t, res[i].Attributes) } require.NotEmpty(t, cursor) + //nolint:staticcheck // drop with t.Skip res, cursor, err = db.Search(cnr, fs, nil, cursor, 6) require.NoError(t, err) t.Skip("paging is broken when prim attribute is not requested, see also https://github.com/nspcc-dev/neofs-node/issues/3058#issuecomment-2553193094") @@ -1331,15 +1333,15 @@ func TestDB_SearchObjects(t *testing.T) { require.NoError(t, err) require.Empty(t, cursor) require.Equal(t, []objectcore.SearchResultItem{ - {ids[0], []string{"cat1.jpg", "1738760790"}}, + {ID: ids[0], Attributes: []string{"cat1.jpg", "1738760790"}}, }, res) }) t.Run("multiple", func(t *testing.T) { t.Run("both attributes", func(t *testing.T) { fullRes := []objectcore.SearchResultItem{ - {ids[1], []string{"cat2.jpg", "1738760792"}}, - {ids[2], []string{"cat2.jpg", "1738760791"}}, - {ids[3], []string{"cat2.jpg", "1738760793"}}, + {ID: ids[1], Attributes: []string{"cat2.jpg", "1738760792"}}, + {ID: ids[2], Attributes: []string{"cat2.jpg", "1738760791"}}, + {ID: ids[3], Attributes: []string{"cat2.jpg", "1738760793"}}, } var fs object.SearchFilters fs.AddFilter(object.AttributeFilePath, "cat2.jpg", object.MatchStringEqual)