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

Method get_or_insert_key

arrow-array/src/builder/primitive_dictionary_builder.rs:283–295  ·  view source on GitHub ↗
(&mut self, value: V::Native)

Source from the content-addressed store, hash-verified

281{
282 #[inline]
283 fn get_or_insert_key(&mut self, value: V::Native) -> Result<K::Native, ArrowError> {
284 match self.map.get(&Value(value)) {
285 Some(&key) => {
286 Ok(K::Native::from_usize(key).ok_or(ArrowError::DictionaryKeyOverflowError)?)
287 }
288 None => {
289 let key = self.values_builder.len();
290 self.values_builder.append_value(value);
291 self.map.insert(Value(value), key);
292 Ok(K::Native::from_usize(key).ok_or(ArrowError::DictionaryKeyOverflowError)?)
293 }
294 }
295 }
296
297 /// Append a primitive value to the array. Return an existing index
298 /// if already present in the values array or a new index if the

Callers 3

appendMethod · 0.45
append_nMethod · 0.45
extend_dictionaryMethod · 0.45

Calls 5

ValueClass · 0.85
getMethod · 0.45
lenMethod · 0.45
append_valueMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected