forked from TrueCloudLab/frostfs-node
[#208] Set unique splitID in children
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
6280d075b9
commit
f96630581a
1 changed files with 13 additions and 2 deletions
|
@ -27,6 +27,8 @@ type payloadSizeLimiter struct {
|
||||||
previous []*objectSDK.ID
|
previous []*objectSDK.ID
|
||||||
|
|
||||||
chunkWriter io.Writer
|
chunkWriter io.Writer
|
||||||
|
|
||||||
|
splitID *objectSDK.SplitID
|
||||||
}
|
}
|
||||||
|
|
||||||
type payloadChecksumHasher struct {
|
type payloadChecksumHasher struct {
|
||||||
|
@ -47,6 +49,7 @@ func NewPayloadSizeLimiter(maxSize uint64, targetInit TargetInitializer) ObjectT
|
||||||
return &payloadSizeLimiter{
|
return &payloadSizeLimiter{
|
||||||
maxSize: maxSize,
|
maxSize: maxSize,
|
||||||
targetInit: targetInit,
|
targetInit: targetInit,
|
||||||
|
splitID: objectSDK.NewSplitID(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,9 +79,9 @@ func (s *payloadSizeLimiter) initialize() {
|
||||||
// initialize parent object once (after 1st object)
|
// initialize parent object once (after 1st object)
|
||||||
if ln == 1 {
|
if ln == 1 {
|
||||||
s.parent = s.current
|
s.parent = s.current
|
||||||
|
s.current = fromObject(s.parent)
|
||||||
s.parent.ResetRelations()
|
s.parent.ResetRelations()
|
||||||
s.parentHashers = s.currentHashers
|
s.parentHashers = s.currentHashers
|
||||||
s.current = fromObject(s.parent)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set previous object to the last previous identifier
|
// set previous object to the last previous identifier
|
||||||
|
@ -95,6 +98,12 @@ func fromObject(obj *object.RawObject) *object.RawObject {
|
||||||
res.SetAttributes(obj.Attributes()...)
|
res.SetAttributes(obj.Attributes()...)
|
||||||
res.SetType(obj.Type())
|
res.SetType(obj.Type())
|
||||||
|
|
||||||
|
// obj.SetSplitID creates splitHeader but we don't need to do it in case
|
||||||
|
// of small objects, so we should make nil check.
|
||||||
|
if obj.SplitID() != nil {
|
||||||
|
res.SetSplitID(obj.SplitID())
|
||||||
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,14 +221,16 @@ func (s *payloadSizeLimiter) initializeLinking() {
|
||||||
s.current = fromObject(s.current)
|
s.current = fromObject(s.current)
|
||||||
s.current.SetParentID(id)
|
s.current.SetParentID(id)
|
||||||
s.current.SetChildren(s.previous...)
|
s.current.SetChildren(s.previous...)
|
||||||
|
s.current.SetSplitID(s.splitID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *payloadSizeLimiter) writeChunk(chunk []byte) error {
|
func (s *payloadSizeLimiter) writeChunk(chunk []byte) error {
|
||||||
// statement is true if the previous write of bytes reached exactly the boundary.
|
// statement is true if the previous write of bytes reached exactly the boundary.
|
||||||
if s.written > 0 && s.written%s.maxSize == 0 {
|
if s.written > 0 && s.written%s.maxSize == 0 {
|
||||||
if s.written == s.maxSize {
|
if s.written == s.maxSize {
|
||||||
// initialize blank split header on first object in chain
|
// initialize split header with split ID on first object in chain
|
||||||
s.current.InitRelations()
|
s.current.InitRelations()
|
||||||
|
s.current.SetSplitID(s.splitID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// we need to release current object
|
// we need to release current object
|
||||||
|
|
Loading…
Reference in a new issue