forked from TrueCloudLab/frostfs-node
[#1103] node: Implement Get\Head
requests for EC object
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
167c52a1a9
commit
112a7c690f
30 changed files with 579 additions and 11 deletions
|
@ -1,6 +1,7 @@
|
|||
package meta
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
|
@ -264,6 +265,13 @@ func putUniqueIndexes(
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if ecHead := obj.GetECHeader(); ecHead != nil {
|
||||
err = putECInfo(tx, cnr, objKey, ecHead)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -571,3 +579,34 @@ func isLinkObject(obj *objectSDK.Object) bool {
|
|||
func isLastObject(obj *objectSDK.Object) bool {
|
||||
return len(obj.Children()) == 0 && obj.Parent() != nil
|
||||
}
|
||||
|
||||
func putECInfo(tx *bbolt.Tx,
|
||||
cnr cid.ID, objKey []byte,
|
||||
ecHead *objectSDK.ECHeader,
|
||||
) error {
|
||||
parentID := objectKey(ecHead.Parent(), make([]byte, objectKeySize))
|
||||
bucketName := make([]byte, bucketKeySize)
|
||||
|
||||
val := getFromBucket(tx, ecInfoBucketName(cnr, bucketName), parentID)
|
||||
if len(val) == 0 {
|
||||
val = objKey
|
||||
} else {
|
||||
offset := 0
|
||||
found := false
|
||||
for offset < len(val) {
|
||||
if bytes.Equal(objKey, val[offset:offset+objectKeySize]) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
offset += objectKeySize
|
||||
}
|
||||
if !found {
|
||||
val = append(val, objKey...)
|
||||
}
|
||||
}
|
||||
return putUniqueIndexItem(tx, namedBucketItem{
|
||||
name: ecInfoBucketName(cnr, make([]byte, bucketKeySize)),
|
||||
key: parentID,
|
||||
val: val,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue