rdblue commented on code in PR #15854: URL: https://github.com/apache/iceberg/pull/15854#discussion_r3103692738
########## core/src/main/java/org/apache/iceberg/TrackedFileStruct.java: ########## @@ -0,0 +1,337 @@ +/* + * 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 java.util.Set; +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.ImmutableList; +import org.apache.iceberg.stats.BaseContentStats; +import org.apache.iceberg.stats.ContentStats; +import org.apache.iceberg.types.Types; +import org.apache.iceberg.util.ArrayUtil; +import org.apache.iceberg.util.ByteBuffers; + +/** Mutable {@link StructLike} implementation of {@link TrackedFile}. */ +class TrackedFileStruct extends SupportsIndexProjection implements TrackedFile, Serializable { + private static final FileContent[] FILE_CONTENT_VALUES = FileContent.values(); + private static final Types.StructType BASE_TYPE = + Types.StructType.of( + ImmutableList.<Types.NestedField>builder() + .addAll(TrackedFile.schemaWithContentStats(Types.StructType.of()).fields()) + .add(MetadataColumns.ROW_POSITION) + .build()); + + private FileContent contentType = FileContent.DATA; + private String location = null; + private FileFormat fileFormat = null; + private long recordCount = 0L; + private long fileSizeInBytes = 0L; + private Integer specId = null; + + // optional fields + private TrackingStruct tracking = null; + private ContentStats contentStats = null; + private Integer sortOrderId = null; + private DeletionVectorStruct deletionVector = null; + private ManifestInfoStruct manifestInfo = null; + private byte[] keyMetadata = null; + private long[] splitOffsets = null; + private int[] equalityIds = null; + + // not serialized to manifest, set by manifest readers + private transient TrackedFile manifestContext = null; Review Comment: I think Steven's point is a good one. As I commented below, I don't think this class should have anything to do with passing the manifest context. We should remove it and inject that context using a custom reader. For now, I think we should remove manifest context from this class and only use it in `TrackingStruct`. This affects how we handle the manifest context. It does not need to be used by this class, so it doesn't need to be `transient` (or even present). However, in classes where it is used (`TrackingStruct`) `transient` is not the right option. The main requirement is that we don't want serialization to change the values returned by the type. Last I checked, we were getting values from it lazily, which would break. However, I think I also commented in that class that we should clean up when inherited values are set, which could clean up that issue. -- 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]
