mash

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package mash provides sequence MinHashing and Mash distance calculation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Distance added in v1.4.0

func Distance(n, k int, s1, s2 []byte) float64

Distance returns the Mash distance between two sequences, using n hashes and k-long subsequences.

func FromJaccard

func FromJaccard(jac float64, k int) float64

FromJaccard returns the Mash distance given a Jaccard similarity.

Types

type Masher

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

A Masher min-hashes sequences and calculates Mash distances.

func New

func New(n, k int) *Masher

New returns a new Masher with n hashes, k-long subsequences and seed 0.

func NewSeed

func NewSeed(n, k int, seed uint32) *Masher

NewSeed returns a new Masher with n hashes, k-long subsequences and the given seed.

func (*Masher) Add

func (m *Masher) Add(seq []byte) *Masher

Add adds the given sequence to the MinHash.

func (*Masher) AddSeq added in v1.4.0

func (m *Masher) AddSeq(seqs iter.Seq[[]byte]) *Masher

AddSeq adds the given sequences to the MinHash.

func (*Masher) Distance

func (m *Masher) Distance(other *Masher) float64

Distance returns the Mash distance between this Masher and another one.

Both Mashers need to have the same k's and seeds.

func (*Masher) MarshalJSON added in v1.4.0

func (m *Masher) MarshalJSON() ([]byte, error)

MarshalJSON implements the JSONMarshaler interface.

func (*Masher) UnmarshalJSON added in v1.4.0

func (m *Masher) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the JSONUnmarshaler interface.

Jump to

Keyboard shortcuts

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