@@ -133,18 +133,9 @@ pub trait JoinHashMapType: Send + Sync {
133133 match_indices : & mut Vec < u64 > ,
134134 ) -> Option < MapOffset > ;
135135
136- /// Detects whether any hash bucket holds build rows with differing join
137- /// keys — i.e. real hash collisions.
138- ///
139- /// Returns `false` only when every chain is "pure": all rows sharing a
140- /// bucket also share the same join key. In that case the probe side can
141- /// check the key once per chain head and emit the rest of the chain
142- /// without re-checking each duplicate (see `lookup_join_hashmap`). When
143- /// `true`, callers must fall back to a per-pair recheck.
144- ///
145- /// `left_values` are the build-side join key columns. The default is the
146- /// conservative `true` (always recheck); the concrete chained maps
147- /// override it with an O(build_rows) scan.
136+ /// Returns `true` if any bucket holds build rows with differing join keys
137+ /// (real hash collisions). When `false`, the probe can check once per
138+ /// chain head and accept the whole run. Scanned once at build time.
148139 fn has_key_collisions (
149140 & self ,
150141 left_values : & [ ArrayRef ] ,
@@ -530,15 +521,14 @@ pub fn contain_hashes<T>(map: &HashTable<(u64, T)>, hash_values: &[u64]) -> Bool
530521 BooleanArray :: new ( buffer, None )
531522}
532523
533- /// Scans the collision chain to detect whether any bucket holds rows with
534- /// differing join keys (real hash collisions).
524+ /// Scans the `next` chain to detect real hash collisions (two build rows in
525+ /// the same bucket with different keys). `next[i]` stores `prev_row + 1`
526+ /// (`0` = end of chain). Checking every adjacent linked pair is sufficient:
527+ /// any two distinct keys in the same bucket must appear as neighbors somewhere.
535528///
536- /// Each entry of `next` links a build row to the previous row inserted into
537- /// the same bucket (`next[i]` stores `prev_row + 1`, `0` marks the end of a
538- /// chain). Two rows joined by a link share a hash, so comparing the keys
539- /// across every link covers every chain: if all linked pairs are equal, no
540- /// bucket mixes keys and the map is collision-free. Returns `true` on the
541- /// first differing link. O(build_rows) comparisons, run once at build time.
529+ /// Example — keys `["cat", "cat", "dog"]`, next `[0, 1, 2]`:
530+ /// row 1 → prev 0: "cat"=="cat" ✓
531+ /// row 2 → prev 1: "dog"!="cat" → return true (collision found)
542532fn detect_key_collisions < T > (
543533 next : & [ T ] ,
544534 left_values : & [ ArrayRef ] ,
0 commit comments