@@ -49,7 +49,8 @@ static inline syncmer_hash_t syncmer_smer_hash(uint64_t packed) {
49
49
* This function combines two individual syncmer hashes into a single hash
50
50
* for the randstrobe.
51
51
*
52
- * One syncmer is designated as the "main", the other is the "auxiliary".
52
+ * The syncmer with the smaller hash is designated as the "main", the other is
53
+ * the "auxiliary".
53
54
* The combined hash is obtained by setting the top bits to the bits of
54
55
* the main hash and the bottom bits to the bits of the auxiliary
55
56
* hash. Since entries in the index are sorted by randstrobe hash, this allows
@@ -58,6 +59,10 @@ static inline syncmer_hash_t syncmer_smer_hash(uint64_t packed) {
58
59
static inline randstrobe_hash_t randstrobe_hash (
59
60
syncmer_hash_t hash1, syncmer_hash_t hash2, randstrobe_hash_t main_hash_mask
60
61
) {
62
+ // Make the function symmetric
63
+ if (hash1 > hash2) {
64
+ std::swap (hash1, hash2);
65
+ }
61
66
return ((hash1 & main_hash_mask) | (hash2 & ~main_hash_mask)) & RANDSTROBE_HASH_MASK;
62
67
}
63
68
@@ -156,11 +161,12 @@ std::ostream& operator<<(std::ostream& os, const QueryRandstrobe& randstrobe) {
156
161
}
157
162
158
163
Randstrobe make_randstrobe (Syncmer strobe1, Syncmer strobe2, randstrobe_hash_t main_hash_mask) {
164
+ bool first_strobe_is_main = strobe1.hash < strobe2.hash ;
159
165
return Randstrobe{
160
166
randstrobe_hash (strobe1.hash , strobe2.hash , main_hash_mask),
161
167
static_cast <uint32_t >(strobe1.position ),
162
168
static_cast <uint32_t >(strobe2.position ),
163
- true
169
+ first_strobe_is_main
164
170
};
165
171
}
166
172
0 commit comments