#[repr(C)]pub struct MinHashSig<const H: usize> {
pub schema: u16,
pub _pad: [u8; 6],
pub hashes: [u64; H],
}minhash only.Expand description
MinHash signature with H hash slots.
Represented as a fixed-size, repr(C), bytemuck::Pod struct so callers
can memory-map, persist, or zero-copy serialize collections of
signatures.
§Layout
offset 0..2 : u16 schema version (= [`SCHEMA_VERSION`])
offset 2..8 : 6 bytes padding (zeroed)
offset 8.. : H * u64 hash slots, little-endianTotal size: 8 + 8 * H bytes. 8-byte aligned.
§Stability
The byte layout above is semver-frozen as of v0.1.0.
Fields§
§schema: u16Schema version. Must equal SCHEMA_VERSION.
_pad: [u8; 6]Padding to align hashes on an 8-byte boundary. Must be zero.
hashes: [u64; H]The H min-hash slots.
Implementations§
Source§impl<const H: usize> MinHashSig<H>
impl<const H: usize> MinHashSig<H>
Sourcepub const fn empty() -> Self
pub const fn empty() -> Self
Construct an “all-maxima” signature.
Every slot is initialized to u64::MAX so a sketcher can collapse
each slot toward the running minimum as tokens flow in. This is
the documented initial state for both
MinHashFingerprinter and
MinHashStreaming.
§Returns
MinHashSig<H> with schema = SCHEMA_VERSION, padding zeroed,
and hashes = [u64::MAX; H].
§Example
use txtfp::MinHashSig;
let s: MinHashSig<128> = MinHashSig::empty();
assert_eq!(s.schema, 1);
assert!(s.hashes.iter().all(|h| *h == u64::MAX));Sourcepub const fn slot_count(&self) -> usize
pub const fn slot_count(&self) -> usize
Number of hash slots — equals the const generic H.
§Example
use txtfp::MinHashSig;
assert_eq!(MinHashSig::<128>::empty().slot_count(), 128);
assert_eq!(MinHashSig::<64>::empty().slot_count(), 64);Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
View the signature as a byte slice. Zero-copy.
Useful for hashing the signature itself (e.g. to build a content- addressed cache key) or for serializing to disk. The returned bytes match the on-disk layout documented at the type level.
§Returns
A &[u8] of length 8 + 8 * H. Bytes are little-endian.
§Example
use txtfp::MinHashSig;
let s: MinHashSig<8> = MinHashSig::empty();
let bytes = s.as_bytes();
assert_eq!(bytes.len(), 8 + 8 * 8);
// Zero-copy round-trip via bytemuck.
let s2: MinHashSig<8> = *bytemuck::from_bytes(bytes);
assert_eq!(s, s2);Trait Implementations§
Source§impl<const H: usize> Clone for MinHashSig<H>
impl<const H: usize> Clone for MinHashSig<H>
Source§fn clone(&self) -> MinHashSig<H>
fn clone(&self) -> MinHashSig<H>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<const H: usize> Debug for MinHashSig<H>
impl<const H: usize> Debug for MinHashSig<H>
Source§impl<'de, const H: usize> Deserialize<'de> for MinHashSig<H>
impl<'de, const H: usize> Deserialize<'de> for MinHashSig<H>
Source§fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
Source§impl<const H: usize> Hash for MinHashSig<H>
impl<const H: usize> Hash for MinHashSig<H>
Source§impl<const H: usize> PartialEq for MinHashSig<H>
impl<const H: usize> PartialEq for MinHashSig<H>
Source§impl<const H: usize> Serialize for MinHashSig<H>
impl<const H: usize> Serialize for MinHashSig<H>
Source§impl<const H: usize> Zeroable for MinHashSig<H>
impl<const H: usize> Zeroable for MinHashSig<H>
impl<const H: usize> Copy for MinHashSig<H>
impl<const H: usize> Eq for MinHashSig<H>
impl<const H: usize> Pod for MinHashSig<H>
impl<const H: usize> StructuralPartialEq for MinHashSig<H>
Auto Trait Implementations§
impl<const H: usize> Freeze for MinHashSig<H>
impl<const H: usize> RefUnwindSafe for MinHashSig<H>
impl<const H: usize> Send for MinHashSig<H>
impl<const H: usize> Sync for MinHashSig<H>
impl<const H: usize> Unpin for MinHashSig<H>
impl<const H: usize> UnsafeUnpin for MinHashSig<H>
impl<const H: usize> UnwindSafe for MinHashSig<H>
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.