Reduce allocation overhead of no-op `GeospatialStatistics.Builder`
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 1.6k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 33
Description
### Describe the enhancement requested
`GeospatialStatistics.noopBuilder()` is called for every non-geometry column in every row group. Today, each call allocates a new `NoopBuilder` (plus a `WKBReader`, `BoundingBox`, and `GeospatialTypes` that are never used), and each `build()` allocates a new `GeospatialStatistics(null, null)` that is immediately discarded.
Since `NoopBuilder` carries no state and all its methods are no-ops, it can be a singleton. Its `build()` result is equally stateless (null fields, with merge/abort guarded by null checks), so it can be cached too.
### Proposed Changes
- Make `NoopBuilder` a singleton via a static `INSTANCE` field
- Cache `build()` output as a static `EMPTY` instance
- Add a package-private super constructor that skips field initialization so the singleton doesn't allocate unused objects
This eliminates per-column-per-row-group allocations on the common path where geospatial statistics are disabled.
### Component(s)
Core
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at GeospatialStatistics.noopBuilder() and trace NoopBuilder, its build() method, and the relevant constructors. Confirm how unused fields are initialized and verify that the no-op builder and empty statistics result are reused without changing merge or abort behavior; done means the common path no longer allocates those objects per call.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100