Compare commits

...

3 commits

Author SHA1 Message Date
ed2377307d [#1059] pilorama: Pass linter check
All checks were successful
DCO action / DCO (pull_request) Successful in 1m16s
Build / Build Components (1.21) (pull_request) Successful in 3m16s
Vulncheck / Vulncheck (pull_request) Successful in 3m35s
Build / Build Components (1.20) (pull_request) Successful in 5m8s
Tests and linters / gopls check (pull_request) Successful in 6m42s
Tests and linters / Staticcheck (pull_request) Successful in 6m48s
Tests and linters / Lint (pull_request) Successful in 7m25s
Tests and linters / Tests (1.20) (pull_request) Successful in 8m34s
Tests and linters / Tests with -race (pull_request) Successful in 8m43s
Tests and linters / Tests (1.21) (pull_request) Successful in 9m5s
funlen 'TreeSortedByFilename' is too long (81 > 80)

Signed-off-by: Alex Vanin <a.vanin@yadro.com>
2024-04-02 08:45:31 +03:00
b595ba2992 [#1059] pilorama: Run ascending tree sort test against boltdb
Some checks failed
DCO action / DCO (pull_request) Successful in 5m40s
Vulncheck / Vulncheck (pull_request) Successful in 5m38s
Build / Build Components (1.21) (pull_request) Successful in 6m58s
Build / Build Components (1.20) (pull_request) Successful in 7m10s
Tests and linters / Lint (pull_request) Failing after 7m9s
Tests and linters / Staticcheck (pull_request) Successful in 7m23s
Tests and linters / gopls check (pull_request) Successful in 7m46s
Tests and linters / Tests (1.20) (pull_request) Successful in 9m15s
Tests and linters / Tests (1.21) (pull_request) Successful in 9m18s
Tests and linters / Tests with -race (pull_request) Successful in 10m35s
Signed-off-by: Alex Vanin <a.vanin@yadro.com>
2024-04-01 21:09:39 +03:00
bae4cc1c18 [#1059] pilorama: Fix compare condition for subtree sort
Signed-off-by: Alex Vanin <a.vanin@yadro.com>
2024-04-01 21:09:39 +03:00
2 changed files with 17 additions and 3 deletions

View file

@ -1073,8 +1073,9 @@ func (t *boltForest) TreeSortedByFilename(ctx context.Context, cid cidSDK.ID, tr
return bytes.Compare(result[i].Meta.GetAttr(AttributeFilename), result[j].Meta.GetAttr(AttributeFilename)) == -1
})
for i := range result {
if bytes.Compare([]byte(last), result[i].Meta.GetAttr(AttributeFilename)) == -1 {
result = result[i:]
if cmp := bytes.Compare([]byte(last), result[i].Meta.GetAttr(AttributeFilename)); cmp <= 0 {
// if last == result[i], return next [i+1:] values; if last < result[i], return all values from [i:]
result = result[i+cmp+1:]
break
}
}

View file

@ -4,6 +4,7 @@ import (
"context"
"errors"
"path"
"path/filepath"
"sort"
"testing"
@ -123,9 +124,21 @@ func TestGetSubTree(t *testing.T) {
}
func TestGetSubTreeOrderAsc(t *testing.T) {
t.Run("memory forest", func(t *testing.T) {
testGetSubTreeOrderAsc(t, pilorama.NewMemoryForest())
})
t.Run("boltdb forest", func(t *testing.T) {
p := pilorama.NewBoltForest(pilorama.WithPath(filepath.Join(t.TempDir(), "pilorama")))
require.NoError(t, p.Open(context.Background(), 0644))
require.NoError(t, p.Init())
testGetSubTreeOrderAsc(t, p)
})
}
func testGetSubTreeOrderAsc(t *testing.T, p pilorama.ForestStorage) {
d := pilorama.CIDDescriptor{CID: cidtest.ID(), Size: 1}
treeID := "sometree"
p := pilorama.NewMemoryForest()
tree := []struct {
path []string