Skip to content

Commit

Permalink
node/metabase: Fix omission of some entries with prim PREFIX filter
Browse files Browse the repository at this point in the history
Previously, when filter was `PREFIX` with integer value, metabase
iterator processed int entries only.

This makes the iterator to start from integers entries, and, once they
are finished, then jump over to the rest ones. The approach is reused
from `!=` matcher fix in d189ad6.

Refs #3131. Refs #3058.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
  • Loading branch information
cthulhu-rider committed Feb 18, 2025
1 parent 2f457e6 commit 03497a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pkg/local_object_storage/metabase/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func (db *DB) searchTx(tx *bbolt.Tx, cnr cid.ID, fs object.SearchFilters, fInt m
valID := cursor.Key[cursor.ValIDOff:]
prevResPrimVal, prevResOID = valID[:len(valID)-oid.Size], valID[len(valID)-oid.Size:]
} else {
if primMatcher == object.MatchStringEqual || primMatcher == object.MatchCommonPrefix ||
if primMatcher == object.MatchStringEqual ||
primMatcher == object.MatchNumGT || primMatcher == object.MatchNumGE {
var err error
if primSeekKey, primSeekPrefix, err = seekKeyForAttribute(primAttr, primVal); err != nil {
Expand All @@ -293,6 +293,11 @@ func (db *DB) searchTx(tx *bbolt.Tx, cnr cid.ID, fs object.SearchFilters, fInt m
jump = !intPrimMatcher
primSeekKey = slices.Concat([]byte{metaPrefixAttrIDInt}, []byte(primAttr), utf8Delimiter)
primSeekPrefix = primSeekKey
if primMatcher == object.MatchCommonPrefix && primVal != "-" {
if _, ok := new(big.Int).SetString(primVal, 10); !ok { // none of int match this
primSeekKey[0], jump = metaPrefixAttrIDPlain, false
}
}
}
}

Expand Down
1 change: 0 additions & 1 deletion pkg/local_object_storage/metabase/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,6 @@ func TestDB_SearchObjects(t *testing.T) {
})
})
t.Run("PREFIX", func(t *testing.T) {
t.Skip("https://github.com/nspcc-dev/neofs-node/issues/3131")
t.Run("negative", func(t *testing.T) {
check := func(t testing.TB, val string) {
check(t, object.MatchCommonPrefix, val, 0, 1)
Expand Down

0 comments on commit 03497a5

Please sign in to comment.