libs

package
v0.0.0-...-0d681e9 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const UnixfsChunkSize uint64 = 1 << 20 //Deafault chunksize 2M

Variables

This section is empty.

Functions

func DefaultDagServiceAction

func DefaultDagServiceAction(c cid.Cid, nodeType pb.Data_DataType)

func DefaultHelperAction

func DefaultHelperAction(node ipld.Node, srcPath string, offset uint64, size uint64)

func DefaultWriteAfterAction

func DefaultWriteAfterAction(path string, buf []byte, offset uint64)

func DefaultWriteBeforeAction

func DefaultWriteBeforeAction(buf []byte, w io.Writer) ([]byte, error)

func WrappedDagService

func WrappedDagService(dagService ipld.DAGService, cb DagServiceAction) ipld.DAGService

func WrappedWriter

func WrappedWriter(w io.Writer, path string, acb WriteAfterAction, bcb WriteBeforeAction) io.Writer

Types

type DagServiceAction

type DagServiceAction func(node ipld.Node)

type EnhancedSplitter

type EnhancedSplitter interface {
	chunker.Splitter
	NextBytesWithMeta() ([]byte, *SliceMeta, error)
}

Defining the EnhancedSplitter interface as an extension of the Splitter interface, which reads data while also returning source data path, offset, and size

func NewSplitter

func NewSplitter(r io.Reader, size int64, srcPath string, parentPath string, chunkStart uint64) (EnhancedSplitter, error)

type HelperAction

type HelperAction func(node ipld.Node, srcPath string, offset uint64, size uint64)

Helper callback function, when Helper calls Add to add a node to DAGService, it passes the mapping information of the node to MappingService.

type SliceMeta

type SliceMeta struct {
	Path   string
	Offset uint64
	Size   uint64
}

Reading data while obtaining source data information, including the source data file path, offset, and size:

type WrapDagBuilder

type WrapDagBuilder struct {
	helpers.Helper
	// contains filtered or unexported fields
}

func WrappedDagBuilder

func WrappedDagBuilder(params *helpers.DagBuilderParams, spl EnhancedSplitter, hcb HelperAction) (*WrapDagBuilder, error)

func (*WrapDagBuilder) Add

func (w *WrapDagBuilder) Add(node ipld.Node) error

Rewrite the 'Add' method to invoke a callback function to pass back the mapping information of the node.

func (*WrapDagBuilder) Done

func (w *WrapDagBuilder) Done() bool

Rewrite the 'Done' function to make the helper retrieve data from the 'EnhancedSplitter' interface.

func (*WrapDagBuilder) NewLeafDataNode

func (w *WrapDagBuilder) NewLeafDataNode(fsNodeType pb.Data_DataType) (node ipld.Node, dataSize uint64, err error)

Rewrite 'NewLeafDataNode' to cache the 'SliceMeta' information retrieved from the 'EnhancedSplitter'

func (*WrapDagBuilder) Next

func (w *WrapDagBuilder) Next() ([]byte, error)

Rewrite the 'Next' function to make the helper retrieve data from the 'EnhancedSplitter' interface.

type WrapDagService

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

func (*WrapDagService) Add

func (wds *WrapDagService) Add(ctx context.Context, node ipld.Node) error

func (*WrapDagService) AddMany

func (wds *WrapDagService) AddMany(ctx context.Context, nodes []ipld.Node) error

func (*WrapDagService) Get

func (wds *WrapDagService) Get(ctx context.Context, c cid.Cid) (ipld.Node, error)

func (*WrapDagService) GetMany

func (wds *WrapDagService) GetMany(ctx context.Context, cids []cid.Cid) <-chan *ipld.NodeOption

func (*WrapDagService) Remove

func (wds *WrapDagService) Remove(ctx context.Context, c cid.Cid) error

func (*WrapDagService) RemoveMany

func (wds *WrapDagService) RemoveMany(ctx context.Context, cids []cid.Cid) error

type WrapWriter

type WrapWriter struct {
	io.Writer
	// contains filtered or unexported fields
}

Encapsulate io.Writer. When the Write method is executed, invoke a callback function to notify MappingService about the data that has been written.

func (*WrapWriter) Write

func (bc *WrapWriter) Write(p []byte) (int, error)

type WriteAfterAction

type WriteAfterAction func(path string, buf []byte, offset uint64)

The callback function for WrapWriter.

type WriteBeforeAction

type WriteBeforeAction func([]byte, io.Writer) ([]byte, error)

Jump to

Keyboard shortcuts

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