DKER2 opened a new pull request, #11232:
URL: https://github.com/apache/arrow-rs/pull/11232

   # Which issue does this PR close?
   
   - Closes #9493.
   
   # Rationale for this change
   
   `parse_in_bracket` currently allocates a `String` for every bracket 
expression, including indexes, wildcards, and quoted fields that require no 
unescaping. `VariantPathElement::Field` already stores `Cow<str>`, so unescaped 
field names can borrow directly from the input path.
   
   # What changes are included in this PR?
   
   - Defer creation of the unescaped `String` until the first backslash is 
encountered.
   - Borrow the original bracket-content slice when no escape processing is 
required.
   - Preserve ownership for escaped fields and strip their surrounding quotes 
in place.
   - Add tests proving unescaped bracket fields use `Cow::Borrowed` while 
escaped fields use `Cow::Owned`.
   
   This PR is independent of #11231, but both touch `parse_in_bracket`. I will 
rebase the remaining branch after either PR lands.
   
   # Are these changes tested?
   
   Yes. The following checks pass:
   
   - `cargo test -p parquet-variant`
   - `cargo clippy -p parquet-variant --all-targets --all-features -- -D 
warnings`
   - `cargo +stable fmt --all -- --check`
   - `git diff --check`
   
   A temporary Criterion harness measured the parser before and after this 
change on aarch64 macOS:
   
   | Case | Before | After | Change |
   |---|---:|---:|---:|
   | Three quoted bracket fields | 300.22 ns | 54.10 ns | -81.7% |
   | Three bracket indexes | 146.13 ns | 45.57 ns | -68.2% |
   | Escaped bracket field | 140.41 ns | 111.37 ns | -24.9% |
   | Dot-path control | 38.68 ns | 40.88 ns | Within noise |
   
   # Are there any user-facing changes?
   
   No semantic or public API changes. Parsed paths remain the same; unescaped 
bracket fields now borrow their names instead of allocating owned strings.
   
   # AI usage
   
   OpenAI Codex was used to inspect the parser, help implement the lazy 
allocation path, construct ownership tests, and run validation and benchmarks. 
I reviewed the resulting code and behavior and can own and debug the change.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to