cache

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package cache provides subtree caching functionality.

Package cache is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogPopulateFunc

func LogPopulateFunc(hasher hashers.LogHasher) storage.PopulateSubtreeFunc

LogPopulateFunc obtains a log storage population function based on a supplied LogHasher. This is intended for use by storage utilities.

Types

type GetSubtreeFunc

type GetSubtreeFunc func(id storage.NodeID) (*storagepb.SubtreeProto, error)

GetSubtreeFunc describes a function which can return a Subtree from storage.

type GetSubtreesFunc

type GetSubtreesFunc func(ids []storage.NodeID) ([]*storagepb.SubtreeProto, error)

GetSubtreesFunc describes a function which can return a number of Subtrees from storage.

type MockNodeStorage

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

MockNodeStorage is a mock of NodeStorage interface

func NewMockNodeStorage

func NewMockNodeStorage(ctrl *gomock.Controller) *MockNodeStorage

NewMockNodeStorage creates a new mock instance

func (*MockNodeStorage) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockNodeStorage) GetSubtree

func (m *MockNodeStorage) GetSubtree(arg0 storage.NodeID) (*storagepb.SubtreeProto, error)

GetSubtree mocks base method

func (*MockNodeStorage) SetSubtrees

func (m *MockNodeStorage) SetSubtrees(arg0 []*storagepb.SubtreeProto) error

SetSubtrees mocks base method

type MockNodeStorageMockRecorder

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

MockNodeStorageMockRecorder is the mock recorder for MockNodeStorage

func (*MockNodeStorageMockRecorder) GetSubtree

func (mr *MockNodeStorageMockRecorder) GetSubtree(arg0 interface{}) *gomock.Call

GetSubtree indicates an expected call of GetSubtree

func (*MockNodeStorageMockRecorder) SetSubtrees

func (mr *MockNodeStorageMockRecorder) SetSubtrees(arg0 interface{}) *gomock.Call

SetSubtrees indicates an expected call of SetSubtrees

type NodeStorage

type NodeStorage interface {
	GetSubtree(n storage.NodeID) (*storagepb.SubtreeProto, error)
	SetSubtrees(s []*storagepb.SubtreeProto) error
}

NodeStorage provides an interface for storing and retrieving subtrees.

type SetSubtreesFunc

type SetSubtreesFunc func(s []*storagepb.SubtreeProto) error

SetSubtreesFunc describes a function which can store a collection of Subtrees into storage.

type SubtreeCache

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

SubtreeCache provides a caching access to Subtree storage. Currently there are assumptions in the code that all subtrees are multiple of 8 in depth and that log subtrees are always of depth 8. It is not possible to just change the constants above and have things still work. This is because of issues like byte packing of node IDs.

func NewLogSubtreeCache

func NewLogSubtreeCache(logStrata []int, hasher hashers.LogHasher) SubtreeCache

NewLogSubtreeCache creates and returns a SubtreeCache appropriate for use with a log tree. The caller must supply the strata depths to be used and a suitable LogHasher.

func NewMapSubtreeCache

func NewMapSubtreeCache(mapStrata []int, treeID int64, hasher hashers.MapHasher) SubtreeCache

NewMapSubtreeCache creates and returns a SubtreeCache appropriate for use with a map tree. The caller must supply the strata depths to be used, the treeID and a suitable MapHasher.

func NewSubtreeCache

func NewSubtreeCache(strataDepths []int, populateSubtree storage.PopulateSubtreeFunc, prepareSubtreeWrite storage.PrepareSubtreeWriteFunc) SubtreeCache

NewSubtreeCache returns a newly intialised cache ready for use. populateSubtree is a function which knows how to populate a subtree's internal nodes given its leaves, and will be called for each subtree loaded from storage. TODO(al): consider supporting different sized subtrees - for now everything's subtrees of 8 levels.

func (*SubtreeCache) Flush

func (s *SubtreeCache) Flush(setSubtrees SetSubtreesFunc) error

Flush causes the cache to write all dirty Subtrees back to storage.

func (*SubtreeCache) GetNodeHash

func (s *SubtreeCache) GetNodeHash(id storage.NodeID, getSubtree GetSubtreeFunc) ([]byte, error)

GetNodeHash returns a single node hash from the cache.

func (*SubtreeCache) GetNodes

func (s *SubtreeCache) GetNodes(ids []storage.NodeID, getSubtrees GetSubtreesFunc) ([]storage.Node, error)

GetNodes returns the requested nodes, calling the getSubtrees function if they are not already cached.

func (*SubtreeCache) SetNodeHash

func (s *SubtreeCache) SetNodeHash(id storage.NodeID, h []byte, getSubtree GetSubtreeFunc) error

SetNodeHash sets a node hash in the cache.

Jump to

Keyboard shortcuts

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