LuciferYang opened a new pull request, #56759:
URL: https://github.com/apache/spark/pull/56759

   ### What changes were proposed in this pull request?
   
   `InMemoryStore` looked up children at two spots with 
`parentToChildrenMap.getOrDefault(parentKey, new NaturalKeys())`. Java 
evaluates the default argument eagerly, so a fresh empty `NaturalKeys` was 
allocated on every call, even when the key was present. Both spots only read 
the result (they iterate its keys), so this switches to `get(parentKey)` with a 
null guard: `removeAllByIndexValues` continues to the next value on a miss, and 
`InMemoryView.copyElements` returns an empty list. On a genuine miss the 
skipped `parentToChildrenMap.remove(parentKey)` was already a no-op.
   
   ### Why are the changes needed?
   
   It drops an allocation per call on the delete and child-view paths. The 
previous `getOrDefault` form built and discarded an empty map on every lookup, 
including hits.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Added two `InMemoryStoreSuite` tests for the natural-parent-index paths, 
which were not directly covered before: `testRemoveAllByNaturalParentIndex` 
(removing by a parent value, plus an absent parent that removes nothing) and 
`testViewByNaturalParentIndex` (a parent-filtered view returning its children 
in order, plus an absent parent yielding an empty iterator). The full kvstore 
suite passes, with the LevelDB suites skipped on Apple Silicon and run on CI, 
and checkstyle reports no violations.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   No
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to