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

Function build_field_index

arrow-json/src/reader/struct_array.rs:277–292  ·  view source on GitHub ↗
(fields: &Fields)

Source from the content-addressed store, hash-verified

275}
276
277fn build_field_index(fields: &Fields) -> Option<HashMap<String, usize>> {
278 // Heuristic threshold: for small field counts, linear scan avoids HashMap overhead.
279 const FIELD_INDEX_LINEAR_THRESHOLD: usize = 16;
280 if fields.len() < FIELD_INDEX_LINEAR_THRESHOLD {
281 return None;
282 }
283
284 let mut map = HashMap::with_capacity(fields.len());
285 for (idx, field) in fields.iter().enumerate() {
286 let name = field.name();
287 if !map.contains_key(name) {
288 map.insert(name.to_string(), idx);
289 }
290 }
291 Some(map)
292}

Callers 1

newMethod · 0.85

Calls 4

lenMethod · 0.45
iterMethod · 0.45
nameMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected