From 6280d075b9520b231fe2f0a67e67efd20025168f Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Thu, 26 Nov 2020 12:15:15 +0300 Subject: [PATCH] [#208] Remove `childfree` search attribute With updated specification of object related operation we don't have this search attribute any more and we should not use functions related to this attribute. This commit breaks object service logic, however it will be fixed later. Signed-off-by: Alex Vanin --- pkg/local_object_storage/metabase/db.go | 2 -- pkg/local_object_storage/metabase/db_test.go | 18 ------------------ pkg/local_object_storage/metabase/put.go | 11 +---------- pkg/services/object/search/query/v1/keys.go | 4 ++-- 4 files changed, 3 insertions(+), 32 deletions(-) diff --git a/pkg/local_object_storage/metabase/db.go b/pkg/local_object_storage/metabase/db.go index a7a6ac9a3e..5621b51ca0 100644 --- a/pkg/local_object_storage/metabase/db.go +++ b/pkg/local_object_storage/metabase/db.go @@ -63,8 +63,6 @@ func stringEqualMatcher(key, objVal, filterVal string) bool { switch key { default: return objVal == filterVal - case v2object.FilterPropertyChildfree: - return (filterVal == v2object.BooleanPropertyValueTrue) == (objVal == v2object.BooleanPropertyValueTrue) case v2object.FilterPropertyPhy, v2object.FilterPropertyRoot: return true } diff --git a/pkg/local_object_storage/metabase/db_test.go b/pkg/local_object_storage/metabase/db_test.go index 5782e82e52..4e27f35e98 100644 --- a/pkg/local_object_storage/metabase/db_test.go +++ b/pkg/local_object_storage/metabase/db_test.go @@ -10,7 +10,6 @@ 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/pkg/errors" @@ -174,24 +173,7 @@ func TestDB_SelectProperties(t *testing.T) { 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) } func TestDB_Path(t *testing.T) { diff --git a/pkg/local_object_storage/metabase/put.go b/pkg/local_object_storage/metabase/put.go index a42f0e9fae..cda37b8980 100644 --- a/pkg/local_object_storage/metabase/put.go +++ b/pkg/local_object_storage/metabase/put.go @@ -96,12 +96,7 @@ func addressKey(addr *objectSDK.Address) []byte { func objectIndices(obj *object.Object, parent bool) []bucketItem { as := obj.Attributes() - res := make([]bucketItem, 0, 7+len(as)) // 7 predefined buckets and object attributes - - childfreeVal := v2object.BooleanPropertyValueTrue - if len(obj.Children()) > 0 { - childfreeVal = "" - } + res := make([]bucketItem, 0, 6+len(as)) // 6 predefined buckets and object attributes res = append(res, bucketItem{ @@ -116,10 +111,6 @@ func objectIndices(obj *object.Object, parent bool) []bucketItem { key: v2object.FilterHeaderOwnerID, val: obj.OwnerID().String(), }, - bucketItem{ - key: v2object.FilterPropertyChildfree, - val: childfreeVal, - }, bucketItem{ key: v2object.FilterHeaderParent, val: obj.ParentID().String(), diff --git a/pkg/services/object/search/query/v1/keys.go b/pkg/services/object/search/query/v1/keys.go index cd062ce117..7b866ce5a6 100644 --- a/pkg/services/object/search/query/v1/keys.go +++ b/pkg/services/object/search/query/v1/keys.go @@ -8,24 +8,24 @@ import ( // FIXME: this is a temporary solution for object fields filters +// fixme: remove it, it is broken now func NewRightChildQuery(par *object.ID) query.Query { q := &Query{ filters: make(object.SearchFilters, 0, 2), } q.filters.AddFilter(v2object.FilterHeaderParent, idValue(par), object.MatchStringEqual) - q.filters.AddFilter(v2object.FilterPropertyChildfree, v2object.BooleanPropertyValueTrue, object.MatchStringEqual) return q } +// fixme: remove it, it is broken now func NewLinkingQuery(par *object.ID) query.Query { q := &Query{ filters: make(object.SearchFilters, 0, 2), } q.filters.AddFilter(v2object.FilterHeaderParent, idValue(par), object.MatchStringEqual) - q.filters.AddFilter(v2object.FilterPropertyChildfree, v2object.BooleanPropertyValueFalse, object.MatchStringEqual) return q }