Skip to main content

project

Function project 

Source
pub fn project(
    items: Vec<Value>,
    keys: &[String],
    command: Option<&str>,
) -> Vec<Value>
Expand description

Rewrites each object element to carry only keys, in the requested order.

Keys absent from an element are skipped rather than emitted as null, so a projection never invents fields. Non-object elements pass through unchanged. The dotted paths are split ONCE here rather than per element.

Splitting inside the per-element loop allocated a Vec<String>, plus a String per segment, for every element times every key — and discarded them immediately. graph entities --select name over the measured corpus of 107 135 entities did that 107 135 times to answer with one field. sort and dedupe in this same file already hoist the split out of their loops, so this is the file’s own established shape rather than a new idea.