forked from TrueCloudLab/frostfs-node
[#131] metabase: Implement indexing by object properties
Process parent objects in Put method. Headers of parent object are stored as regular leaf objects in metabase from now. Build indexes for ROOT, LEAF and CHILDFREE properties. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
97077294fc
commit
1db01725c9
4 changed files with 175 additions and 49 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
||||
v2object "github.com/nspcc-dev/neofs-api-go/v2/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -153,3 +154,85 @@ func TestDB_Delete(t *testing.T) {
|
|||
|
||||
testSelect(t, db, fs)
|
||||
}
|
||||
|
||||
func TestDB_SelectProperties(t *testing.T) {
|
||||
path := "test.db"
|
||||
|
||||
bdb, err := bbolt.Open(path, 0600, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
defer func() {
|
||||
bdb.Close()
|
||||
os.Remove(path)
|
||||
}()
|
||||
|
||||
db := NewDB(bdb)
|
||||
|
||||
parent := object.NewRaw()
|
||||
parent.SetContainerID(testCID())
|
||||
parent.SetID(testOID())
|
||||
|
||||
child := object.NewRaw()
|
||||
child.SetContainerID(testCID())
|
||||
child.SetID(testOID())
|
||||
child.SetParent(parent.Object().SDK())
|
||||
|
||||
parAddr := parent.Object().Address()
|
||||
childAddr := child.Object().Address()
|
||||
|
||||
require.NoError(t, db.Put(child.Object()))
|
||||
|
||||
// root filter
|
||||
fs := objectSDK.SearchFilters{}
|
||||
fs.AddRootFilter()
|
||||
testSelect(t, db, fs, parAddr)
|
||||
|
||||
// non-root filter
|
||||
fs = fs[:0]
|
||||
fs.AddNonRootFilter()
|
||||
testSelect(t, db, fs, childAddr)
|
||||
|
||||
// root filter (with random false value)
|
||||
fs = fs[:0]
|
||||
fs.AddFilter(v2object.FilterPropertyRoot, "some false value", objectSDK.MatchStringEqual)
|
||||
testSelect(t, db, fs, childAddr)
|
||||
|
||||
// leaf filter
|
||||
fs = fs[:0]
|
||||
fs.AddLeafFilter()
|
||||
testSelect(t, db, fs, childAddr)
|
||||
|
||||
// non-leaf filter
|
||||
fs = fs[:0]
|
||||
fs.AddNonLeafFilter()
|
||||
testSelect(t, db, fs, parAddr)
|
||||
|
||||
// leaf filter (with random false value)
|
||||
fs = fs[:0]
|
||||
fs.AddFilter(v2object.FilterPropertyLeaf, "some false value", objectSDK.MatchStringEqual)
|
||||
testSelect(t, db, fs, parAddr)
|
||||
|
||||
lnk := object.NewRaw()
|
||||
lnk.SetContainerID(testCID())
|
||||
lnk.SetID(testOID())
|
||||
lnk.SetChildren(testOID())
|
||||
|
||||
lnkAddr := lnk.Object().Address()
|
||||
|
||||
require.NoError(t, db.Put(lnk.Object()))
|
||||
|
||||
// childfree filter
|
||||
fs = fs[:0]
|
||||
fs.AddChildfreeFilter()
|
||||
testSelect(t, db, fs, childAddr, parAddr)
|
||||
|
||||
// non-childfree filter
|
||||
fs = fs[:0]
|
||||
fs.AddNonChildfreeFilter()
|
||||
testSelect(t, db, fs, lnkAddr)
|
||||
|
||||
// childfree filter (with random false value)
|
||||
fs = fs[:0]
|
||||
fs.AddFilter(v2object.FilterPropertyChildfree, "some false value", objectSDK.MatchStringEqual)
|
||||
testSelect(t, db, fs, lnkAddr)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue