From abbbb20b560ad07df7afcf74386e2070b6666a6c Mon Sep 17 00:00:00 2001 From: Valdemar Erk Date: Mon, 25 Oct 2021 13:18:24 +0200 Subject: [PATCH 1/2] fix: Endianness was incorrectly assumed for GroupWord --- src/swisstable_group_query/no_simd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/swisstable_group_query/no_simd.rs b/src/swisstable_group_query/no_simd.rs index fb074e4..8ce9fe7 100644 --- a/src/swisstable_group_query/no_simd.rs +++ b/src/swisstable_group_query/no_simd.rs @@ -29,7 +29,7 @@ impl GroupQuery { // has pretty much the same effect as a hash collision, something // that we need to deal with in any case anyway. - let group = GroupWord::from_le_bytes(*group); + let group = GroupWord::from_ne_bytes(*group); let cmp = group ^ repeat(h2); let high_bit_greater_than_128 = (!cmp) & repeat(0x80); let high_bit_greater_than_128_or_zero = cmp.wrapping_sub(repeat(0x01)); From 05b5cd03baf9999efa0528fff2279c635f005bdf Mon Sep 17 00:00:00 2001 From: Valdemar Erk Date: Thu, 28 Oct 2021 10:54:17 +0200 Subject: [PATCH 2/2] Use the solution suggested by cuviper --- src/swisstable_group_query/no_simd.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/swisstable_group_query/no_simd.rs b/src/swisstable_group_query/no_simd.rs index 8ce9fe7..81898fe 100644 --- a/src/swisstable_group_query/no_simd.rs +++ b/src/swisstable_group_query/no_simd.rs @@ -29,13 +29,13 @@ impl GroupQuery { // has pretty much the same effect as a hash collision, something // that we need to deal with in any case anyway. - let group = GroupWord::from_ne_bytes(*group); + let group = GroupWord::from_le_bytes(*group); let cmp = group ^ repeat(h2); let high_bit_greater_than_128 = (!cmp) & repeat(0x80); let high_bit_greater_than_128_or_zero = cmp.wrapping_sub(repeat(0x01)); - let eq_mask = (high_bit_greater_than_128_or_zero & high_bit_greater_than_128).to_le(); + let eq_mask = high_bit_greater_than_128_or_zero & high_bit_greater_than_128; - let empty_mask = (group & repeat(0x80)).to_le(); + let empty_mask = group & repeat(0x80); GroupQuery { eq_mask,