sdd commented on code in PR #512:
URL: https://github.com/apache/iceberg-rust/pull/512#discussion_r1720845074

##########
crates/iceberg/src/io/object_cache.rs:
##########
@@ -0,0 +1,161 @@
+// 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.
+
+use std::sync::Arc;
+
+use crate::io::FileIO;
+use crate::spec::{
+    FormatVersion, Manifest, ManifestFile, ManifestList, SchemaId, 
SnapshotRef, TableMetadataRef,
+};
+use crate::{Error, ErrorKind, Result};
+
+const DEFAULT_CACHE_SIZE_BYTES: u64 = 32 * 1024 * 1024; // 32MB
+
+#[derive(Clone, Debug)]
+pub(crate) enum CachedItem {
+    ManifestList(Arc<ManifestList>),
+    Manifest(Arc<Manifest>),
+}
+
+#[derive(Clone, Debug, Hash, Eq, PartialEq)]
+pub(crate) enum CachedObjectKey {
+    ManifestList((String, FormatVersion, SchemaId)),

Review Comment:
   This was done because a manifest list can be referenced from more than one 
snapshot, and those snapshots could have different schemas, and the table 
metadata that references them could also have potentially updated from V1 to V2.
   
   We're caching the **parsed** ManifestList, and the parsing depends on the 
passed down table metadata format version and snapshot schema: 
https://github.com/apache/iceberg-rust/blob/17317660993a3c1b7974a37761356cbd27e3558e/crates/iceberg/src/spec/snapshot.rs#L164-L185
   
   By adding the format version and schema id to the key, we ensure that, if 
the ManifestList is requested from either a snapshot with a different schema 
id, or from an updated table manifest data (unlikely, but I figured it safer to 
take this into consideration), then they will get a manifest list parsed with 
those specific parameters rather than one parsed under different settings.



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to