[#149] metabase: Add parent ID index

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-05 19:54:24 +03:00 committed by Alex Vanin
parent 65be09d3db
commit 2913aa0fd1
2 changed files with 27 additions and 0 deletions

View file

@ -142,6 +142,10 @@ func objectIndices(obj *object.Object, parent bool) []bucketItem {
key: v2object.FilterPropertyChildfree, key: v2object.FilterPropertyChildfree,
val: childfreeVal, val: childfreeVal,
}, },
bucketItem{
key: v2object.FilterHeaderParent,
val: obj.GetParentID().String(),
},
// TODO: add remaining fields after neofs-api#72 // TODO: add remaining fields after neofs-api#72
) )

View file

@ -184,3 +184,26 @@ func TestMissingObjectAttribute(t *testing.T) {
testSelect(t, db, fs, obj1.Address()) testSelect(t, db, fs, obj1.Address())
} }
func TestSelectParentID(t *testing.T) {
db := newDB(t)
defer releaseDB(db)
// generate 2 objects
obj1 := generateObject(t, testPrm{})
obj2 := generateObject(t, testPrm{})
// set parent ID of 1st object
par := testOID()
object.NewRawFromObject(obj1).SetParentID(par)
// store objects
require.NoError(t, db.Put(obj1))
require.NoError(t, db.Put(obj2))
// filter by parent ID
fs := objectSDK.SearchFilters{}
fs.AddParentIDFilter(objectSDK.MatchStringEqual, par)
testSelect(t, db, fs, obj1.Address())
}