blocks

package
v0.0.0-...-e85cb22 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: Apache-2.0 Imports: 18 Imported by: 3

Documentation

Index

Constants

View Source
const DefaultBlockSize = 1024 * 1024
View Source
const HashSize = sha512.Size

Variables

Functions

This section is empty.

Types

type Block

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

func CreateBlock

func CreateBlock(data []byte) *Block

func (*Block) AsSlice

func (block *Block) AsSlice() []byte

func (*Block) Hash

func (block *Block) Hash() *BlockHash

func (*Block) Size

func (block *Block) Size() uint64

func (*Block) Update

func (block *Block) Update(data []byte)

type BlockHash

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

func HashBlock

func HashBlock(data []byte) *BlockHash

func HashFromSlice

func HashFromSlice(hash []byte) (*BlockHash, error)

func (*BlockHash) AsSlice

func (block *BlockHash) AsSlice() []byte

func (*BlockHash) Equal

func (block *BlockHash) Equal(other *BlockHash) bool

func (*BlockHash) String

func (b *BlockHash) String() string

type BlockPipeline

type BlockPipeline struct {
	context.Context
	sync.WaitGroup
	ChunkSize uint64
	Blocks    chan *FileBlockData
}

func NewBlockPipeline

func NewBlockPipeline(ctx context.Context, chunkSize uint64, bufferSize int) *BlockPipeline

func (*BlockPipeline) FromDirectory

func (b *BlockPipeline) FromDirectory(root string) *BlockPipeline

func (*BlockPipeline) FromSlice

func (b *BlockPipeline) FromSlice(blocks []FileBlockData) *BlockPipeline

func (*BlockPipeline) FromZip

func (b *BlockPipeline) FromZip(r *zip.Reader) *BlockPipeline

func (*BlockPipeline) Run

func (*BlockPipeline) RunBatch

func (b *BlockPipeline) RunBatch(p []BlockProcessor) error

type BlockProcessor

type BlockProcessor func(b *FileBlockData) (*FileBlockData, error)

func DedupBlockProcessor

func DedupBlockProcessor() BlockProcessor

func HTTPFetchBlockProcessor

func HTTPFetchBlockProcessor(prefix string) BlockProcessor

func HashBlockProcessor

func HashBlockProcessor() BlockProcessor

func PrintBlockProcessor

func PrintBlockProcessor() BlockProcessor

func ValidateBlockProcessor

func ValidateBlockProcessor() BlockProcessor

func ZlibCompressBlockProcessor

func ZlibCompressBlockProcessor(level int) BlockProcessor

func ZlibDecompressBlockProcessor

func ZlibDecompressBlockProcessor() BlockProcessor

type FileBlockData

type FileBlockData struct {
	File    string
	Offset  uint64
	BlockId uint64
	Size    uint64
	Hash    *BlockHash
	Data    *Block
}

func (*FileBlockData) ComputeHash

func (block *FileBlockData) ComputeHash() (*BlockHash, error)

func (*FileBlockData) SetBlock

func (block *FileBlockData) SetBlock(data []byte)

func (*FileBlockData) String

func (b *FileBlockData) String() string

func (*FileBlockData) UpdateHash

func (block *FileBlockData) UpdateHash() (*BlockHash, error)

Jump to

Keyboard shortcuts

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