nastra commented on code in PR #12401:
URL: https://github.com/apache/iceberg/pull/12401#discussion_r1981161877
##########
core/src/main/java/org/apache/iceberg/view/ViewMetadata.java:
##########
@@ -462,9 +463,18 @@ public ViewMetadata build() {
ViewProperties.VERSION_HISTORY_SIZE,
historySize);
- // expire old versions, but keep at least the versions added in this
builder
- int numAddedVersions = (int)
changes(MetadataUpdate.AddViewVersion.class).count();
- int numVersionsToKeep = Math.max(numAddedVersions, historySize);
+ // expire old versions, but keep at least the versions added in this
builder and the current
+ // version
+ int numVersions =
+ ImmutableSet.builder()
+ .addAll(
+ changes(MetadataUpdate.AddViewVersion.class)
+ .map(v -> v.viewVersion().versionId())
+ .collect(Collectors.toSet()))
+ .add(currentVersionId)
+ .build()
+ .size();
Review Comment:
not necessarily. If the `currentVersionId` was set to one of the added
versions, then the +1 wouldn't apply, hence why I suggested using a set to get
the exact count of versions to keep
--
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]