From abbc9d6b19c5f5bdaaa3b7c15b2bd2d768325549 Mon Sep 17 00:00:00 2001 From: Matthew Turner Date: Sat, 5 Apr 2025 11:15:47 -0400 Subject: [PATCH] Start setting up indexmap cache --- crates/datafusion-app/Cargo.toml | 1 + .../src/cache/indexmap_cache.rs | 78 +++++++++++++++++++ crates/datafusion-app/src/cache/mod.rs | 18 +++++ crates/datafusion-app/src/lib.rs | 1 + 4 files changed, 98 insertions(+) create mode 100644 crates/datafusion-app/src/cache/indexmap_cache.rs create mode 100644 crates/datafusion-app/src/cache/mod.rs diff --git a/crates/datafusion-app/Cargo.toml b/crates/datafusion-app/Cargo.toml index ad83185..2c2076d 100644 --- a/crates/datafusion-app/Cargo.toml +++ b/crates/datafusion-app/Cargo.toml @@ -57,6 +57,7 @@ iceberg = ["dep:iceberg-catalog-rest", "dep:iceberg-datafusion"] observability = [] s3 = ["object_store/aws", "url"] udfs-wasm = ["dep:datafusion-udfs-wasm"] +object_store = ["dep:object_store"] [lints.clippy] clone_on_ref_ptr = "deny" diff --git a/crates/datafusion-app/src/cache/indexmap_cache.rs b/crates/datafusion-app/src/cache/indexmap_cache.rs new file mode 100644 index 0000000..9f771bd --- /dev/null +++ b/crates/datafusion-app/src/cache/indexmap_cache.rs @@ -0,0 +1,78 @@ +// 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 datafusion::execution::cache::CacheAccessor; +use indexmap::IndexMap; +use object_store::{path::Path, ObjectMeta}; + +struct IndexMapFileCache { + name: String, + inner: IndexMap>>, +} + +impl IndexMapFileCache { + pub fn new(name: String, data: IndexMap>>) -> Self { + Self { name, inner: data } + } +} + +impl CacheAccessor>> for IndexMapFileCache { + type Extra = ObjectMeta; + + fn name(&self) -> String { + self.name.clone() + } + + fn get(&self, k: &Path) -> Option>> { + todo!() + } + + fn get_with_extra(&self, k: &Path, e: &Self::Extra) -> Option>> { + todo!() + } + + fn put(&self, key: &Path, value: Arc>) -> Option>> { + todo!() + } + + fn put_with_extra( + &self, + key: &Path, + value: Arc>, + e: &Self::Extra, + ) -> Option>> { + todo!() + } + + fn remove(&mut self, k: &Path) -> Option>> { + todo!() + } + + fn contains_key(&self, k: &Path) -> bool { + todo!() + } + + fn len(&self) -> usize { + todo!() + } + + fn clear(&self) { + todo!() + } +} diff --git a/crates/datafusion-app/src/cache/mod.rs b/crates/datafusion-app/src/cache/mod.rs new file mode 100644 index 0000000..8222612 --- /dev/null +++ b/crates/datafusion-app/src/cache/mod.rs @@ -0,0 +1,18 @@ +// 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. + +pub mod indexmap_cache; diff --git a/crates/datafusion-app/src/lib.rs b/crates/datafusion-app/src/lib.rs index ba5635b..d2e89af 100644 --- a/crates/datafusion-app/src/lib.rs +++ b/crates/datafusion-app/src/lib.rs @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +pub mod cache; pub mod catalog; pub mod config; pub mod executor;