MCPcopy Create free account
hub / github.com/apache/arrow-rs / test_from_bitwise_binary_op

Function test_from_bitwise_binary_op

arrow-buffer/src/buffer/boolean.rs:1065–1105  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1063
1064 #[test]
1065 fn test_from_bitwise_binary_op() {
1066 // pick random boolean inputs
1067 let input_bools_left = (0..1024)
1068 .map(|_| rand::random::<bool>())
1069 .collect::<Vec<bool>>();
1070 let input_bools_right = (0..1024)
1071 .map(|_| rand::random::<bool>())
1072 .collect::<Vec<bool>>();
1073 let input_buffer_left = BooleanBuffer::from(&input_bools_left[..]);
1074 let input_buffer_right = BooleanBuffer::from(&input_bools_right[..]);
1075
1076 #[cfg(miri)] // Takes too long otherwise
1077 let left_offsets = [0, 1, 7, 8, 63, 64, 65];
1078 #[cfg(not(miri))]
1079 let left_offsets = 0..200;
1080
1081 for left_offset in left_offsets {
1082 for right_offset in [0, 4, 5, 17, 33, 24, 45, 64, 65, 100, 200] {
1083 for len_offset in [0, 1, 44, 100, 256, 300, 512] {
1084 let len = 1024 - len_offset - left_offset.max(right_offset); // ensure we don't go out of bounds
1085 // compute with AND
1086 let result = BooleanBuffer::from_bitwise_binary_op(
1087 input_buffer_left.values(),
1088 left_offset,
1089 input_buffer_right.values(),
1090 right_offset,
1091 len,
1092 |a, b| a & b,
1093 );
1094 // compute directly from bools
1095 let expected = input_bools_left[left_offset..]
1096 .iter()
1097 .zip(&input_bools_right[right_offset..])
1098 .take(len)
1099 .map(|(a, b)| *a & *b)
1100 .collect::<BooleanBuffer>();
1101 assert_eq!(result, expected);
1102 }
1103 }
1104 }
1105 }
1106
1107 #[test]
1108 fn test_from_bitwise_binary_op_same_mod_64_unaligned_fallback() {

Callers

nothing calls this directly

Calls 5

maxMethod · 0.80
zipMethod · 0.80
valuesMethod · 0.45
takeMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected