forked from TrueCloudLab/frostfs-node
[#1324] local_object_storage: Implement tree service backend
In this commit we implement algorithm for CRDT trees from https://martin.klepmann.com/papers/move-op.pdf Each tree is identified by the ID of a container it belongs to and the tree name itself. Essentially, it is a sequence of operations which should be applied in chronological order to get a usual tree representation. There are 2 backends for now: bbolt database and in-memory. In-memory backend is here for debugging and will eventually act as a memory-cache for the on-disk database. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
198beae703
commit
8cf71b7f1c
8 changed files with 1499 additions and 0 deletions
35
pkg/local_object_storage/pilorama/interface.go
Normal file
35
pkg/local_object_storage/pilorama/interface.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package pilorama
|
||||
|
||||
import cidSDK "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||
|
||||
// Forest represents CRDT tree.
|
||||
type Forest interface {
|
||||
// TreeMove moves node in the tree.
|
||||
// If the parent of the move operation is TrashID, the node is removed.
|
||||
// If the child of the move operation is RootID, new ID is generated and added to a tree.
|
||||
TreeMove(cid cidSDK.ID, treeID string, m *Move) (*LogMove, error)
|
||||
// TreeAddByPath adds new node in the tree using provided path.
|
||||
// The path is constructed by descending from the root using the values of the attr in meta.
|
||||
TreeAddByPath(cid cidSDK.ID, treeID string, attr string, path []string, meta []KeyValue) ([]LogMove, error)
|
||||
// TreeApply applies replicated operation from another node.
|
||||
TreeApply(cid cidSDK.ID, treeID string, m *Move) error
|
||||
// TreeGetByPath returns all nodes corresponding to the path.
|
||||
// The path is constructed by descending from the root using the values of the
|
||||
// AttributeFilename in meta.
|
||||
// The last argument determines whether only the node with the latest timestamp is returned.
|
||||
TreeGetByPath(cid cidSDK.ID, treeID string, attr string, path []string, latest bool) ([]Node, error)
|
||||
// TreeGetMeta returns meta information of the node with the specified ID.
|
||||
TreeGetMeta(cid cidSDK.ID, treeID string, nodeID Node) (Meta, error)
|
||||
}
|
||||
|
||||
type ForestStorage interface {
|
||||
Init() error
|
||||
Open() error
|
||||
Close() error
|
||||
Forest
|
||||
}
|
||||
|
||||
const (
|
||||
AttributeFilename = "FileName"
|
||||
AttributeVersion = "Version"
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue