index

package
v0.0.0-...-8931874 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2016 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package index provides the functionality to describe a reference 'file' and its contents in terms of the weak and strong checksums, in such a way that you can check if a weak checksum is present, then check if there is a strong checksum that matches.

It also allows lookups in terms of block offsets, so that upon finding a match, you can more efficiently check if the next block follows it.

The index structure does not lend itself to being an interface - the pattern of taking the result of looking for the weak checksum and looking up the strong checksum in that requires us to return an object matching an interface which both packages must know about.

Here's the interface:

type Index interface {
	FindWeakChecksum(chk []byte) interface{}
	FindStrongChecksum(chk []byte, weak interface{}) []chunks.ChunkChecksum
}

This allows the implementation to rely on a previously generated value, without the users knowing what it is. This breaks the dependency that requires so many packages to import index.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChecksumIndex

type ChecksumIndex struct {
	BlockCount int

	MaxStrongLength     int
	AverageStrongLength float32
	Count               int
	// contains filtered or unexported fields
}

func MakeChecksumIndex

func MakeChecksumIndex(checksums []chunks.ChunkChecksum) *ChecksumIndex

Builds an index in which chunks can be found, with their corresponding offsets We use this for the

func (*ChecksumIndex) FindStrongChecksum2

func (index *ChecksumIndex) FindStrongChecksum2(chk []byte, weak interface{}) []chunks.ChunkChecksum

func (*ChecksumIndex) FindWeakChecksum2

func (index *ChecksumIndex) FindWeakChecksum2(chk []byte) interface{}

func (*ChecksumIndex) FindWeakChecksumInIndex

func (index *ChecksumIndex) FindWeakChecksumInIndex(weak []byte) StrongChecksumList

func (*ChecksumIndex) WeakCount

func (index *ChecksumIndex) WeakCount() int

type StrongChecksumList

type StrongChecksumList []chunks.ChunkChecksum

func (StrongChecksumList) FindStrongChecksum

func (s StrongChecksumList) FindStrongChecksum(strong []byte) (result []chunks.ChunkChecksum)

func (StrongChecksumList) Len

func (s StrongChecksumList) Len() int

Sortable interface

func (StrongChecksumList) Less

func (s StrongChecksumList) Less(i, j int) bool

Sortable interface

func (StrongChecksumList) Swap

func (s StrongChecksumList) Swap(i, j int)

Sortable interface

Jump to

Keyboard shortcuts

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