forked from TrueCloudLab/frostfs-node
[#840] shard: Return only physically stored objects from List
`List` method of `Shard` must return only physically stored objects. Use `AddPhyFilter` to select only phy objects. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
b97cdbea9e
commit
02e6df683a
2 changed files with 7 additions and 1 deletions
|
@ -19,6 +19,7 @@ func (r *ListContainersRes) Containers() []*cid.ID {
|
||||||
return r.containers
|
return r.containers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List returns all objects physically stored in the Shard.
|
||||||
func (s *Shard) List() (*SelectRes, error) {
|
func (s *Shard) List() (*SelectRes, error) {
|
||||||
lst, err := s.metaBase.Containers()
|
lst, err := s.metaBase.Containers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -27,6 +28,7 @@ func (s *Shard) List() (*SelectRes, error) {
|
||||||
|
|
||||||
res := new(SelectRes)
|
res := new(SelectRes)
|
||||||
filters := object.NewSearchFilters()
|
filters := object.NewSearchFilters()
|
||||||
|
filters.AddPhyFilter()
|
||||||
|
|
||||||
for i := range lst {
|
for i := range lst {
|
||||||
ids, err := meta.Select(s.metaBase, lst[i], filters) // consider making List in metabase
|
ids, err := meta.Select(s.metaBase, lst[i], filters) // consider making List in metabase
|
||||||
|
|
|
@ -40,6 +40,11 @@ func testShardList(t *testing.T, sh *shard.Shard) {
|
||||||
obj := generateRawObjectWithCID(t, cid)
|
obj := generateRawObjectWithCID(t, cid)
|
||||||
addPayload(obj, 1<<2)
|
addPayload(obj, 1<<2)
|
||||||
|
|
||||||
|
// add parent as virtual object, it must be ignored in List()
|
||||||
|
parent := generateRawObjectWithCID(t, cid)
|
||||||
|
obj.SetParentID(parent.Object().ID())
|
||||||
|
obj.SetParent(parent.Object().SDK())
|
||||||
|
|
||||||
objs[obj.Object().Address().String()] = 0
|
objs[obj.Object().Address().String()] = 0
|
||||||
|
|
||||||
putPrm.WithObject(obj.Object())
|
putPrm.WithObject(obj.Object())
|
||||||
|
@ -53,7 +58,6 @@ func testShardList(t *testing.T, sh *shard.Shard) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
for _, objID := range res.AddressList() {
|
for _, objID := range res.AddressList() {
|
||||||
|
|
||||||
i, ok := objs[objID.String()]
|
i, ok := objs[objID.String()]
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
require.Equal(t, 0, i)
|
require.Equal(t, 0, i)
|
||||||
|
|
Loading…
Reference in a new issue