Skip to content

Commit

Permalink
Added several missing derives
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaCappelletti94 committed Aug 15, 2024
1 parent 91fb26d commit 26d93b4
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/h2b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::AHasherDefaultBuilder;
/// different numbers of sub streams.
///
/// Both the hasher and the sub stream size siaz can be customized, by default it uses `AHasherBuilder` and `M256`
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
pub struct HyperTwoBits<SKETCH: Sketch = M256, HASH: BuildHasher = AHasherDefaultBuilder> {
hash: HASH,
sketch: SKETCH,
Expand Down
7 changes: 4 additions & 3 deletions src/h2b/sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub trait Sketch: Default {
}

/// M = 64, using two 64 bit integers to store the sketch
#[derive(Default)]
#[derive(Debug, Eq, PartialEq, Hash, Clone, Default)]
pub struct M64 {
low: u64,
high: u64,
Expand Down Expand Up @@ -98,7 +98,7 @@ impl Sketch for M64 {
/// instructions for 128 bit integers.
///
/// The implementation is similar to M64
#[derive(Default)]
#[derive(Debug, Eq, PartialEq, Hash, Clone, Default)]
pub struct M128 {
low: u128,
high: u128,
Expand Down Expand Up @@ -159,7 +159,7 @@ impl Sketch for M128 {
/// We use a register to store hi and low bits together
/// to optimize for cache locallity when compiting inside
/// a vectored sketch
#[derive(Default, Clone, Copy, Debug)]
#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Hash)]
struct HiLoRegister {
high: u128,
low: u128,
Expand All @@ -169,6 +169,7 @@ struct HiLoRegister {
///
/// This is not meant to be used directly instead it serves as
/// a base for the other vectored sketches
#[derive(Debug, Eq, PartialEq, Hash, Copy, Clone)]
pub struct M128Reg<const REGISTERS: usize> {
registers: [HiLoRegister; REGISTERS],
}
Expand Down
1 change: 1 addition & 0 deletions src/h3b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::AHasherDefaultBuilder;
/// different numbers of sub streams.
///
/// Both the hasher and the sub stream size siaz can be customized, by default it uses `AHasherBuilder` and `M256`
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
pub struct HyperThreeBits<SKETCH: Sketch = M256, HASH: BuildHasher = AHasherDefaultBuilder> {
hash: HASH,
sketch: SKETCH,
Expand Down
7 changes: 4 additions & 3 deletions src/h3b/sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub trait Sketch: Default {
}

/// M = 64, using two 64 bit integers to store the sketch
#[derive(Default)]
#[derive(Debug, Eq, PartialEq, Hash, Copy, Clone, Default)]
pub struct M64 {
high: u64,
middle: u64,
Expand Down Expand Up @@ -121,7 +121,7 @@ impl Sketch for M64 {
/// instructions for 128 bit integers.
///
/// The implementation is similar to M64
#[derive(Default)]
#[derive(Debug, Eq, PartialEq, Hash, Copy, Clone, Default)]
pub struct M128 {
low: u128,
middle: u128,
Expand Down Expand Up @@ -192,7 +192,7 @@ impl Sketch for M128 {
/// We use a register to store hi and low bits together
/// to optimize for cache locallity when compiting inside
/// a vectored sketch
#[derive(Default, Clone, Copy, Debug)]
#[derive(Default, Clone, Copy, Debug, Hash, Eq, PartialEq)]
struct BitRegister {
high: u128,
middle: u128,
Expand All @@ -203,6 +203,7 @@ struct BitRegister {
///
/// This is not meant to be used directly instead it serves as
/// a base for the other vectored sketches
#[derive(Debug, Eq, PartialEq, Hash, Copy, Clone)]
pub struct M128Reg<const REGISTERS: usize> {
registers: [BitRegister; REGISTERS],
}
Expand Down
1 change: 1 addition & 0 deletions src/hbb64.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::hash::Hasher;

/// `HyperBitBit` cardinality counter with 64 substreams
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
pub struct HyperBitBit64<HASH: Hasher + Default = ahash::AHasher> {
_hash: std::marker::PhantomData<HASH>,
sketch1: u64,
Expand Down
3 changes: 3 additions & 0 deletions src/hyper_two_bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use sketch::Sketch;
use crate::M256;

/// Random Seeded `AHasher` Builder that allows for seeded hashing per `HyperTwoBit` isnstance
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
pub struct AHasherBuilder {
state: u64,
}
Expand Down Expand Up @@ -36,6 +37,7 @@ pub type AHasherDefaultBuilder = BuildHasherDefault<ahash::AHasher>;

/// Random Seeded `SipHasher13` Builder
#[cfg(feature = "siphash")]
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
pub struct SipHasher13Builder {
state: u64,
}
Expand Down Expand Up @@ -65,6 +67,7 @@ pub type SipHasher13DefaultBuilder = BuildHasherDefault<siphasher::sip::SipHashe
/// different numbers of sub streams.
///
/// Both the hasher and the sub stream size siaz can be customized, by default it uses `AHasherBuilder` and `M256`
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
pub struct HyperTwoBits<SKETCH: Sketch = M256, HASH: BuildHasher = AHasherDefaultBuilder> {
hash: HASH,
sketch: SKETCH,
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use std::hash::{BuildHasher, BuildHasherDefault, Hasher as _};
pub use prelude::*;

/// Random Seeded `AHasher` Builder that allows for seeded hashing per `HyperTwoBit` isnstance
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
pub struct AHasherBuilder {
state: u64,
}
Expand Down Expand Up @@ -57,6 +58,7 @@ pub type AHasherDefaultBuilder = BuildHasherDefault<ahash::AHasher>;

/// Random Seeded `SipHasher13` Builder
#[cfg(feature = "siphash")]
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
pub struct SipHasher13Builder {
state: u64,
}
Expand Down

0 comments on commit 26d93b4

Please sign in to comment.