Computes an occupancy mask for this dictionary's values For each value in [`Self::values`] the corresponding bit will be set in the returned mask if it is referenced by a key in this [`DictionaryArray`]
(&self)
| 564 | /// For each value in [`Self::values`] the corresponding bit will be set in the |
| 565 | /// returned mask if it is referenced by a key in this [`DictionaryArray`] |
| 566 | pub fn occupancy(&self) -> BooleanBuffer { |
| 567 | let len = self.values.len(); |
| 568 | let mut builder = BooleanBufferBuilder::new(len); |
| 569 | builder.resize(len); |
| 570 | let slice = builder.as_slice_mut(); |
| 571 | match self.keys.nulls().filter(|n| n.null_count() > 0) { |
| 572 | Some(n) => { |
| 573 | let v = self.keys.values(); |
| 574 | n.valid_indices() |
| 575 | .for_each(|idx| set_bit(slice, v[idx].as_usize())) |
| 576 | } |
| 577 | None => { |
| 578 | let v = self.keys.values(); |
| 579 | v.iter().for_each(|v| set_bit(slice, v.as_usize())) |
| 580 | } |
| 581 | } |
| 582 | builder.finish() |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | /// Constructs a `DictionaryArray` from an `ArrayData` |