Skip to content

refactor: Adopt ObjectProvider in Table #1227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 9 additions & 152 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions crates/iceberg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ derive_builder = { workspace = true }
fnv = { workspace = true }
futures = { workspace = true }
itertools = { workspace = true }
moka = { version = "0.12.10", features = ["future"] }
murmur3 = { workspace = true }
num-bigint = { workspace = true }
once_cell = { workspace = true }
Expand Down Expand Up @@ -98,4 +97,4 @@ tera = { workspace = true }

[package.metadata.cargo-machete]
# These dependencies are added to ensure minimal dependency version
ignored = ["tap"]
ignored = ["tap"]
13 changes: 12 additions & 1 deletion crates/iceberg/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

//! Cache management for Iceberg.

use std::fmt::Debug;
use std::sync::Arc;

use crate::spec::{Manifest, ManifestList};
Expand Down Expand Up @@ -44,13 +45,23 @@ pub trait ObjectCache<K, V>: Send + Sync {
/// which contains `Schema`. Please ensure that the cache stores the
/// object in memory as-is, without attempting to serialize it, as
/// serialization could be extremely expensive.
pub trait ObjectCacheProvide: Send + Sync {
pub trait ObjectCacheProvide: Send + Sync + Debug {
/// Gets a cache for manifests.
fn manifest_cache(&self) -> &dyn ObjectCache<String, Arc<Manifest>>;
/// Gets a cache for manifest lists.
fn manifest_list_cache(&self) -> &dyn ObjectCache<String, Arc<ManifestList>>;
}

impl<T: ObjectCacheProvide + ?Sized> ObjectCacheProvide for T {
fn manifest_cache(&self) -> &dyn ObjectCache<String, Arc<Manifest>> {
(*self).manifest_cache()
}

fn manifest_list_cache(&self) -> &dyn ObjectCache<String, Arc<ManifestList>> {
(*self).manifest_list_cache()
}
}

/// CacheProvider is a type alias for a thread-safe reference-counted pointer to a CacheProvide trait object.
pub type ObjectCacheProvider = Arc<dyn ObjectCacheProvide>;

Expand Down
6 changes: 5 additions & 1 deletion crates/iceberg/src/inspect/manifests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ impl<'a> ManifestsTable<'a> {

if let Some(snapshot) = self.table.metadata().current_snapshot() {
let manifest_list = snapshot
.load_manifest_list(self.table.file_io(), &self.table.metadata_ref())
.load_manifest_list(
&self.table.metadata_ref(),
self.table.file_io(),
self.table.object_cache(),
)
.await?;
for manifest in manifest_list.entries() {
content.append_value(manifest.content as i32);
Expand Down
1 change: 0 additions & 1 deletion crates/iceberg/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ use storage_memory::*;
mod storage_s3;
#[cfg(feature = "storage-s3")]
pub use storage_s3::*;
pub(crate) mod object_cache;
#[cfg(feature = "storage-fs")]
mod storage_fs;

Expand Down
Loading
Loading