Gabriel39 commented on code in PR #70869:
URL: https://github.com/apache/doris/pull/70869#discussion_r4667607273


##########
fe/fe-iceberg-common/src/main/java/org/apache/doris/connector/iceberg/IcebergV4FileIO.java:
##########
@@ -0,0 +1,170 @@
+// 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.doris.connector.iceberg;
+
+import com.github.benmanes.caffeine.cache.Caffeine;
+import com.github.benmanes.caffeine.cache.LoadingCache;
+import org.apache.iceberg.ContentFile;
+import org.apache.iceberg.DataFile;
+import org.apache.iceberg.DeleteFile;
+import org.apache.iceberg.FileFormat;
+import org.apache.iceberg.InternalData;
+import org.apache.iceberg.ManifestFile;
+import org.apache.iceberg.ManifestListFile;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.avro.AvroIterable;
+import org.apache.iceberg.io.CloseableIterable;
+import org.apache.iceberg.io.FileIO;
+import org.apache.iceberg.io.InputFile;
+import org.apache.iceberg.io.OutputFile;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.util.Map;
+import java.util.Objects;
+import java.util.regex.Pattern;
+
+/** Serializable, borrowed read view for table-relative format v4 locations. */
+public final class IcebergV4FileIO implements FileIO {
+    private static final long serialVersionUID = 1L;
+    private static final Pattern SCHEME = 
Pattern.compile("^[a-zA-Z][a-zA-Z0-9+.-]*:.*", Pattern.DOTALL);
+    private final FileIO delegate;
+    private final String tableLocation;
+    private transient LoadingCache<String, Integer> manifestVersions;
+
+    public IcebergV4FileIO(FileIO delegate, String tableLocation) {
+        this.delegate = Objects.requireNonNull(delegate, "delegate");
+        this.tableLocation = tableLocation;
+    }
+
+    public FileIO delegate() {
+        return delegate;
+    }
+
+    public static String resolve(String tableLocation, String path) {
+        Objects.requireNonNull(path, "path");
+        if (isAbsolute(path)) {
+            return path;
+        }
+        if (tableLocation == null || tableLocation.isEmpty()) {
+            throw new IllegalArgumentException("Relative Iceberg v4 path 
requires a table location: " + path);
+        }
+        // Duplicate separators are part of an object-store key, including at 
the concatenation boundary.
+        return tableLocation + "/" + path;
+    }
+
+    private static boolean isAbsolute(String path) {
+        return SCHEME.matcher(path).matches();
+    }
+
+    private static boolean isAbsoluteMetadataLocation(String path) {
+        // Upgrades retain filesystem-rooted write.metadata.path locations 
without a URI scheme.
+        // Content paths use their producing manifest's rules instead, so a V4 
"/data/file" stays relative.
+        return path.startsWith("/") || isAbsolute(path);

Review Comment:
   Fixed in e685cc46cb95f20fd4e736ea3fd28536b7ccfcbd.
   
   Slash-leading V4 manifest/list references now resolve against the frozen 
table location. Filesystem-rooted metadata is recognized from producing-list 
provenance, with validated directory/entry context for retained references 
after expiration; the prefix alone no longer establishes a legacy absolute 
path. Authentication rebinding preserves that context.
   
   Added fresh V4 cases with and without a slash-leading list, unrelated root 
bytes, cold/warm cached and uncached native reads, and serialized IO. V2/V3 
upgrade tests now expire source snapshots. Additional stored/inline metadata 
cases cover V4 rewrites containing only EXISTING entries after expiration. 
Local review also moved provenance IO out of cache-only prefetch probes and 
avoided copying stored snapshot history into every serialized task.
   
   The four new P2 reproduction cases fail on the previous head. Local scoped 
runs now pass 580 distinct FE/JNI tests, including all 25 V4 cases, with zero 
remaining failures/errors/skips; required FE Checkstyle passes. The final local 
self-review found no new verified issue. Packaged SQL and live KDC/HDFS/S3 
integration were not rerun.



##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergManifestCache.java:
##########
@@ -230,14 +235,23 @@ ManifestCacheValue getManifestCacheValue(ManifestFile 
manifest, Table table, Str
 
     /** Uses one stable statement identity while retaining only values 
classified as plaintext. */
     ManifestCacheValue readForStatement(ManifestFile manifest, Table table, 
Object loadScope, boolean privateRead) {
-        IcebergManifestEntryKey key = IcebergManifestEntryKey.of(manifest);
+        IcebergManifestEntryKey key = manifestKey(manifest, table);
         return privateRead ? IcebergManifestLoader.read(manifest, table, 
manifest.content(), false)
                 : entry.getForLoadScope(key, loadScope, k -> 
IcebergManifestLoader.read(
                         manifest, table, k.getContent(), 
entry.isWeightBounded()));
     }
 
-    void recordStatementAccess(ManifestFile manifest, String queryId, boolean 
allowCacheHit) {
-        recordAccess(IcebergManifestEntryKey.of(manifest), queryId, 
allowCacheHit);
+    void recordStatementAccess(ManifestFile manifest, Table table, String 
queryId, boolean allowCacheHit) {
+        recordAccess(manifestKey(manifest, table), queryId, allowCacheHit);
+    }
+
+    private static IcebergManifestEntryKey manifestKey(ManifestFile manifest, 
Table table) {
+        if (table instanceof BaseTable && ((BaseTable) 
table).operations().current().formatVersion() >= 4) {
+            // The same relative manifest name can describe different bytes in 
different table locations.
+            return new 
IcebergManifestEntryKey(IcebergV4FileIO.resolve(table.location(), 
manifest.path()),

Review Comment:
   Fixed in e685cc46cb95f20fd4e736ea3fd28536b7ccfcbd.
   
   V4 parsed-cache keys now include the table base, raw manifest reference, 
snapshot ID, sequence number and first row ID. Relative/absolute aliases of the 
same physical manifest therefore keep their own inherited context; legacy cache 
identity remains unchanged.
   
   Added real SDK shared-manifest cases in both read orders. Repeated reads 
assert each table's exact raw manifest provenance and resolved data path, plus 
cache reuse within that context. Another test verifies inherited sequence 
numbers and row IDs for shared bytes. Slash-leading references bind provenance 
on elected reads outside the prefetch queue lock; an unbound cache-only probe 
returns a miss without storage IO and can then reuse the parsed payload.
   
   The alias cases fail on the previous head. Local scoped runs pass 580 
distinct FE/JNI tests, including 25 V4 and 11 prefetch cases; required FE 
Checkstyle passes. The final local self-review found no new verified issue. No 
new packaged SQL or live storage integration result is claimed.



-- 
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]

Reply via email to