Trait WordType

Source
pub trait WordType<const BITS: usize>: Precision {
    type Words: Copy + Debug + IndexMut<usize, Output = u32> + Index<usize, Output = u32> + Send + Sync + Eq + PartialEq + ArrayIter<u32> + ArrayDefault<u32>;
    type RegisterMultiplicities: Index<usize, Output = Self::NumberOfZeros> + IndexMut<usize, Output = Self::NumberOfZeros> + Copy + Debug + Eq + ArrayIterArgmin<Self::NumberOfZeros> + ArrayIterArgmax<Self::NumberOfZeros> + ArrayDefault<Self::NumberOfZeros> + PrimitiveArray<f32, Array = Self::FloatMultiplicities> + ArrayIter<Self::NumberOfZeros>;
    type FloatMultiplicities: Index<usize, Output = f32>;
}

Required Associated Types§

Source

type Words: Copy + Debug + IndexMut<usize, Output = u32> + Index<usize, Output = u32> + Send + Sync + Eq + PartialEq + ArrayIter<u32> + ArrayDefault<u32>

The type to use for the associated vector of words. The type of Words is always an array of u32, as this is the smallest type that can be used to store the number of registers.

The length of the array is: ceil(P::NUMBER_OF_REGISTERS, 32 / BITS)

We cannot use the above expression directly, as it would force the library user to propagate some very ugly constraints around.

Source

type RegisterMultiplicities: Index<usize, Output = Self::NumberOfZeros> + IndexMut<usize, Output = Self::NumberOfZeros> + Copy + Debug + Eq + ArrayIterArgmin<Self::NumberOfZeros> + ArrayIterArgmax<Self::NumberOfZeros> + ArrayDefault<Self::NumberOfZeros> + PrimitiveArray<f32, Array = Self::FloatMultiplicities> + ArrayIter<Self::NumberOfZeros>

The register multiplicities is an array with the length of the largest possible value that can appear in a register. The value at index i is the number of registers that have a value equal to i, meaning the largest value that any register can have is the number of registers, i.e. 2^EXPONENT. This is the m parameter in the HyperLogLog. The lenth of the multiplicities array varies depending on the exponent and the number of bits, as the length of the array is equal to the maximal value that can be stored in a register. The value being stored in the register is the number of leading zeros in the hash of the value that is being inserted. When the register is of 1 bit, the maximal value is 1, and the length of the array is 2. When the register is of 2 bits, the maximal value is 3, and the length of the array is 4. When the register is of 3 bits, the maximal value is 7, and the length of the array is 8. When the register is of 4 bits, the maximal value is 15, and the length of the array is 16. When the register is of 5 bits, the maximal value is 31, and the length of the array is 32. Things start to get interesting for the cases of register at least 6 bits, as the maximal value representable in 6 bits is 63, but here we have to take into account the fact that the precision will be the limiting factor. In fact, the higher the precision, the larger the number of registers, and therefore more bits of the hash will be used to sample the register associated to a given value. For this reason, in those cases, the maximal value that we may encounter stored in the register is not 63, but 64 - (PRECISION - 1) + 1. So, when the register is of 6 bits, we need to consider the precision as follows: When the precision is 4, the maximal value is 61, and the length of the array is 62. When the precision is 5, the length of the array is 61. When the precision is 6, the length of the array is 60. The decrease in length continues linearly until the maximal precision for which we have experimental parameters, which is 18, where the length of the array is 48.

Source

type FloatMultiplicities: Index<usize, Output = f32>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl WordType<1> for Precision4

Source§

impl WordType<1> for Precision5

Source§

impl WordType<1> for Precision6

Source§

impl WordType<1> for Precision7

Source§

impl WordType<1> for Precision8

Source§

impl WordType<1> for Precision9

Source§

impl WordType<1> for Precision10

Source§

impl WordType<1> for Precision11

Source§

impl WordType<1> for Precision12

Source§

impl WordType<1> for Precision13

Source§

impl WordType<1> for Precision14

Source§

impl WordType<1> for Precision15

Source§

impl WordType<1> for Precision16

Source§

impl WordType<1> for Precision17

Source§

impl WordType<1> for Precision18

Source§

impl WordType<2> for Precision4

Source§

impl WordType<2> for Precision5

Source§

impl WordType<2> for Precision6

Source§

impl WordType<2> for Precision7

Source§

impl WordType<2> for Precision8

Source§

impl WordType<2> for Precision9

Source§

impl WordType<2> for Precision10

Source§

impl WordType<2> for Precision11

Source§

impl WordType<2> for Precision12

Source§

impl WordType<2> for Precision13

Source§

impl WordType<2> for Precision14

Source§

impl WordType<2> for Precision15

Source§

impl WordType<2> for Precision16

Source§

impl WordType<2> for Precision17

Source§

impl WordType<2> for Precision18

Source§

impl WordType<3> for Precision4

Source§

impl WordType<3> for Precision5

Source§

impl WordType<3> for Precision6

Source§

impl WordType<3> for Precision7

Source§

impl WordType<3> for Precision8

Source§

impl WordType<3> for Precision9

Source§

impl WordType<3> for Precision10

Source§

impl WordType<3> for Precision11

Source§

impl WordType<3> for Precision12

Source§

impl WordType<3> for Precision13

Source§

impl WordType<3> for Precision14

Source§

impl WordType<3> for Precision15

Source§

impl WordType<3> for Precision16

Source§

impl WordType<3> for Precision17

Source§

impl WordType<3> for Precision18

Source§

impl WordType<4> for Precision4

Source§

impl WordType<4> for Precision5

Source§

impl WordType<4> for Precision6

Source§

impl WordType<4> for Precision7

Source§

impl WordType<4> for Precision8

Source§

impl WordType<4> for Precision9

Source§

impl WordType<4> for Precision10

Source§

impl WordType<4> for Precision11

Source§

impl WordType<4> for Precision12

Source§

impl WordType<4> for Precision13

Source§

impl WordType<4> for Precision14

Source§

impl WordType<4> for Precision15

Source§

impl WordType<4> for Precision16

Source§

impl WordType<4> for Precision17

Source§

impl WordType<4> for Precision18

Source§

impl WordType<5> for Precision4

Source§

impl WordType<5> for Precision5

Source§

impl WordType<5> for Precision6

Source§

impl WordType<5> for Precision7

Source§

impl WordType<5> for Precision8

Source§

impl WordType<5> for Precision9

Source§

impl WordType<5> for Precision10

Source§

impl WordType<5> for Precision11

Source§

impl WordType<5> for Precision12

Source§

impl WordType<5> for Precision13

Source§

impl WordType<5> for Precision14

Source§

impl WordType<5> for Precision15

Source§

impl WordType<5> for Precision16

Source§

impl WordType<5> for Precision17

Source§

impl WordType<5> for Precision18

Source§

impl WordType<6> for Precision4

Source§

impl WordType<6> for Precision5

Source§

impl WordType<6> for Precision6

Source§

impl WordType<6> for Precision7

Source§

impl WordType<6> for Precision8

Source§

impl WordType<6> for Precision9

Source§

impl WordType<6> for Precision10

Source§

impl WordType<6> for Precision11

Source§

impl WordType<6> for Precision12

Source§

impl WordType<6> for Precision13

Source§

impl WordType<6> for Precision14

Source§

impl WordType<6> for Precision15

Source§

impl WordType<6> for Precision16

Source§

impl WordType<6> for Precision17

Source§

impl WordType<6> for Precision18

Source§

impl WordType<7> for Precision6

Source§

impl WordType<8> for Precision6