From ffeea2c003574d32d66d0cf8b740bf64357798f8 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Fri, 20 Nov 2020 10:43:41 +0300 Subject: [PATCH] [#177] metabase: Add index by object ID Signed-off-by: Leonard Lyubich --- go.mod | 2 +- go.sum | Bin 59689 -> 59749 bytes pkg/local_object_storage/metabase/put.go | 4 ++++ .../metabase/select_test.go | 17 +++++++++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index dc90d21f0..6509c03f3 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/multiformats/go-multiaddr-net v0.1.2 // v0.1.1 => v0.1.2 github.com/multiformats/go-multihash v0.0.13 // indirect github.com/nspcc-dev/neo-go v0.91.1-pre.0.20201030072836-71216865717b - github.com/nspcc-dev/neofs-api-go v1.20.2 + github.com/nspcc-dev/neofs-api-go v1.20.3-0.20201120074117-20ede88fe753 github.com/nspcc-dev/neofs-crypto v0.3.0 github.com/nspcc-dev/tzhash v1.4.0 github.com/panjf2000/ants/v2 v2.3.0 diff --git a/go.sum b/go.sum index 4b2b7756d38e0ecc5c6d38178cbd2b816d08633b..c653c126093d3b43e9c3d42e406d4f98215f1e3a 100644 GIT binary patch delta 133 zcmZ2^iTUXz<_%m~e#W{6dPW9D28M=41_tIPhKA<4Mh2-VsTLM#sph7}3K@o00sa9c zRZf+jX{J@hWqGc-0lC^K7MAIOCWhH=<&jS2X%(ryK83F3&V|X73vE`Jnj_%2sK`EXo{$3T45#~nD6@}^9 Z<%xw=uEoh7<&z&|YB3sZUYK>H4giF38gT#s diff --git a/pkg/local_object_storage/metabase/put.go b/pkg/local_object_storage/metabase/put.go index 7fde8b0d3..a42f0e9fa 100644 --- a/pkg/local_object_storage/metabase/put.go +++ b/pkg/local_object_storage/metabase/put.go @@ -124,6 +124,10 @@ func objectIndices(obj *object.Object, parent bool) []bucketItem { key: v2object.FilterHeaderParent, val: obj.ParentID().String(), }, + bucketItem{ + key: v2object.FilterHeaderObjectID, + val: obj.ID().String(), + }, // TODO: add remaining fields after neofs-api#72 ) diff --git a/pkg/local_object_storage/metabase/select_test.go b/pkg/local_object_storage/metabase/select_test.go index 04708db87..43371548a 100644 --- a/pkg/local_object_storage/metabase/select_test.go +++ b/pkg/local_object_storage/metabase/select_test.go @@ -207,3 +207,20 @@ func TestSelectParentID(t *testing.T) { testSelect(t, db, fs, obj1.Address()) } + +func TestSelectObjectID(t *testing.T) { + db := newDB(t) + defer releaseDB(db) + + // generate object + obj := generateObject(t, testPrm{}) + + // store objects + require.NoError(t, db.Put(obj)) + + // filter by object ID + fs := objectSDK.SearchFilters{} + fs.AddObjectIDFilter(objectSDK.MatchStringEqual, obj.ID()) + + testSelect(t, db, fs, obj.Address()) +}