rdblue commented on code in PR #14533: URL: https://github.com/apache/iceberg/pull/14533#discussion_r2539963991
########## core/src/main/java/org/apache/iceberg/GenericTrackedFile.java: ########## @@ -0,0 +1,773 @@ +/* + * 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 java.nio.ByteBuffer; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import org.apache.avro.Schema; +import org.apache.avro.generic.IndexedRecord; +import org.apache.avro.specific.SpecificData; +import org.apache.iceberg.avro.AvroSchemaUtil; +import org.apache.iceberg.avro.SupportsIndexProjection; +import org.apache.iceberg.relocated.com.google.common.base.MoreObjects; +import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; +import org.apache.iceberg.types.Types; +import org.apache.iceberg.util.ArrayUtil; +import org.apache.iceberg.util.ByteBuffers; + +/** Generic implementation of {@link TrackedFile} for V4 manifests. */ +public class GenericTrackedFile extends SupportsIndexProjection + implements TrackedFile<GenericTrackedFile>, + IndexedRecord, + StructLike, + SpecificData.SchemaConstructable, + Serializable { + + private static final FileContent[] FILE_CONTENT_VALUES = FileContent.values(); + + // Tracking metadata + private String manifestLocation = null; + private TrackingInfo.Status status = null; + private Long snapshotId = null; + private Long sequenceNumber = null; + private Long fileSequenceNumber = null; + private Long firstRowId = null; + private Long position = null; + + // Common file metadata + private FileContent contentType = FileContent.DATA; + private String location = null; + private FileFormat fileFormat = null; + private long recordCount = -1L; + private Long fileSizeInBytes = null; + + // Deletion vector fields + private Long deletionVectorOffset = null; + private Long deletionVectorSizeInBytes = null; + private byte[] deletionVectorInlineContent = null; + + // Partition and ordering + private int partitionSpecId = -1; + private Integer sortOrderId = null; + + // Optional metadata + private byte[] keyMetadata = null; + private long[] splitOffsets = null; + private int[] equalityIds = null; + private String referencedFile = null; + + // Manifest stats (for manifest entries) + private Integer addedFilesCount = null; + private Integer existingFilesCount = null; + private Integer deletedFilesCount = null; + private Long addedRowsCount = null; + private Long existingRowsCount = null; + private Long deletedRowsCount = null; + private Long minSequenceNumber = null; + + // Content stats placeholder (TODO: implement ContentStats) + private Object contentStats = null; + + // Cached schema for Avro + private transient Schema avroSchema = null; + + // Base type that corresponds to positions for get/set + // All fields are made optional to support different content types + static final Types.StructType BASE_TYPE = + Types.StructType.of( + TrackedFile.CONTENT_TYPE, + TrackedFile.LOCATION, + TrackedFile.FILE_FORMAT, + TrackedFile.PARTITION_SPEC_ID, + TrackedFile.SORT_ORDER_ID, + TrackedFile.RECORD_COUNT, + TrackedFile.FILE_SIZE_IN_BYTES, + TrackedFile.KEY_METADATA, + TrackedFile.SPLIT_OFFSETS, + TrackedFile.EQUALITY_IDS, + TrackedFile.REFERENCED_FILE, + // Tracking info fields + TrackingInfo.STATUS.asOptional(), + TrackingInfo.SNAPSHOT_ID, + TrackingInfo.SEQUENCE_NUMBER, + TrackingInfo.FILE_SEQUENCE_NUMBER, + TrackingInfo.FIRST_ROW_ID, + // Deletion vector fields + DeletionVector.OFFSET, + DeletionVector.SIZE_IN_BYTES, + DeletionVector.INLINE_CONTENT, + // Manifest stats fields + ManifestStats.ADDED_FILES_COUNT.asOptional(), + ManifestStats.EXISTING_FILES_COUNT.asOptional(), + ManifestStats.DELETED_FILES_COUNT.asOptional(), + ManifestStats.ADDED_ROWS_COUNT.asOptional(), + ManifestStats.EXISTING_ROWS_COUNT.asOptional(), + ManifestStats.DELETED_ROWS_COUNT.asOptional(), + ManifestStats.MIN_SEQUENCE_NUMBER.asOptional()); Review Comment: Each of the sub-structs should be its own struct type (like `ManifestStatsStruct` and `TrackingInfoStruct`) that is read and written the same way that this class is. The `TrackedFile` schema should embed each sub struct as a field. -- 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]
