From 09296e4986063bf71741917d2f2550dfe194e11a Mon Sep 17 00:00:00 2001 From: Marcel Martin Date: Tue, 27 Feb 2024 23:02:40 +0100 Subject: [PATCH] Make index creation deterministic By ensuring randstrobes are sorted by all their fields. --- src/randstrobes.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/randstrobes.hpp b/src/randstrobes.hpp index 933fc89f..7a79e8ad 100644 --- a/src/randstrobes.hpp +++ b/src/randstrobes.hpp @@ -34,8 +34,8 @@ struct RefRandstrobe { // RefRandstrobes in the index is reproducible no matter which sorting // function is used. This branchless comparison is faster than the // equivalent one using std::tie. - __uint128_t lhs = (static_cast<__uint128_t>(hash) << 64) | position; - __uint128_t rhs = (static_cast<__uint128_t>(other.hash) << 64) | other.position; + __uint128_t lhs = (static_cast<__uint128_t>(hash) << 64) | ((static_cast(position) << 32) | m_packed); + __uint128_t rhs = (static_cast<__uint128_t>(other.hash) << 64) | ((static_cast(other.position) << 32) | m_packed); return lhs < rhs; }