wombatu-kun commented on code in PR #16265:
URL: https://github.com/apache/iceberg/pull/16265#discussion_r3353651592
##########
core/src/main/java/org/apache/iceberg/BaseFile.java:
##########
@@ -530,11 +539,19 @@ public ByteBuffer keyMetadata() {
@Override
public List<Long> splitOffsets() {
- if (hasWellDefinedOffsets()) {
- return ArrayUtil.toUnmodifiableLongList(splitOffsets);
+ if (!hasWellDefinedOffsets()) {
+ return null;
}
- return null;
+ // Cache the unmodifiable view so that repeated callers (manifest
+ // rewriting, format conversion, toString debugging) don't reallocate
+ // a new List<Long> wrapper on every invocation. The cache is
+ // transient and is invalidated wherever splitOffsets is reassigned.
+ // See #15622.
+ if (splitOffsetsList == null) {
+ splitOffsetsList = ArrayUtil.toUnmodifiableLongList(splitOffsets);
Review Comment:
For consistency with AGENTS.md ("Use this. for instance field assignment")
and with the rest of this change: the three invalidation sites use
this.splitOffsetsList, and the sibling lazy cache getSchema() uses
this.avroSchema (BaseFile.java:306). Suggest: this.splitOffsetsList =
ArrayUtil.toUnmodifiableLongList(splitOffsets)
--
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]