frostfs-node/pkg/local_object_storage/pilorama/types.go
Evgenii Stratonikov 8cf71b7f1c [#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>
2022-07-21 15:08:24 +03:00

52 lines
1.1 KiB
Go

package pilorama
import (
"errors"
"math"
)
// Timestamp is an alias for integer timestamp type.
// TODO: remove after the debugging.
type Timestamp = uint64
// Node is used to represent nodes.
// TODO: remove after the debugging.
type Node = uint64
// Meta represents arbitrary meta information.
// TODO: remove after the debugging or create a proper interface.
type Meta struct {
Time Timestamp
Items []KeyValue
}
// KeyValue represents a key-value pair.
type KeyValue struct {
Key string
Value []byte
}
// Move represents a single move operation.
type Move struct {
Parent Node
Meta
// Child represents the ID of a node being moved. If zero, new ID is generated.
Child Node
}
// LogMove represents log record for a single move operation.
type LogMove struct {
Move
HasOld bool
Old nodeInfo
}
const (
// RootID represents the ID of a root node.
RootID = 0
// TrashID is a parent for all removed nodes.
TrashID = math.MaxUint64
)
// ErrTreeNotFound is returned when the requested tree is not found.
var ErrTreeNotFound = errors.New("tree not found")