Documentation
¶
Index ¶
- Constants
- Variables
- func BuildID() string
- func BuildTime() string
- func ChecksumCache(path string, size int64, modTime time.Time) (string, error)
- func ChecksumPath(s string) uint32
- func ChecksumReader(r io.Reader) (uint32, int, error)
- func CompareContent(a, b Token) int
- func ComparePaths(a, b Token) int
- type Cache
- type GuestfsLSCSV
- type Index
- type Indexer
- type JaccardSimilarity
- type Token
Constants ¶
const (
// BuildCommitChars is the number of characters to show in the build commit.
BuildCommitChars = 7
)
Variables ¶
var ErrChecksumSizeMismatch = errors.New("checksum size mismatch")
Functions ¶
func BuildID ¶
func BuildID() string
BuildID returns the build ID, typically a git commit but can be overriden via a linker flag. This is the short version, up to BuildCommitChars characters long.
func ChecksumPath ¶
func CompareContent ¶
CompareContent compares two tokens by their content hash.
func ComparePaths ¶
ComparePaths compares two tokens by their path hash.
Types ¶
type GuestfsLSCSV ¶
type GuestfsLSCSV struct {
// contains filtered or unexported fields
}
func NewGuestfsLSCSV ¶
func NewGuestfsLSCSV(r io.Reader) *GuestfsLSCSV
func (*GuestfsLSCSV) Index ¶
func (gr *GuestfsLSCSV) Index() *Index
func (*GuestfsLSCSV) ReadAll ¶
func (gr *GuestfsLSCSV) ReadAll() error
type Index ¶
type Index struct {
Tokens []Token
// contains filtered or unexported fields
}
type Indexer ¶
type Indexer struct {
// ErrFn is called when an error occurs during indexing. The first argument
// is the path of the file that caused the error, and the second argument
// is the error itself. The function can be called from multiple goroutines.
ErrFn func(string, error)
// contains filtered or unexported fields
}
func NewIndexer ¶
NewIndexer creates a new Indexer. The root argument is the root of the directory tree to be indexed.
type JaccardSimilarity ¶
type JaccardSimilarity struct {
// Similarity is the overall Jaccard similarity between two indices.
Similarity float64
// ContentSimilarity is the Jaccard similarity between two indices by file content.
ContentSimilarity float64
// PathSimilarity is the Jaccard similarity between two indices by file paths.
PathSimilarity float64
}
JaccardSimilarity holds the Jaccard similarity between two indices. It contains the overall similarity, content similarity, and path similarity.
func SimilarityJaccard ¶
func SimilarityJaccard(a, b *Index) JaccardSimilarity
Similarity computes the Jaccard similarity between two indices.
type Token ¶
func Intersect ¶
Intersect computes the intersection of two sets of tokens by cmp function. It returns a slice of tokens that are present in both sets. Both a and b arguments must be sorted and unique for the cmp function.
func SortByContent ¶
SortByContent sorts the tokens by their content hash. It returns a new slice of tokens with duplicates removed.
func SortByPaths ¶
SortByPaths sorts the tokens by their path hash. It returns a new slice of tokens with duplicates removed.