cchash

package module
v0.0.0-...-cf74cc2 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2019 License: MIT Imports: 6 Imported by: 0

README

cchash

Package cchash provides a concurrent hasher for implementers of io.ReaderAt with a known size, such as os.File.

Documentation

Overview

Package cchash provides a concurrent hasher for implementers of io.ReaderAt with a known size, such as os.File.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashFactory

type HashFactory func() hash.Hash

HashFactory should return a new and usable hash.Hash upon each call.

type Interface

type Interface interface {
	// Hash computes the hash of the bytes read from the source io.ReaderAt.
	Hash() error

	// Sum appends the current hash to b and returns the resulting slice.
	// It does not change the underlying hash state.
	Sum(b []byte) []byte

	// Hash computes the hash of the bytes read from the source io.ReaderAt.
	Size() int
}

Interface represents a type that can concurrently compute a hash.

func New

func New(r io.ReaderAt, size int64, factory HashFactory, opts ...Option) Interface

New creates a new concurrent hasher that will hash the bytes read from the io.ReaderAt with the provided total size.

type Option

type Option func(c Interface)

Option configures a concurrent hasher.

func ChunkSize

func ChunkSize(s int64) Option

ChunkSize configures the size of the logical chunks that the input will be split into. A goroutine will be spawned for each chunk so TotalSize / ChunkSize is equivalent to the maximum concurrency.

Jump to

Keyboard shortcuts

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