Jefffrey commented on code in PR #23537:
URL: https://github.com/apache/datafusion/pull/23537#discussion_r3578123051
##########
datafusion/functions/src/core/getfield.rs:
##########
@@ -129,22 +129,24 @@ fn process_map_array(
let mut mutable =
MutableArrayData::with_capacities(vec![&original_data], true,
capacity);
+ let offsets = map_array.value_offsets();
+ // Scan the comparison result in place: slicing it per entry would allocate
+ // a new array for every row of the map.
+ let matches = keys.values();
+ let match_nulls = keys.nulls();
+
for entry in 0..map_array.len() {
- let start = map_array.value_offsets()[entry] as usize;
- let end = map_array.value_offsets()[entry + 1] as usize;
+ let start = offsets[entry] as usize;
+ let end = offsets[entry + 1] as usize;
- let maybe_matched = keys
- .slice(start, end - start)
- .iter()
- .enumerate()
- .find(|(_, t)| t.unwrap());
+ let matched = (start..end).find(|&i| {
+ matches.value(i) && match_nulls.is_none_or(|nulls|
nulls.is_valid(i))
Review Comment:
the previous logic always unwrapped, meaning it ignored any nulls; i assume
this is to do with how map array keys cannot be null. perhaps we can follow on
that assumption and ignore null check as before?
--
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]