jhorstmann commented on a change in pull request #8204: URL: https://github.com/apache/arrow/pull/8204#discussion_r490852595
########## File path: rust/arrow/src/compute/kernels/filter.rs ########## @@ -241,11 +241,21 @@ impl FilterContext { let filter_mask: Vec<u64> = (0..64).map(|x| 1u64 << x).collect(); let filter_bytes = filter_array.data_ref().buffers()[0].data(); let filtered_count = bit_util::count_set_bits(filter_bytes); + // transmute filter_bytes to &[u64] let mut u64_buffer = MutableBuffer::new(filter_bytes.len()); - u64_buffer - .write_bytes(filter_bytes, u64_buffer.capacity() - filter_bytes.len())?; - let filter_u64 = u64_buffer.typed_data_mut::<u64>().to_owned(); + // add to the resulting len so is is a multiple of the size of u64 + let pad_addional_len = 8 - filter_bytes.len() % 8; + u64_buffer.write_bytes(filter_bytes, pad_addional_len)?; + let mut filter_u64 = u64_buffer.typed_data_mut::<u64>().to_owned(); + + // mask of any bits outside of the given len + if filter_array.len() % 64 != 0 { + let last_idx = filter_u64.len() - 1; + let mask = u64::MAX >> (64 - filter_array.len() % 64); + filter_u64[last_idx] &= mask; Review comment: This fixes the issue I reported about accessing bits outside of len in https://issues.apache.org/jira/browse/ARROW-10025 ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org