lsh

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash64

func Hash64(s string) uint64

Hash64 computes a 64-bit FNV-1a hash for a string.

func MinInt

func MinInt(a, b int) int

MinInt returns the smaller of two ints.

Types

type HashFunc

type HashFunc func(uint64) uint64

HashFunc maps a 64-bit base hash to another 64-bit value.

type LSHIndex

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

LSHIndex implements MinHash LSH with banding.

func NewLSHIndex

func NewLSHIndex(bands, rows int) *LSHIndex

NewLSHIndex creates an index with banding parameters.

func (*LSHIndex) AddFragment

func (idx *LSHIndex) AddFragment(id string, signature *MinHashSignature) error

AddFragment inserts a fragment signature into the index.

func (*LSHIndex) Bands

func (idx *LSHIndex) Bands() int

Bands returns the number of bands.

func (*LSHIndex) BuildIndex

func (idx *LSHIndex) BuildIndex() error

BuildIndex is a no-op for incremental building (kept for API symmetry).

func (*LSHIndex) FindCandidates

func (idx *LSHIndex) FindCandidates(signature *MinHashSignature) []string

FindCandidates retrieves candidate fragment IDs that share at least one band bucket.

func (*LSHIndex) GetSignature

func (idx *LSHIndex) GetSignature(id string) *MinHashSignature

GetSignature returns the stored signature for a fragment ID.

func (*LSHIndex) Rows

func (idx *LSHIndex) Rows() int

Rows returns the number of rows per band.

func (*LSHIndex) Size

func (idx *LSHIndex) Size() int

Size returns the number of fragments in the index.

type MinHashSignature

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

MinHashSignature holds the signature vector.

func (*MinHashSignature) NumHashes

func (s *MinHashSignature) NumHashes() int

NumHashes returns the number of hash functions used.

func (*MinHashSignature) Signatures

func (s *MinHashSignature) Signatures() []uint64

Signatures returns the signature slice.

type MinHasher

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

MinHasher computes MinHash signatures for feature sets.

func NewMinHasher

func NewMinHasher(numHashes int) *MinHasher

NewMinHasher creates a MinHasher with numHashes functions (default 128 if invalid).

func (*MinHasher) ComputeSignature

func (m *MinHasher) ComputeSignature(features []string) *MinHashSignature

ComputeSignature computes the MinHash signature for a set of features.

func (*MinHasher) EstimateJaccardSimilarity

func (m *MinHasher) EstimateJaccardSimilarity(sig1, sig2 *MinHashSignature) float64

EstimateJaccardSimilarity estimates Jaccard similarity via signature agreement ratio.

func (*MinHasher) NumHashes

func (m *MinHasher) NumHashes() int

NumHashes returns the number of hash functions.

Jump to

Keyboard shortcuts

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