[#177] metabase: Add index by object ID

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-20 10:43:41 +03:00 committed by Alex Vanin
parent dbf6c9efef
commit ffeea2c003
4 changed files with 24 additions and 3 deletions

2
go.mod
View file

@ -14,7 +14,7 @@ require (
github.com/multiformats/go-multiaddr-net v0.1.2 // v0.1.1 => v0.1.2 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/multiformats/go-multihash v0.0.13 // indirect
github.com/nspcc-dev/neo-go v0.91.1-pre.0.20201030072836-71216865717b 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/neofs-crypto v0.3.0
github.com/nspcc-dev/tzhash v1.4.0 github.com/nspcc-dev/tzhash v1.4.0
github.com/panjf2000/ants/v2 v2.3.0 github.com/panjf2000/ants/v2 v2.3.0

4
go.sum
View file

@ -276,8 +276,8 @@ github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:
github.com/nspcc-dev/neo-go v0.91.0/go.mod h1:G6HdOWvzQ6tlvFdvFSN/PgCzLPN/X/X4d5hTjFRUDcc= github.com/nspcc-dev/neo-go v0.91.0/go.mod h1:G6HdOWvzQ6tlvFdvFSN/PgCzLPN/X/X4d5hTjFRUDcc=
github.com/nspcc-dev/neo-go v0.91.1-pre.0.20201030072836-71216865717b h1:gk5bZgpWOehaDVKI5vBDkcjXTpRkKqcvIb1h/vHnBH4= github.com/nspcc-dev/neo-go v0.91.1-pre.0.20201030072836-71216865717b h1:gk5bZgpWOehaDVKI5vBDkcjXTpRkKqcvIb1h/vHnBH4=
github.com/nspcc-dev/neo-go v0.91.1-pre.0.20201030072836-71216865717b/go.mod h1:9s7LNp2lMgf0caH2t0sam4+WT2SIauXozwP0AdBqnEo= github.com/nspcc-dev/neo-go v0.91.1-pre.0.20201030072836-71216865717b/go.mod h1:9s7LNp2lMgf0caH2t0sam4+WT2SIauXozwP0AdBqnEo=
github.com/nspcc-dev/neofs-api-go v1.20.2 h1:jOsfgOQdKhg7gTAGciRdIdOJxYX72CxqgkwaqzEscHw= github.com/nspcc-dev/neofs-api-go v1.20.3-0.20201120074117-20ede88fe753 h1:POPtzByIf5zsvnEmPm+d89gQ41kFwYB7fxeMLqEwCqc=
github.com/nspcc-dev/neofs-api-go v1.20.2/go.mod h1:G7dqincfdjBrAbL5nxVp82emF05fSVEqe59ICsoRDI8= github.com/nspcc-dev/neofs-api-go v1.20.3-0.20201120074117-20ede88fe753/go.mod h1:G7dqincfdjBrAbL5nxVp82emF05fSVEqe59ICsoRDI8=
github.com/nspcc-dev/neofs-crypto v0.2.0/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA= github.com/nspcc-dev/neofs-crypto v0.2.0/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA=
github.com/nspcc-dev/neofs-crypto v0.2.3/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw= github.com/nspcc-dev/neofs-crypto v0.2.3/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw=
github.com/nspcc-dev/neofs-crypto v0.3.0 h1:zlr3pgoxuzrmGCxc5W8dGVfA9Rro8diFvVnBg0L4ifM= github.com/nspcc-dev/neofs-crypto v0.3.0 h1:zlr3pgoxuzrmGCxc5W8dGVfA9Rro8diFvVnBg0L4ifM=

View file

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

View file

@ -207,3 +207,20 @@ func TestSelectParentID(t *testing.T) {
testSelect(t, db, fs, obj1.Address()) 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())
}