Skip to content

Commit

Permalink
services/object: Drop unused code
Browse files Browse the repository at this point in the history
Signed-off-by: Leonard Lyubich <[email protected]>
  • Loading branch information
cthulhu-rider committed Dec 24, 2024
1 parent 156433f commit 9d73cec
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 283 deletions.
119 changes: 0 additions & 119 deletions pkg/services/object/util/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ type ObjectSource interface {
// Stop boolean result provides the ability to interrupt the traversal.
type SplitMemberHandler func(member *object.Object, reverseDirection bool) (stop bool)

// IterateAllSplitLeaves is an iterator over all object split-tree leaves in direct order.
func IterateAllSplitLeaves(r ObjectSource, addr oid.Address, h func(*object.Object)) error {
return IterateSplitLeaves(r, addr, func(leaf *object.Object) bool {
h(leaf)
return false
})
}

// IterateSplitLeaves is an iterator over object split-tree leaves in direct order.
//
// If member handler returns true, then the iterator aborts without error.
Expand Down Expand Up @@ -199,114 +191,3 @@ func headFromReceiver(r ObjectSource, addr oid.Address) (*object.Object, error)
return nil, fmt.Errorf("unexpected information: %T", res)
}
}

// TraverseSplitChain is an iterator over object split-tree leaves.
//
// Traversal occurs in one of two directions, which depends on what pslit info was received:
// * in direct order for link part;
// * in reverse order for last part.
func TraverseSplitChain(r ObjectSource, addr oid.Address, h SplitMemberHandler) error {
_, err := traverseSplitChain(r, addr, h)
return err
}

func traverseSplitChain(r ObjectSource, addr oid.Address, h SplitMemberHandler) (bool, error) {
v, err := r.Head(addr)
if err != nil {
return false, err
}

cnr := addr.Container()

switch res := v.(type) {
default:
panic(fmt.Sprintf("unexpected result of %T: %T", r, v))
case *object.Object:
return h(res, false), nil
case *object.SplitInfo:
link := res.GetLink()
last := res.GetLastPart()

switch {
default:
return false, errors.New("lack of split information")
case !link.IsZero():
var addr oid.Address
addr.SetContainer(cnr)
addr.SetObject(link)

chain := make([]oid.ID, 0)

if _, err := traverseSplitChain(r, addr, func(member *object.Object, reverseDirection bool) (stop bool) {
children := member.Children()

if reverseDirection {
chain = append(children, chain...)
} else {
chain = append(chain, children...)
}

return false
}); err != nil {
return false, err
}

var reverseChain []*object.Object

for i := range chain {
addr.SetObject(chain[i])

if stop, err := traverseSplitChain(r, addr, func(member *object.Object, reverseDirection bool) (stop bool) {
if !reverseDirection {
return h(member, false)
}

reverseChain = append(reverseChain, member)
return false
}); err != nil || stop {
return stop, err
}
}

for i := len(reverseChain) - 1; i >= 0; i-- {
if h(reverseChain[i], false) {
return true, nil
}
}
case !last.IsZero():
var addr oid.Address
addr.SetContainer(cnr)

for last = res.GetLastPart(); !last.IsZero(); {
addr.SetObject(last)

var directChain []*object.Object

if _, err := traverseSplitChain(r, addr, func(member *object.Object, reverseDirection bool) (stop bool) {
if reverseDirection {
last = member.GetPreviousID()
return h(member, true)
}

directChain = append(directChain, member)

return false
}); err != nil {
return false, err
}

for i := len(directChain) - 1; i >= 0; i-- {
if h(directChain[i], true) {
return true, nil
}
}

if len(directChain) > 0 {
last = directChain[len(directChain)-1].GetPreviousID()
}
}
}
}

return false, nil
}
164 changes: 0 additions & 164 deletions pkg/services/object/util/placement.go

This file was deleted.

0 comments on commit 9d73cec

Please sign in to comment.