index

package
v5.0.0-...-ad4f444 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2025 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package index provides ready-to-use tables and DAOs for storing hierarchical data using the nested sets pattern

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterIndexLen

func RegisterIndexLen(len int)

Types

type BatchSend

type BatchSend struct {
	// contains filtered or unexported fields
}

BatchSend sql structure

func NewBatchSend

func NewBatchSend() *BatchSend

NewBatchSend Creation of the channels

func (*BatchSend) Close

func (b *BatchSend) Close() error

Close the Batch

func (*BatchSend) Send

func (b *BatchSend) Send(arg interface{})

Send a node to the batch

type BatchSender

type BatchSender interface {
	Send(interface{})
	Close() error
}

BatchSender interface

type CacheDAO

type CacheDAO interface {
	// PathCreateNoAdd does the same as Path(create=true) but does not really
	// create the node in the cache, just find a firstAvailableIndex
	PathCreateNoAdd(ctx context.Context, strpath string) (*tree.MPath, tree.ITreeNode, error)
}

type Cacher

type Cacher struct {
	// contains filtered or unexported fields
}

func NewCacher

func NewCacher(store cache.Cache) *Cacher

func (*Cacher) Get

func (c *Cacher) Get(key string) interface{}

func (*Cacher) Store

func (c *Cacher) Store(key string, val interface{}) error

type DAO

type DAO interface {
	Migrate(ctx context.Context) error

	// GetNodeTree retrieves all children recursively
	GetNodeTree(context.Context, *tree.MPath, ...*tree.MetaFilter) chan interface{}
	// GetNodeChildren retrieves all direct children of a Collection
	GetNodeChildren(context.Context, *tree.MPath, ...*tree.MetaFilter) chan interface{}
	// GetNodeChildrenCounts counts all collection children
	GetNodeChildrenCounts(context.Context, *tree.MPath, bool) (int, int)
	// GetNodeChildrenSize sums up all collection children sizes
	GetNodeChildrenSize(context.Context, *tree.MPath) (int, error)
	// GetNodesByMPaths takes multiple MPath as input and load all nodes at once
	GetNodesByMPaths(context.Context, ...*tree.MPath) chan tree.ITreeNode

	// GetNodeByMPath finds an existing node by its MPath
	GetNodeByMPath(context.Context, *tree.MPath) (tree.ITreeNode, error)
	// GetNodeByUUID finds an existing node by its UUID
	GetNodeByUUID(context.Context, string) (tree.ITreeNode, error)
	// GetNodeByPath lookups for a node at a given path, returning error if it does not exist
	GetNodeByPath(ctx context.Context, nodePath string) (tree.ITreeNode, error)
	// GetOrCreateNodeByPath lookups for an existing node at a given path, and creates it if required. It also creates intermediary collections if necessary.
	GetOrCreateNodeByPath(ctx context.Context, nodePath string, info *tree.Node, rootInfo ...*tree.Node) (tree.ITreeNode, []tree.ITreeNode, error)
	// UpdateNode updates a node position (mPath) and metadata
	UpdateNode(context.Context, tree.ITreeNode) error
	// DelNode removes a node from the tree
	DelNode(context.Context, tree.ITreeNode) error
	// MoveNodeTree moves a whole tree from one position to another. The target must not exist.
	MoveNodeTree(ctx context.Context, nodeFrom tree.ITreeNode, nodeTo tree.ITreeNode) error

	// AddNodeStream Simple Add / Set / Delete
	AddNodeStream(context.Context, int) (chan tree.ITreeNode, chan error)
	// Flush triggers underlying flush
	Flush(context.Context, bool) error
	// SetNodes returns a batcher that can be used for quick updates
	SetNodes(context.Context, string, int64) BatchSender

	ResyncDirtyEtags(ctx context.Context, rootNode tree.ITreeNode) error
	CleanResourcesOnDeletion(context.Context) (string, error)
	LostAndFounds(context.Context) ([]LostAndFound, error)
	FixLostAndFound(ctx context.Context, lost LostAndFound) error
	Flatten(context.Context) (string, error)
	UpdateNameInPlace(ctx context.Context, oldName, newName string, knownUuid string, knownLevel int) (int64, error)
	// contains filtered or unexported methods
}

DAO interface

func NewDAO

func NewDAO[T tree.ITreeNode](db *gorm.DB) DAO

NewDAO for the common sql index

func NewDAOWithCache

func NewDAOWithCache[T tree.ITreeNode](db *gorm.DB, ca cache.Cache) DAO

NewDAOWithCache for the common sql index

func NewFolderSizeCacheDAO

func NewFolderSizeCacheDAO(dao DAO) DAO

NewFolderSizeCacheDAO provides a middleware implementation of the index sql dao that removes duplicate entries of the .pydio file that have the same etag at the same level

func NewSessionDAO

func NewSessionDAO(session string, concurrency int, d DAO) DAO

NewSessionDAO wraps a cache around the dao

type Factory

type Factory[T tree.ITreeNode] interface {
	Struct() T
	Slice() []T
	RootGroupProvider
}

type FolderSizeCacheSQL

type FolderSizeCacheSQL struct {
	DAO
}

FolderSizeCacheSQL implementation

func (*FolderSizeCacheSQL) DelNode

func (dao *FolderSizeCacheSQL) DelNode(ctx context.Context, node tree.ITreeNode) error

DelNode removes a node from the tree

func (*FolderSizeCacheSQL) GetNodeByMPath

func (dao *FolderSizeCacheSQL) GetNodeByMPath(ctx context.Context, path *tree.MPath) (tree.ITreeNode, error)

GetNode from path

func (*FolderSizeCacheSQL) GetNodeByUUID

func (dao *FolderSizeCacheSQL) GetNodeByUUID(ctx context.Context, uuid string) (tree.ITreeNode, error)

GetNodeByUUID returns the node stored with the unique uuid

func (*FolderSizeCacheSQL) GetNodeChildren

func (dao *FolderSizeCacheSQL) GetNodeChildren(ctx context.Context, path *tree.MPath, filter ...*tree.MetaFilter) chan interface{}

GetNodeChildren List

func (*FolderSizeCacheSQL) GetNodeTree

func (dao *FolderSizeCacheSQL) GetNodeTree(ctx context.Context, path *tree.MPath, filter ...*tree.MetaFilter) chan interface{}

GetNodeTree List from the path

func (*FolderSizeCacheSQL) GetOrCreateNodeByPath

func (dao *FolderSizeCacheSQL) GetOrCreateNodeByPath(ctx context.Context, nodePath string, info *tree.Node, rootInfo ...*tree.Node) (tree.ITreeNode, []tree.ITreeNode, error)

func (*FolderSizeCacheSQL) MoveNodeTree

func (dao *FolderSizeCacheSQL) MoveNodeTree(ctx context.Context, nodeFrom tree.ITreeNode, nodeTo tree.ITreeNode) error

MoveNodeTree move all the nodes belonging to a tree by calculating the new mpathes

func (*FolderSizeCacheSQL) UpdateNode

func (dao *FolderSizeCacheSQL) UpdateNode(ctx context.Context, node tree.ITreeNode) error

SetNode updates a node, including its tree position

type LostAndFound

type LostAndFound interface {
	fmt.Stringer
	IsDuplicate() bool
	IsLostParent() bool
	IsDir() bool

	GetUUIDs() []string
	MarkForDeletion([]string)
}

type RootGroupProvider

type RootGroupProvider interface {
	RootGroup() string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL