Documentation
¶
Index ¶
- func Hash64(s string) uint64
- func MinInt(a, b int) int
- type LSHIndex
- func (idx *LSHIndex) AddFragment(id string, signature *MinHashSignature) error
- func (idx *LSHIndex) Bands() int
- func (idx *LSHIndex) BuildIndex() error
- func (idx *LSHIndex) FindCandidates(signature *MinHashSignature) []string
- func (idx *LSHIndex) FindCandidatesLimit(signature *MinHashSignature, maxCandidates int) []string
- func (idx *LSHIndex) GetSignature(id string) *MinHashSignature
- func (idx *LSHIndex) Rows() int
- func (idx *LSHIndex) Size() int
- type MinHashSignature
- type MinHasher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LSHIndex ¶
type LSHIndex struct {
// contains filtered or unexported fields
}
LSHIndex implements MinHash LSH with banding.
func NewLSHIndex ¶
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) BuildIndex ¶
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) FindCandidatesLimit ¶ added in v0.2.2
func (idx *LSHIndex) FindCandidatesLimit(signature *MinHashSignature, maxCandidates int) []string
FindCandidatesLimit retrieves candidate fragment IDs that share at least one band bucket, stopping as soon as maxCandidates distinct IDs have been collected so dense buckets never materialize in full. maxCandidates <= 0 disables the cap. Traversal order is deterministic — band order, then bucket insertion order — so capped queries keep the earliest-encountered candidates rather than an arbitrary subset.
func (*LSHIndex) GetSignature ¶
func (idx *LSHIndex) GetSignature(id string) *MinHashSignature
GetSignature returns the stored signature for a fragment ID.
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.
The hash family is stored as coefficient pairs rather than closures: signing one fragment evaluates numHashes × |features| hashes, so an indirect call per evaluation is the difference between a few and a few dozen instructions.
func NewMinHasher ¶
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.