vvellanki commented on a change in pull request #2182:
URL: https://github.com/apache/iceberg/pull/2182#discussion_r566744926
##########
File path: core/src/main/java/org/apache/iceberg/FastAppend.java
##########
@@ -147,6 +152,22 @@ private ManifestFile copyManifest(ManifestFile manifest) {
return newManifests;
}
+ @Override
+ protected Map<Integer, String> updatePartitionStats() {
+ Map<Integer, String> newPartitionStatsLocations = new HashMap<>();
+ int currentSpecID = ops.current().spec().specId();
+ List<PartitionStatsEntry> oldStatsEntries =
getOldPartitionStatsBySpec(currentSpecID);
+ PartitionsTable.PartitionMap partitionMap =
partitionStatsMap.getPartitionMap(currentSpecID);
+ if (Objects.isNull(partitionMap)) {
+ partitionMap = partitionStatsMap.getEmptyPartitionMap(currentSpecID);
Review comment:
The transaction might be a schema change transaction (like adding a new
column). Does this require creating a new partition stats for the current
specif?
##########
File path: core/src/main/java/org/apache/iceberg/GenericPartitionStatsEntry.java
##########
@@ -0,0 +1,121 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.IndexedRecord;
+import org.apache.avro.specific.SpecificData;
+import org.apache.iceberg.avro.AvroSchemaUtil;
+
+public class GenericPartitionStatsEntry implements PartitionStatsEntry,
StructLike, IndexedRecord,
+ SpecificData.SchemaConstructable, Serializable {
+
+ private final org.apache.avro.Schema schema;
+ private PartitionData partitionData = null;
+ private int fileCount;
+ private long rowCount;
+
+ GenericPartitionStatsEntry(org.apache.avro.Schema schema) {
+ this.schema = schema;
+ }
+
+ public GenericPartitionStatsEntry(PartitionData partitionData, int
fileCount, long rowCount) {
+ this.schema =
AvroSchemaUtil.convert(PartitionStatsEntry.getSchema(partitionData.getPartitionType()),
+ "partitionStatsEntry");
+ this.partitionData = partitionData;
+ this.fileCount = fileCount;
+ this.rowCount = rowCount;
+ }
+
+ @Override
+ public void put(int i, Object v) {
+ switch (i) {
+ case 0:
Review comment:
Can you define enums for these instead of using 0, 1 and 2?
##########
File path: core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java
##########
@@ -494,6 +499,48 @@ private ManifestFile newDeleteFilesAsManifest() {
return cachedNewDeleteManifest;
}
+ @Override
+ protected Map<Integer, String> updatePartitionStats() {
+ Map<Integer, String> newPartitionStatsLocations = new HashMap<>();
+
+ int currentSpecID = ops.current().spec().specId();
+
+ /**
+ * Update Partition Stats for Delete operation
+ */
+ PartitionStatsMap deletePartitionStatsMap =
filterManager.getPartitionStatsMap();
+ deletePartitionStatsMap.getAllUpdatedPartitionSpec().forEach(
+ specId -> {
+ if (specId != currentSpecID) {
+ List<PartitionStatsEntry> statsEntries =
getOldPartitionStatsBySpec(specId);
+ PartitionsTable.PartitionMap parMap =
deletePartitionStatsMap.getPartitionMap(specId);
+ parMap.subtractFromPartitionStatsEntries(statsEntries);
+ OutputFile outputFile = newPartitionStatsFile(specId);
+ newPartitionStatsLocations.put(specId, outputFile.location());
+ writePartitionStatsEntries(parMap.getAllPartitionStatsEntries(),
outputFile, specId);
Review comment:
Why are we not re-using the partition stats from the previous snapshot
instead of creating a new one for each spec?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]