forked from TrueCloudLab/frostfs-node
[#1347] metabase: Fix EC search
For EC chunks need to return EC parent object ID as EC chunks don't have own attributes but inherit parent's. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
b33559754d
commit
e3764c51df
2 changed files with 40 additions and 8 deletions
|
@ -150,7 +150,8 @@ func (db *DB) selectObjects(tx *bbolt.Tx, cnr cid.ID, fs objectSDK.SearchFilters
|
|||
continue // ignore removed objects
|
||||
}
|
||||
|
||||
if !db.matchSlowFilters(tx, addr, group.slowFilters, currEpoch) {
|
||||
addr, match := db.matchSlowFilters(tx, addr, group.slowFilters, currEpoch)
|
||||
if !match {
|
||||
continue // ignore objects with unmatched slow filters
|
||||
}
|
||||
|
||||
|
@ -382,15 +383,16 @@ func (db *DB) selectObjectID(
|
|||
}
|
||||
|
||||
// matchSlowFilters return true if object header is matched by all slow filters.
|
||||
func (db *DB) matchSlowFilters(tx *bbolt.Tx, addr oid.Address, f objectSDK.SearchFilters, currEpoch uint64) bool {
|
||||
func (db *DB) matchSlowFilters(tx *bbolt.Tx, addr oid.Address, f objectSDK.SearchFilters, currEpoch uint64) (oid.Address, bool) {
|
||||
result := addr
|
||||
if len(f) == 0 {
|
||||
return true
|
||||
return result, true
|
||||
}
|
||||
|
||||
buf := make([]byte, addressKeySize)
|
||||
obj, err := db.get(tx, addr, buf, true, false, currEpoch)
|
||||
if err != nil {
|
||||
return false
|
||||
return result, false
|
||||
}
|
||||
|
||||
for i := range f {
|
||||
|
@ -415,23 +417,26 @@ func (db *DB) matchSlowFilters(tx *bbolt.Tx, addr oid.Address, f objectSDK.Searc
|
|||
default: // user attribute
|
||||
v, ok := attributeValue(obj, f[i].Header())
|
||||
if ok {
|
||||
if ech := obj.ECHeader(); ech != nil {
|
||||
result.SetObject(ech.Parent())
|
||||
}
|
||||
data = []byte(v)
|
||||
} else {
|
||||
return f[i].Operation() == objectSDK.MatchNotPresent
|
||||
return result, f[i].Operation() == objectSDK.MatchNotPresent
|
||||
}
|
||||
}
|
||||
|
||||
matchFunc, ok := db.matchers[f[i].Operation()]
|
||||
if !ok {
|
||||
return false
|
||||
return result, false
|
||||
}
|
||||
|
||||
if !matchFunc.matchSlow(f[i].Header(), data, f[i].Value()) {
|
||||
return false
|
||||
return result, false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
return result, true
|
||||
}
|
||||
|
||||
func attributeValue(obj *objectSDK.Object, attribute string) (string, bool) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue