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

Method lookup_key

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

If `value` is present in `values` (aka the dictionary), returns the corresponding key (index into the `values` array). Otherwise returns `None`. Panics if `values` is not a [`StringArray`].

(&self, value: &str)

Source from the content-addressed store, hash-verified

363 ///
364 /// Panics if `values` is not a [`StringArray`].
365 pub fn lookup_key(&self, value: &str) -> Option<K::Native> {
366 let rd_buf: &StringArray = self.values.as_any().downcast_ref::<StringArray>().unwrap();
367
368 (0..rd_buf.len())
369 .position(|i| rd_buf.value(i) == value)
370 .and_then(K::Native::from_usize)
371 }
372
373 /// Returns a reference to the dictionary values array
374 pub fn values(&self) -> &ArrayRef {

Callers

nothing calls this directly

Calls 5

and_thenMethod · 0.80
positionMethod · 0.80
as_anyMethod · 0.45
lenMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected