Skip to content

Commit 8ce93d2

Browse files
committed
bitmap_instead_of_hll_smaller_datatypes
1 parent e8fe907 commit 8ce93d2

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

datafusion/functions-aggregate/benches/approx_distinct.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,16 +222,16 @@ fn approx_distinct_benchmark(c: &mut Criterion) {
222222
})
223223
});
224224

225-
// Boolean
226-
let values = Arc::new(create_bool_array()) as ArrayRef;
227-
c.bench_function("approx_distinct bool bitmap", |b| {
228-
b.iter(|| {
229-
let mut accumulator = prepare_accumulator(DataType::Boolean);
230-
accumulator
231-
.update_batch(std::slice::from_ref(&values))
232-
.unwrap()
233-
})
234-
});
225+
// // Boolean - commented out for main comparison (not supported on main)
226+
// let values = Arc::new(create_bool_array()) as ArrayRef;
227+
// c.bench_function("approx_distinct bool bitmap", |b| {
228+
// b.iter(|| {
229+
// let mut accumulator = prepare_accumulator(DataType::Boolean);
230+
// accumulator
231+
// .update_batch(std::slice::from_ref(&values))
232+
// .unwrap()
233+
// })
234+
// });
235235
}
236236

237237
criterion_group!(benches, approx_distinct_benchmark);

datafusion/functions-aggregate/src/approx_distinct.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ impl Bitmap256Accumulator {
228228

229229
#[inline]
230230
fn set_bit(&mut self, value: u8) {
231-
let word = (value / 64) as usize;
232-
let bit = value % 64;
231+
let word = (value >> 6) as usize;
232+
let bit = value & 63;
233233
self.bitmap[word] |= 1u64 << bit;
234234
}
235235

@@ -303,8 +303,8 @@ impl Bitmap256AccumulatorI8 {
303303
fn set_bit(&mut self, value: i8) {
304304
// Convert i8 to u8 by reinterpreting bits
305305
let idx = value as u8;
306-
let word = (idx / 64) as usize;
307-
let bit = idx % 64;
306+
let word = (idx >> 6) as usize;
307+
let bit = idx & 63;
308308
self.bitmap[word] |= 1u64 << bit;
309309
}
310310

0 commit comments

Comments
 (0)