forked from TrueCloudLab/frostfs-node
[#1408] metabase: Fix EC search with slow and fast filters
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
f83f7feb8c
commit
434048e8d9
2 changed files with 83 additions and 2 deletions
|
@ -389,8 +389,7 @@ func (db *DB) matchSlowFilters(tx *bbolt.Tx, addr oid.Address, f objectSDK.Searc
|
|||
return result, true
|
||||
}
|
||||
|
||||
buf := make([]byte, addressKeySize)
|
||||
obj, err := db.get(tx, addr, buf, true, false, currEpoch)
|
||||
obj, isECChunk, err := db.getObjectForSlowFilters(tx, addr, currEpoch)
|
||||
if err != nil {
|
||||
return result, false
|
||||
}
|
||||
|
@ -401,17 +400,26 @@ func (db *DB) matchSlowFilters(tx *bbolt.Tx, addr oid.Address, f objectSDK.Searc
|
|||
case v2object.FilterHeaderVersion:
|
||||
data = []byte(obj.Version().String())
|
||||
case v2object.FilterHeaderHomomorphicHash:
|
||||
if isECChunk {
|
||||
return result, false // EC chunk and EC parent hashes are incomparable
|
||||
}
|
||||
cs, _ := obj.PayloadHomomorphicHash()
|
||||
data = cs.Value()
|
||||
case v2object.FilterHeaderCreationEpoch:
|
||||
data = make([]byte, 8)
|
||||
binary.LittleEndian.PutUint64(data, obj.CreationEpoch())
|
||||
case v2object.FilterHeaderPayloadLength:
|
||||
if isECChunk {
|
||||
return result, false // EC chunk and EC parent payload lengths are incomparable
|
||||
}
|
||||
data = make([]byte, 8)
|
||||
binary.LittleEndian.PutUint64(data, obj.PayloadSize())
|
||||
case v2object.FilterHeaderOwnerID:
|
||||
data = []byte(obj.OwnerID().EncodeToString())
|
||||
case v2object.FilterHeaderPayloadHash:
|
||||
if isECChunk {
|
||||
return result, false // EC chunk and EC parent payload hashes are incomparable
|
||||
}
|
||||
cs, _ := obj.PayloadChecksum()
|
||||
data = cs.Value()
|
||||
default: // user attribute
|
||||
|
@ -439,6 +447,29 @@ func (db *DB) matchSlowFilters(tx *bbolt.Tx, addr oid.Address, f objectSDK.Searc
|
|||
return result, true
|
||||
}
|
||||
|
||||
func (db *DB) getObjectForSlowFilters(tx *bbolt.Tx, addr oid.Address, currEpoch uint64) (*objectSDK.Object, bool, error) {
|
||||
buf := make([]byte, addressKeySize)
|
||||
obj, err := db.get(tx, addr, buf, true, false, currEpoch)
|
||||
if err != nil {
|
||||
var ecInfoError *objectSDK.ECInfoError
|
||||
if errors.As(err, &ecInfoError) {
|
||||
for _, chunk := range ecInfoError.ECInfo().Chunks {
|
||||
var objID oid.ID
|
||||
if err = objID.ReadFromV2(chunk.ID); err != nil {
|
||||
continue
|
||||
}
|
||||
addr.SetObject(objID)
|
||||
obj, err = db.get(tx, addr, buf, true, false, currEpoch)
|
||||
if err == nil {
|
||||
return obj, true, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil, false, err
|
||||
}
|
||||
return obj, false, nil
|
||||
}
|
||||
|
||||
func attributeValue(obj *objectSDK.Object, attribute string) (string, bool) {
|
||||
objectAttributes := obj.Attributes()
|
||||
if ech := obj.ECHeader(); ech != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue