[#149] metabase: Add parent ID index
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
65be09d3db
commit
2913aa0fd1
2 changed files with 27 additions and 0 deletions
|
@ -142,6 +142,10 @@ func objectIndices(obj *object.Object, parent bool) []bucketItem {
|
|||
key: v2object.FilterPropertyChildfree,
|
||||
val: childfreeVal,
|
||||
},
|
||||
bucketItem{
|
||||
key: v2object.FilterHeaderParent,
|
||||
val: obj.GetParentID().String(),
|
||||
},
|
||||
// TODO: add remaining fields after neofs-api#72
|
||||
)
|
||||
|
||||
|
|
|
@ -184,3 +184,26 @@ func TestMissingObjectAttribute(t *testing.T) {
|
|||
|
||||
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())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue