coderfender commented on code in PR #21456:
URL: https://github.com/apache/datafusion/pull/21456#discussion_r3061010490
##########
datafusion/functions-aggregate-common/src/aggregate/count_distinct/native.rs:
##########
@@ -165,3 +165,354 @@ impl<T: ArrowPrimitiveType + Debug> Accumulator for
FloatDistinctCountAccumulato
size_of_val(self) + self.values.size()
}
}
+
+/// Optimized COUNT DISTINCT accumulator for u8 using a bool array.
+/// Uses 256 bytes to track all possible u8 values.
+#[derive(Debug)]
+pub struct BoolArray256DistinctCountAccumulator {
+ seen: Box<[bool; 256]>,
Review Comment:
Results using `MutableBuffer` :
```
group bitmap_count_distinct
bitmap_count_distinct_mutable_buffer main
----- ---------------------
------------------------------------ ---- 6.2±0.22µs ?
?/sec
count_distinct i16 bitmap 1.03 3.1±0.14µs ?
?/sec 1.00 3.0±0.02µs ? ?/sec 26.16 77.9±3.43µs ?
?/sec
count_distinct i64 80% distinct 1.03 48.2±0.44µs ?
?/sec 1.00 47.0±0.40µs ? ?/sec 1.02 48.0±1.49µs ?
?/sec
count_distinct i64 99% distinct 1.02 48.3±0.46µs ?
?/sec 1.00 47.2±0.92µs ? ?/sec 1.02 48.3±2.14µs ?
?/sec
count_distinct i8 bitmap 1.00 2.9±0.43µs ?
?/sec 1.37 3.9±0.06µs ? ?/sec 5.75 16.4±0.26µs ?
?/sec
count_distinct u16 bitmap 1.06 3.2±0.30µs ?
?/sec 1.00 3.0±0.16µs ? ?/sec 25.58 77.7±1.82µs ?
?/sec
count_distinct u8 bitmap 1.00 2.1±0.03µs ?
?/sec 1.90 3.9±0.08µs ? ?/sec 8.14
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]