[#1144] metabase: Support ec parent filter for Search
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
0b367007fc
commit
f0edebea18
4 changed files with 26 additions and 1 deletions
|
@ -262,7 +262,7 @@ func unknownMatcherBucket(_ *bbolt.Bucket, _ string, _ string, _ func([]byte, []
|
|||
// in boltDB. Useful for getting filter values from unique and list indexes.
|
||||
func bucketKeyHelper(hdr string, val string) []byte {
|
||||
switch hdr {
|
||||
case v2object.FilterHeaderParent:
|
||||
case v2object.FilterHeaderParent, v2object.FilterHeaderECParent:
|
||||
v, err := base58.Decode(val)
|
||||
if err != nil {
|
||||
return nil
|
||||
|
|
|
@ -323,6 +323,17 @@ func updateListIndexes(tx *bbolt.Tx, obj *objectSDK.Object, f updateIndexItemFun
|
|||
}
|
||||
}
|
||||
|
||||
if ech := obj.ECHeader(); ech != nil {
|
||||
err := f(tx, namedBucketItem{
|
||||
name: ecParentToChunksBucketName(cnr, bucketName),
|
||||
key: objectKey(ech.Parent(), make([]byte, objectKeySize)),
|
||||
val: objKey,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -211,6 +211,9 @@ func (db *DB) selectFastFilter(
|
|||
case v2object.FilterHeaderSplitID:
|
||||
bucketName := splitBucketName(cnr, bucketName)
|
||||
db.selectFromList(tx, bucketName, f, to, fNum)
|
||||
case v2object.FilterHeaderECParent:
|
||||
bucketName := ecParentToChunksBucketName(cnr, bucketName)
|
||||
db.selectFromList(tx, bucketName, f, to, fNum)
|
||||
case v2object.FilterPropertyRoot:
|
||||
selectAllFromBucket(tx, rootBucketName(cnr, bucketName), to, fNum)
|
||||
case v2object.FilterPropertyPhy:
|
||||
|
|
|
@ -124,6 +124,12 @@ const (
|
|||
// Key: container ID + type
|
||||
// Value: Object id
|
||||
ecInfoPrefix
|
||||
|
||||
// ecParentToChunksPrefix is used to store a relation between EC parent ID and chunks,
|
||||
// but unlike for ecInfoPrefix the list of chunk IDs is encoded with encodeList.
|
||||
// Key: EC parent ID
|
||||
// Value: list of EC chunk IDs
|
||||
ecParentToChunksPrefix
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -200,6 +206,11 @@ func ecInfoBucketName(cnr cid.ID, key []byte) []byte {
|
|||
return bucketName(cnr, ecInfoPrefix, key)
|
||||
}
|
||||
|
||||
// ecParentToChunksBucketName returns <CID>_ecParentToChunks.
|
||||
func ecParentToChunksBucketName(cnr cid.ID, key []byte) []byte {
|
||||
return bucketName(cnr, ecParentToChunksPrefix, key)
|
||||
}
|
||||
|
||||
// addressKey returns key for K-V tables when key is a whole address.
|
||||
func addressKey(addr oid.Address, key []byte) []byte {
|
||||
addr.Container().Encode(key)
|
||||
|
|
Loading…
Reference in a new issue