kosiew commented on code in PR #23299:
URL: https://github.com/apache/datafusion/pull/23299#discussion_r3519762834


##########
datafusion/physical-expr/src/expressions/in_list/primitive_filter.rs:
##########
@@ -78,23 +78,57 @@ impl BitmapStorage for Box<[u64; 1024]> {
 /// Arrow primitive types supported by [`BitmapFilter`].
 ///
 /// Arrow already defines the Rust value type as `T::Native`. This trait only
-/// supplies the bitmap storage size for the two integer domains that are small
-/// enough to represent with one bit per possible value.
+/// supplies the bitmap storage size and maps values to their bit-pattern index
+/// for the two integer domains that are small enough to represent with one bit
+/// per possible value.
 pub(super) trait BitmapFilterType:
     ArrowPrimitiveType + Send + Sync + 'static
 {
     type Storage: BitmapStorage;
+
+    fn index(value: Self::Native) -> usize;
+}
+
+/// `Int8` has 256 possible bit patterns, so four `u64` words cover the full 
domain.
+impl BitmapFilterType for Int8Type {
+    type Storage = [u64; 4];
+
+    #[inline(always)]
+    fn index(value: Self::Native) -> usize {
+        value as u8 as usize
+    }
 }
 
 /// `UInt8` has 256 possible values, so four `u64` words cover the full domain.
 impl BitmapFilterType for UInt8Type {
     type Storage = [u64; 4];
+
+    #[inline(always)]
+    fn index(value: Self::Native) -> usize {
+        value as usize
+    }
+}
+
+/// `Int16` has 65,536 possible bit patterns, so 1,024 `u64` words cover the 
full
+/// domain.
+impl BitmapFilterType for Int16Type {
+    type Storage = Box<[u64; 1024]>;
+
+    #[inline(always)]
+    fn index(value: Self::Native) -> usize {
+        value as u16 as usize

Review Comment:
   I think this is good as an comment within the code



-- 
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]

Reply via email to