|
4 | 4 | use std::fmt::Debug; |
5 | 5 | use std::hash::Hash; |
6 | 6 |
|
7 | | -<<<<<<< HEAD:vortex-array/src/arrays/dict/array.rs |
8 | 7 | use vortex_buffer::BitBuffer; |
9 | | -======= |
10 | | -use vortex_array::stats::{ArrayStats, StatsSetRef}; |
11 | | -use vortex_array::vtable::{ArrayVTable, NotSupported, VTable, ValidityVTable}; |
12 | | -use vortex_array::{ |
13 | | - Array, ArrayEq, ArrayHash, ArrayRef, EncodingId, EncodingRef, Precision, ToCanonical, vtable, |
14 | | -}; |
15 | | -use vortex_buffer::{BitBuffer, BitBufferMut}; |
16 | | ->>>>>>> 541544af8 (perf[dict]: unreferenced mask Vec<bool>):encodings/dict/src/array.rs |
17 | 8 | use vortex_dtype::{DType, match_each_integer_ptype}; |
18 | 9 | use vortex_error::{VortexExpect as _, VortexResult, vortex_bail}; |
19 | 10 | use vortex_mask::{AllOr, Mask}; |
@@ -128,23 +119,24 @@ impl DictArray { |
128 | 119 | let values_len = self.values().len(); |
129 | 120 |
|
130 | 121 | let mut unreferenced_vec = vec![true; values_len]; |
131 | | - if codes_validity.all_true() { |
132 | | - match_each_integer_ptype!(codes_primitive.ptype(), |P| { |
133 | | - #[allow(clippy::cast_possible_truncation)] |
134 | | - for &code in codes_primitive.as_slice::<P>().iter() { |
135 | | - unreferenced_vec[code as usize] = false; |
136 | | - } |
137 | | - }); |
138 | | - } else { |
139 | | - match_each_integer_ptype!(codes_primitive.ptype(), |P| { |
140 | | - let codes = codes_primitive.as_slice::<P>(); |
141 | | - codes_validity |
142 | | - .to_bit_buffer() |
143 | | - .set_indices() |
144 | | - .for_each(|idx| { |
| 122 | + match codes_validity.bit_buffer() { |
| 123 | + AllOr::All => { |
| 124 | + match_each_integer_ptype!(codes_primitive.ptype(), |P| { |
| 125 | + #[allow(clippy::cast_possible_truncation)] |
| 126 | + for &code in codes_primitive.as_slice::<P>().iter() { |
| 127 | + unreferenced_vec[code as usize] = false; |
| 128 | + } |
| 129 | + }); |
| 130 | + } |
| 131 | + AllOr::None => {} |
| 132 | + AllOr::Some(buf) => { |
| 133 | + match_each_integer_ptype!(codes_primitive.ptype(), |P| { |
| 134 | + let codes = codes_primitive.as_slice::<P>(); |
| 135 | + buf.set_indices().for_each(|idx| { |
145 | 136 | unreferenced_vec[codes[idx] as usize] = false; |
146 | | - }); |
147 | | - }) |
| 137 | + }) |
| 138 | + }); |
| 139 | + } |
148 | 140 | } |
149 | 141 |
|
150 | 142 | Ok(BitBuffer::collect_bool(values_len, |idx| { |
|
0 commit comments