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

Method occupancy

arrow-array/src/array/dictionary_array.rs:566–583  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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`

Callers 3

criterion_benchmarkFunction · 0.80
test_occupancyFunction · 0.80

Calls 12

set_bitFunction · 0.85
filterMethod · 0.80
valid_indicesMethod · 0.80
as_usizeMethod · 0.80
lenMethod · 0.45
resizeMethod · 0.45
as_slice_mutMethod · 0.45
nullsMethod · 0.45
null_countMethod · 0.45
valuesMethod · 0.45
iterMethod · 0.45
finishMethod · 0.45

Tested by 1

test_occupancyFunction · 0.64