arouel opened a new pull request, #3508:
URL: https://github.com/apache/parquet-java/pull/3508

   ### Rationale for this change
   
   `GeospatialStatistics.noopBuilder()` is called for every non-geometry column 
in every row group. Each call allocates a new `NoopBuilder` along with a 
`WKBReader`, `BoundingBox`, and `GeospatialTypes` that are never used. Each 
subsequent `build()` allocates a new `GeospatialStatistics(null, null)` that is 
equally throwaway. On wide schemas with many columns, this creates unnecessary 
GC pressure on the write path.
   
   ### What changes are included in this PR?
   
   - Make `NoopBuilder` a singleton via a static `INSTANCE` field returned by 
`noopBuilder()`
   - Cache the `build()` result as a static `EMPTY` instance, since it is 
stateless (null fields, with merge/abort guarded by null checks)
   - Add a package-private `Builder(boolean)` constructor that skips field 
initialization so the singleton does not allocate unused `WKBReader`, 
`BoundingBox`, and `GeospatialTypes` objects
   - Move `WKBReader` initialization from the field declaration into the public 
`Builder()` constructor, so only real builders pay the cost
   
   ### Are these changes tested?
   
   Yes. Two new tests were added to `TestGeospatialStatistics`:
   - `testNoopBuilderIsSingleton`: verifies `noopBuilder()` returns the same 
builder instance and `build()` returns the same cached result
   - `testNoopBuilderUpdateAndAbortAreNoOps`: exercises `update(nonNull)`, 
`update(null)`, and `abort()` on the noop builder to confirm none throw, and 
asserts the built result remains invalid with null fields
   
   ### Are there any user-facing changes?
   
   No. This is an internal optimization with no API or behavioral changes.
   
   Closes #3507
   


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