index

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2018 License: AGPL-3.0 Imports: 26 Imported by: 26

Documentation

Overview

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

  • Copyright (c) 2018. Abstrium SAS <team (at) pydio.com>
  • This file is part of Pydio Cells. *
  • Pydio Cells is free software: you can redistribute it and/or modify
  • it under the terms of the GNU Affero General Public License as published by
  • the Free Software Foundation, either version 3 of the License, or
  • (at your option) any later version. *
  • Pydio Cells is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY; without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU Affero General Public License for more details. *
  • You should have received a copy of the GNU Affero General Public License
  • along with Pydio Cells. If not, see <http://www.gnu.org/licenses/>. *
  • The latest code can be found at <https://pydio.com>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDAO

func NewDAO(o dao.DAO, rootNodeId string) dao.DAO

NewDAO for the common sql index

func NewNode

func NewNode(treeNode *tree.Node, path utils.MPath, filenames []string) *utils.TreeNode

NewNode utils

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 DAO

type DAO interface {
	Path(strpath string, create bool, reqNode ...*tree.Node) (utils.MPath, []*utils.TreeNode, error)

	// Simple Add / Set / Delete
	AddNode(*utils.TreeNode) error
	SetNode(*utils.TreeNode) error
	DelNode(*utils.TreeNode) error

	// Simple Add / Set / Delete
	AddNodeStream(int) (chan *utils.TreeNode, chan error)
	Flush(bool) error

	// Batch Add / Set / Delete
	GetNodes(...utils.MPath) chan *utils.TreeNode
	SetNodes(string, int64) sql.BatchSender

	// Getters
	GetNode(utils.MPath) (*utils.TreeNode, error)
	GetNodeByUUID(string) (*utils.TreeNode, error)
	GetNodeChild(utils.MPath, string) (*utils.TreeNode, error)
	GetNodeLastChild(utils.MPath) (*utils.TreeNode, error)
	GetNodeFirstAvailableChildIndex(utils.MPath) (uint64, error)
	GetNodeChildrenCount(utils.MPath) int
	GetNodeChildren(utils.MPath) chan *utils.TreeNode
	GetNodeTree(utils.MPath) chan *utils.TreeNode

	MoveNodeTree(nodeFrom *utils.TreeNode, nodeTo *utils.TreeNode) error

	PushCommit(node *utils.TreeNode) error
	DeleteCommits(node *utils.TreeNode) error
	ListCommits(node *utils.TreeNode) ([]*tree.ChangeLog, error)
	ResyncDirtyEtags(rootNode *utils.TreeNode) error
	CleanResourcesOnDeletion() (error, string)
}

DAO interface

func GetDAOCache

func GetDAOCache(session string) DAO

GetDAOCache returns the cache based on the session name

func NewDAOCache

func NewDAOCache(session string, d DAO) DAO

NewDAOCache wraps a cache around the dao

type DAOWrapper

type DAOWrapper func(d DAO) DAO

type IndexSQL

type IndexSQL struct {
	*sql.Handler
	// contains filtered or unexported fields
}

IndexSQL implementation

func (*IndexSQL) AddNode

func (dao *IndexSQL) AddNode(node *utils.TreeNode) error

AddNode to the mysql database

func (*IndexSQL) AddNodeStream

func (dao *IndexSQL) AddNodeStream(max int) (chan *utils.TreeNode, chan error)

AddNodeStream creates a channel to write to the database to the mysql database

func (*IndexSQL) CleanResourcesOnDeletion

func (dao *IndexSQL) CleanResourcesOnDeletion() (error, string)

CleanResourcesOnDeletion revert the creation of the table for a datasource

func (*IndexSQL) DelNode

func (dao *IndexSQL) DelNode(node *utils.TreeNode) error

DelNode from database

func (*IndexSQL) DeleteCommits

func (dao *IndexSQL) DeleteCommits(node *utils.TreeNode) error

DeleteCommits removes the commit versions of the node

func (*IndexSQL) Flush

func (dao *IndexSQL) Flush(final bool) error

Flush the database in case of cached inserts

func (*IndexSQL) GetNode

func (dao *IndexSQL) GetNode(path utils.MPath) (*utils.TreeNode, error)

GetNode from path

func (*IndexSQL) GetNodeByUUID

func (dao *IndexSQL) GetNodeByUUID(uuid string) (*utils.TreeNode, error)

GetNodeByUUID returns the node stored with the unique uuid

func (*IndexSQL) GetNodeChild

func (dao *IndexSQL) GetNodeChild(reqPath utils.MPath, reqName string) (*utils.TreeNode, error)

GetNodeChild from node path whose name matches

func (*IndexSQL) GetNodeChildren

func (dao *IndexSQL) GetNodeChildren(path utils.MPath) chan *utils.TreeNode

GetNodeChildren List

func (*IndexSQL) GetNodeChildrenCount added in v1.2.0

func (dao *IndexSQL) GetNodeChildrenCount(path utils.MPath) int

GetNodeChildrenCount List

func (*IndexSQL) GetNodeFirstAvailableChildIndex

func (dao *IndexSQL) GetNodeFirstAvailableChildIndex(reqPath utils.MPath) (uint64, error)

GetNodeFirstAvailableChildIndex from path

func (*IndexSQL) GetNodeLastChild

func (dao *IndexSQL) GetNodeLastChild(reqPath utils.MPath) (*utils.TreeNode, error)

GetNodeLastChild from path

func (*IndexSQL) GetNodeTree

func (dao *IndexSQL) GetNodeTree(path utils.MPath) chan *utils.TreeNode

GetNodeTree List from the path

func (*IndexSQL) GetNodes

func (dao *IndexSQL) GetNodes(mpathes ...utils.MPath) chan *utils.TreeNode

GetNodes List

func (*IndexSQL) Init

func (dao *IndexSQL) Init(options config.Map) error

Init handles the db version migration and prepare the statements

func (*IndexSQL) ListCommits

func (dao *IndexSQL) ListCommits(node *utils.TreeNode) (commits []*tree.ChangeLog, err error)

ListCommits returns a list of all commit versions for a node

func (*IndexSQL) MoveNodeTree

func (dao *IndexSQL) MoveNodeTree(nodeFrom *utils.TreeNode, nodeTo *utils.TreeNode) error

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

func (*IndexSQL) Path

func (dao *IndexSQL) Path(strpath string, create bool, reqNode ...*tree.Node) (utils.MPath, []*utils.TreeNode, error)

func (*IndexSQL) PushCommit

func (dao *IndexSQL) PushCommit(node *utils.TreeNode) error

PushCommit adds a commit version to the node

func (*IndexSQL) ResyncDirtyEtags

func (dao *IndexSQL) ResyncDirtyEtags(rootNode *utils.TreeNode) error

ResyncDirtyEtags ensures that etags are rightly calculated

func (*IndexSQL) SetNode

func (dao *IndexSQL) SetNode(node *utils.TreeNode) error

SetNode in replacement of previous node

func (*IndexSQL) SetNodes

func (dao *IndexSQL) SetNodes(etag string, deltaSize int64) sql.BatchSender

SetNodes returns a channel and waits for arriving nodes before updating them in batch

Jump to

Keyboard shortcuts

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