mbutrovich commented on code in PR #3739:
URL: https://github.com/apache/iceberg-rust/pull/3739#discussion_r4671727846


##########
crates/iceberg/src/arrow/reader/predicate_visitor.rs:
##########
@@ -278,6 +331,31 @@ fn project_column(
     }
 }
 
+fn probe_set(index: &SetIndex, column: &ArrayRef, negated: bool) -> 
Option<BooleanArray> {
+    Some(match (index, column.data_type()) {
+        (SetIndex::Int(keys), DataType::Int32) => {
+            BooleanArray::from_unary(column.as_primitive::<Int32Type>(), |x| {
+                keys.contains(&x) ^ negated
+            })
+        }
+        (SetIndex::Long(keys), DataType::Int64) => {
+            BooleanArray::from_unary(column.as_primitive::<Int64Type>(), |x| {
+                keys.contains(&x) ^ negated
+            })
+        }
+        (SetIndex::String(keys), DataType::Utf8) => {
+            BooleanArray::from_unary(column.as_string::<i32>(), |s| 
keys.contains(s) ^ negated)
+        }
+        (SetIndex::String(keys), DataType::LargeUtf8) => {

Review Comment:
   > We could be storing the minimum and the maximum length of each value to 
rule our keys before we even hash them.
   
   I'd leave this out. The probe already rejects most non-matching strings 
without comparing their bytes: hashbrown checks a 7-bit tag from the hash 
before it calls `eq` 
([`find_inner`](https://github.com/rust-lang/hashbrown/blob/8fa9464e0dacf09c485ba6e73eb66e4f6c06e874/src/raw.rs#L2015-L2041)),
 and `str` equality compares lengths before bytes 
([`SlicePartialEq::equal`](https://github.com/rust-lang/rust/blob/77e3cbafdd4034d5899ecb7fcf2d619bafb2d99c/library/core/src/slice/cmp.rs#L143-L146)).
 A length range would save only the hash, and only for rows whose length falls 
outside the literals' range. That's a branch on every probe for a gain that 
depends on the data, so I'd wait for a workload that shows it.



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