gaborkaszab commented on code in PR #12401:
URL: https://github.com/apache/iceberg/pull/12401#discussion_r1977378596
##########
core/src/main/java/org/apache/iceberg/view/ViewMetadata.java:
##########
@@ -462,9 +463,15 @@ 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
+ Set<Integer> addedVersions =
+ changes(MetadataUpdate.AddViewVersion.class)
+ .map(v -> v.viewVersion().versionId())
+ .collect(Collectors.toSet());
+ int numVersions =
+
ImmutableSet.builder().addAll(addedVersions).add(currentVersionId).build().size();
Review Comment:
nit: I think instead of creating another Set here we could add
`currentVersionId` to `addedVersions` (Maybe versionsToKeep?). If you want to
avoid any misuse of this set then putting this whole new code into a function
could help (numVersinsToKeep?)
--
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]