singhpk234 commented on code in PR #14921:
URL: https://github.com/apache/iceberg/pull/14921#discussion_r2648470067
##########
api/src/main/java/org/apache/iceberg/ExpireSnapshots.java:
##########
@@ -161,4 +162,7 @@ default ExpireSnapshots cleanExpiredMetadata(boolean clean)
{
throw new UnsupportedOperationException(
this.getClass().getName() + " doesn't implement cleanExpiredMetadata");
}
+
+ /** Report metrics about the ExpireSnapshots operation to the provided
reporter */
+ ExpireSnapshots metricsReporter(MetricsReporter reporter);
Review Comment:
can we have a default which throws UnsupportedOp ?
##########
core/src/main/java/org/apache/iceberg/ReachableFileCleanup.java:
##########
@@ -208,8 +231,16 @@ private Set<String> findFilesToDelete(
}
// Remove all the live files from the candidate deletion set
- try (CloseableIterable<String> paths =
ManifestFiles.readPaths(manifest, fileIO)) {
- paths.forEach(filesToDelete::remove);
+ try (ManifestReader<DataFile> reader =
+ ManifestFiles.read(manifest, fileIO)
+ .select(ImmutableList.of("content", "file_path"))) {
+ reader
+ .liveEntries()
+ .forEach(
+ entry -> {
+ DataFile file = entry.file();
+ filesToDelete.remove(new FileInfo(file.content(),
file.location()));
+ });
Review Comment:
can extract this in a common util as it same as 198-207
##########
core/src/main/java/org/apache/iceberg/FileCleanupStrategy.java:
##########
@@ -124,7 +134,92 @@ protected void deleteFiles(Set<String> pathsToDelete,
String fileType) {
.suppressFailureWhenFinished()
.onFailure(
(file, thrown) -> LOG.warn("Delete failed for {} file: {}",
fileType, file, thrown))
- .run(deleteFuncToUse::accept);
+ .run(
+ file -> {
+ deleteFuncToUse.accept(file);
+ summary.deletedFile(file, fileType);
+ });
+ }
+ }
+
+ static class DeleteSummary {
+ private final AtomicLong dataFilesCount = new AtomicLong(0L);
+ private final AtomicLong positionDeleteFilesCount = new AtomicLong(0L);
+ private final AtomicLong equalityDeleteFilesCount = new AtomicLong(0L);
+ private final AtomicLong manifestsCount = new AtomicLong(0L);
+ private final AtomicLong manifestListsCount = new AtomicLong(0L);
+ private final AtomicLong statisticsFilesCount = new AtomicLong(0L);
+
+ public void deletedFiles(String type, int numFiles) {
+ if (FileContent.DATA.name().equalsIgnoreCase(type)) {
+ dataFilesCount.addAndGet(numFiles);
+
+ } else if (FileContent.POSITION_DELETES.name().equalsIgnoreCase(type)) {
+ positionDeleteFilesCount.addAndGet(numFiles);
+
+ } else if (FileContent.EQUALITY_DELETES.name().equalsIgnoreCase(type)) {
+ equalityDeleteFilesCount.addAndGet(numFiles);
+
+ } else if (MANIFEST.equalsIgnoreCase(type)) {
+ manifestsCount.addAndGet(numFiles);
+
+ } else if (MANIFEST_LIST.equalsIgnoreCase(type)) {
+ manifestListsCount.addAndGet(numFiles);
+
+ } else if (STATISTICS_FILES.equalsIgnoreCase(type)) {
+ statisticsFilesCount.addAndGet(numFiles);
+
+ } else {
+ throw new ValidationException("Illegal file type: %s", type);
+ }
+ }
+
+ public void deletedFile(String path, String type) {
+ if (FileContent.DATA.name().equalsIgnoreCase(type)) {
+ dataFilesCount.incrementAndGet();
+
+ } else if (FileContent.POSITION_DELETES.name().equalsIgnoreCase(type)) {
+ positionDeleteFilesCount.incrementAndGet();
+
+ } else if (FileContent.EQUALITY_DELETES.name().equalsIgnoreCase(type)) {
+ equalityDeleteFilesCount.incrementAndGet();
+
+ } else if ("manifest".equalsIgnoreCase(type)) {
+ manifestsCount.incrementAndGet();
+
+ } else if ("manifest list".equalsIgnoreCase(type)) {
+ manifestListsCount.incrementAndGet();
Review Comment:
can use constants above ?
##########
core/src/main/java/org/apache/iceberg/metrics/RemoveSnapshotsReport.java:
##########
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.metrics;
+
+import org.immutables.value.Value;
+
[email protected]
+public abstract class RemoveSnapshotsReport implements MetricsReport {
Review Comment:
i wonder if there is a way to get this according to the contract defined
here :
https://github.com/apache/iceberg/blob/0651b8913d27c3b1c9aca4a9609bec521905fb36/api/src/main/java/org/apache/iceberg/actions/ExpireSnapshots.java#L116
--
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]