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

Method new_from_builders

arrow-array/src/builder/primitive_dictionary_builder.rs:143–160  ·  view source on GitHub ↗

Creates a new `PrimitiveDictionaryBuilder` from existing `PrimitiveBuilder`s of keys and values. # Safety caller must ensure that the passed in builders are valid for DictionaryArray.

(
        keys_builder: PrimitiveBuilder<K>,
        values_builder: PrimitiveBuilder<V>,
    )

Source from the content-addressed store, hash-verified

141 ///
142 /// caller must ensure that the passed in builders are valid for DictionaryArray.
143 pub unsafe fn new_from_builders(
144 keys_builder: PrimitiveBuilder<K>,
145 values_builder: PrimitiveBuilder<V>,
146 ) -> Self {
147 let keys = keys_builder.values_slice();
148 let values = values_builder.values_slice();
149 let mut map = HashMap::with_capacity(values.len());
150
151 keys.iter().zip(values.iter()).for_each(|(key, value)| {
152 map.insert(Value(*value), K::Native::to_usize(*key).unwrap());
153 });
154
155 Self {
156 keys_builder,
157 values_builder,
158 map,
159 }
160 }
161
162 /// Creates a new `PrimitiveDictionaryBuilder` with the provided capacities
163 ///

Callers

nothing calls this directly

Calls 6

ValueClass · 0.85
zipMethod · 0.80
values_sliceMethod · 0.45
lenMethod · 0.45
iterMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected