Skip to content

refactor(reader): hoist Materialized* boilerplate into shared base#135

Merged
dfa1 merged 1 commit into
mainfrom
refactor/sonar-cleanup
Jun 22, 2026
Merged

refactor(reader): hoist Materialized* boilerplate into shared base#135
dfa1 merged 1 commit into
mainfrom
refactor/sonar-cleanup

Conversation

@dfa1

@dfa1 dfa1 commented Jun 22, 2026

Copy link
Copy Markdown
Owner

The eight buffer-backed Materialized*Array classes each repeated the same cold plumbing: the dtype/length/buffer triple, trivial dtype()/length() getters, and the zero-copy materialize()/segmentIfPresent() contract. Hoisted into a package-private AbstractMaterializedArray that each leaf extends.

Deliberately:

  • Base does not implements Array — that interface is sealed to the typed element families; each leaf does extends AbstractMaterializedArray implements IntArray/….
  • Hot getX/fold/forEach loops stay branch-split in the leaves so C2 keeps vectorising them (CLAUDE.md hot-loop rule). Only cold boilerplate moves.

Net −206 LOC, kills the SonarQube duplication smell across the family. Reader suite green (854); verify javadoc enforcement passes.

🤖 Generated with Claude Code

The eight buffer-backed Materialized*Array classes each repeated the same cold
plumbing: the dtype/length/buffer triple, the trivial dtype()/length() getters,
and the zero-copy materialize()/segmentIfPresent() contract. Extract it into a
package-private AbstractMaterializedArray that each leaf now extends.

The base deliberately does NOT implement Array (that interface is sealed to the
typed element families) and does NOT hoist the hot getX/fold/forEach loops: those
stay monomorphic and branch-split in the leaf classes so C2 keeps vectorising them
(CLAUDE.md hot-loop rule). Only the cold boilerplate moves.

Net -206 LOC, kills the SonarQube duplication smell across the family. Reader
suite green (854); javadoc enforcement passes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dfa1 dfa1 merged commit 8362a35 into main Jun 22, 2026
6 checks passed
@dfa1 dfa1 deleted the refactor/sonar-cleanup branch June 22, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant