Skip to content

Commit

Permalink
[#xxxx] meta: Fix MatchCommonPrefix operation
Browse files Browse the repository at this point in the history
Return all the objects on the empty common prefix search.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
  • Loading branch information
carpawell committed Aug 4, 2022
1 parent 6209e1e commit 1816aaa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/neofs-node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"os"
"os/signal"
"runtime"
"syscall"

"github.com/nspcc-dev/neofs-node/misc"
Expand Down Expand Up @@ -34,6 +35,8 @@ func fatalOnErrDetails(details string, err error) {
}

func main() {
runtime.SetBlockProfileRate(1)

configFile := flag.String("config", "", "path to config")
versionFlag := flag.Bool("version", false, "neofs node version")
flag.Parse()
Expand Down
17 changes: 17 additions & 0 deletions pkg/local_object_storage/metabase/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,23 @@ func stringCommonPrefixMatcherBucket(b *bbolt.Bucket, fKey string, fVal string,
prefix = val[:len(val)-1]
}

if len(val) == 0 {
// empty common prefix, all the objects
// satisfy that filter
err := b.ForEach(func(k, v []byte) error {
if err := f(k, v); err != nil {
return err
}

return nil
})
if err != nil {
return err
}

return nil
}

c := b.Cursor()
for k, v := c.Seek(val); bytes.HasPrefix(k, prefix); k, v = c.Next() {
if checkLast && (len(k) == len(prefix) || k[len(prefix)]>>4 != val[len(val)-1]) {
Expand Down

0 comments on commit 1816aaa

Please sign in to comment.