[#1144] metabase: Support ec parent filter for Search

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
Airat Arifullin 2024-05-21 14:19:22 +03:00
parent 0b367007fc
commit f0edebea18
4 changed files with 26 additions and 1 deletions

View file

@ -262,7 +262,7 @@ func unknownMatcherBucket(_ *bbolt.Bucket, _ string, _ string, _ func([]byte, []
// in boltDB. Useful for getting filter values from unique and list indexes. // in boltDB. Useful for getting filter values from unique and list indexes.
func bucketKeyHelper(hdr string, val string) []byte { func bucketKeyHelper(hdr string, val string) []byte {
switch hdr { switch hdr {
case v2object.FilterHeaderParent: case v2object.FilterHeaderParent, v2object.FilterHeaderECParent:
v, err := base58.Decode(val) v, err := base58.Decode(val)
if err != nil { if err != nil {
return nil return nil

View file

@ -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 return nil
} }

View file

@ -211,6 +211,9 @@ func (db *DB) selectFastFilter(
case v2object.FilterHeaderSplitID: case v2object.FilterHeaderSplitID:
bucketName := splitBucketName(cnr, bucketName) bucketName := splitBucketName(cnr, bucketName)
db.selectFromList(tx, bucketName, f, to, fNum) db.selectFromList(tx, bucketName, f, to, fNum)
case v2object.FilterHeaderECParent:
bucketName := ecParentToChunksBucketName(cnr, bucketName)
db.selectFromList(tx, bucketName, f, to, fNum)
case v2object.FilterPropertyRoot: case v2object.FilterPropertyRoot:
selectAllFromBucket(tx, rootBucketName(cnr, bucketName), to, fNum) selectAllFromBucket(tx, rootBucketName(cnr, bucketName), to, fNum)
case v2object.FilterPropertyPhy: case v2object.FilterPropertyPhy:

View file

@ -124,6 +124,12 @@ const (
// Key: container ID + type // Key: container ID + type
// Value: Object id // Value: Object id
ecInfoPrefix 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 ( const (
@ -200,6 +206,11 @@ func ecInfoBucketName(cnr cid.ID, key []byte) []byte {
return bucketName(cnr, ecInfoPrefix, key) 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. // addressKey returns key for K-V tables when key is a whole address.
func addressKey(addr oid.Address, key []byte) []byte { func addressKey(addr oid.Address, key []byte) []byte {
addr.Container().Encode(key) addr.Container().Encode(key)