2022-04-22 13:29:43 +00:00
|
|
|
package shard
|
|
|
|
|
|
|
|
import (
|
2022-07-18 10:16:23 +00:00
|
|
|
"errors"
|
|
|
|
|
2022-04-22 13:29:43 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama"
|
|
|
|
cidSDK "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ pilorama.Forest = (*Shard)(nil)
|
|
|
|
|
2022-07-18 10:16:23 +00:00
|
|
|
// ErrPiloramaDisabled is returned when pilorama was disabled in the configuration.
|
|
|
|
var ErrPiloramaDisabled = errors.New("plorama is disabled")
|
|
|
|
|
2022-04-22 13:29:43 +00:00
|
|
|
// TreeMove implements the pilorama.Forest interface.
|
2022-05-27 12:55:02 +00:00
|
|
|
func (s *Shard) TreeMove(d pilorama.CIDDescriptor, treeID string, m *pilorama.Move) (*pilorama.LogMove, error) {
|
2022-07-18 10:16:23 +00:00
|
|
|
if s.pilorama == nil {
|
|
|
|
return nil, ErrPiloramaDisabled
|
|
|
|
}
|
2022-06-29 11:27:36 +00:00
|
|
|
if s.GetMode().ReadOnly() {
|
2022-05-16 13:02:35 +00:00
|
|
|
return nil, ErrReadOnlyMode
|
|
|
|
}
|
2022-05-27 12:55:02 +00:00
|
|
|
return s.pilorama.TreeMove(d, treeID, m)
|
2022-04-22 13:29:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TreeAddByPath implements the pilorama.Forest interface.
|
2022-05-27 12:55:02 +00:00
|
|
|
func (s *Shard) TreeAddByPath(d pilorama.CIDDescriptor, treeID string, attr string, path []string, meta []pilorama.KeyValue) ([]pilorama.LogMove, error) {
|
2022-07-18 10:16:23 +00:00
|
|
|
if s.pilorama == nil {
|
|
|
|
return nil, ErrPiloramaDisabled
|
|
|
|
}
|
2022-06-29 11:27:36 +00:00
|
|
|
if s.GetMode().ReadOnly() {
|
2022-05-16 13:02:35 +00:00
|
|
|
return nil, ErrReadOnlyMode
|
|
|
|
}
|
2022-05-27 12:55:02 +00:00
|
|
|
return s.pilorama.TreeAddByPath(d, treeID, attr, path, meta)
|
2022-04-22 13:29:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TreeApply implements the pilorama.Forest interface.
|
2022-05-27 12:55:02 +00:00
|
|
|
func (s *Shard) TreeApply(d pilorama.CIDDescriptor, treeID string, m *pilorama.Move) error {
|
2022-07-18 10:16:23 +00:00
|
|
|
if s.pilorama == nil {
|
|
|
|
return ErrPiloramaDisabled
|
|
|
|
}
|
2022-06-29 11:27:36 +00:00
|
|
|
if s.GetMode().ReadOnly() {
|
2022-05-16 13:02:35 +00:00
|
|
|
return ErrReadOnlyMode
|
|
|
|
}
|
2022-05-27 12:55:02 +00:00
|
|
|
return s.pilorama.TreeApply(d, treeID, m)
|
2022-04-22 13:29:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TreeGetByPath implements the pilorama.Forest interface.
|
|
|
|
func (s *Shard) TreeGetByPath(cid cidSDK.ID, treeID string, attr string, path []string, latest bool) ([]pilorama.Node, error) {
|
2022-07-18 10:16:23 +00:00
|
|
|
if s.pilorama == nil {
|
|
|
|
return nil, ErrPiloramaDisabled
|
|
|
|
}
|
2022-04-22 13:29:43 +00:00
|
|
|
return s.pilorama.TreeGetByPath(cid, treeID, attr, path, latest)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TreeGetMeta implements the pilorama.Forest interface.
|
2022-05-20 08:41:37 +00:00
|
|
|
func (s *Shard) TreeGetMeta(cid cidSDK.ID, treeID string, nodeID pilorama.Node) (pilorama.Meta, uint64, error) {
|
2022-07-18 10:16:23 +00:00
|
|
|
if s.pilorama == nil {
|
|
|
|
return pilorama.Meta{}, 0, ErrPiloramaDisabled
|
|
|
|
}
|
2022-04-22 13:29:43 +00:00
|
|
|
return s.pilorama.TreeGetMeta(cid, treeID, nodeID)
|
|
|
|
}
|
2022-04-29 10:06:10 +00:00
|
|
|
|
|
|
|
// TreeGetChildren implements the pilorama.Forest interface.
|
|
|
|
func (s *Shard) TreeGetChildren(cid cidSDK.ID, treeID string, nodeID pilorama.Node) ([]uint64, error) {
|
2022-07-18 10:16:23 +00:00
|
|
|
if s.pilorama == nil {
|
|
|
|
return nil, ErrPiloramaDisabled
|
|
|
|
}
|
2022-04-29 10:06:10 +00:00
|
|
|
return s.pilorama.TreeGetChildren(cid, treeID, nodeID)
|
|
|
|
}
|
2022-05-11 13:29:04 +00:00
|
|
|
|
|
|
|
// TreeGetOpLog implements the pilorama.Forest interface.
|
|
|
|
func (s *Shard) TreeGetOpLog(cid cidSDK.ID, treeID string, height uint64) (pilorama.Move, error) {
|
2022-07-18 10:16:23 +00:00
|
|
|
if s.pilorama == nil {
|
|
|
|
return pilorama.Move{}, ErrPiloramaDisabled
|
|
|
|
}
|
2022-05-11 13:29:04 +00:00
|
|
|
return s.pilorama.TreeGetOpLog(cid, treeID, height)
|
|
|
|
}
|
2022-09-07 08:46:13 +00:00
|
|
|
|
|
|
|
// TreeDrop implements the pilorama.Forest interface.
|
|
|
|
func (s *Shard) TreeDrop(cid cidSDK.ID, treeID string) error {
|
|
|
|
if s.pilorama == nil {
|
|
|
|
return ErrPiloramaDisabled
|
|
|
|
}
|
|
|
|
return s.pilorama.TreeDrop(cid, treeID)
|
|
|
|
}
|
2022-10-18 11:59:32 +00:00
|
|
|
|
|
|
|
// TreeList implements the pilorama.Forest interface.
|
|
|
|
func (s *Shard) TreeList(cid cidSDK.ID) ([]string, error) {
|
|
|
|
//TODO implement me
|
|
|
|
panic("implement me")
|
|
|
|
}
|