Skip to content

Commit c67cdc7

Browse files
committed
Override side impl for Hamming
Using provided implementation randomly selects a side if the margin_no_header is 0.
1 parent 870fa98 commit c67cdc7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/distance/hamming.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,19 @@ impl Distance for Hamming {
107107
p.as_bytes().iter().zip(q.as_bytes()).map(|(u, v)| (u & v).count_ones()).sum::<u32>();
108108
ret as f32
109109
}
110+
111+
fn side<R: Rng>(
112+
normal_plane: &UnalignedVector<Self::VectorCodec>,
113+
node: &Leaf<Self>,
114+
rng: &mut R,
115+
) -> Side {
116+
let dot = Self::margin_no_header(&node.vector, normal_plane);
117+
if dot > 0.0 {
118+
Side::Right
119+
} else {
120+
Side::Left
121+
}
122+
}
110123
}
111124

112125
#[inline]

0 commit comments

Comments
 (0)