Skip to content

Commit 94735c2

Browse files
committed
Cleanup OpenDALStorage enum
1 parent 3da86b8 commit 94735c2

File tree

9 files changed

+285
-537
lines changed

9 files changed

+285
-537
lines changed

crates/iceberg/src/io/file_io.rs

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -25,52 +25,11 @@ use async_trait::async_trait;
2525
use bytes::Bytes;
2626
use url::Url;
2727

28+
// Re-export traits from storage module
29+
pub use super::storage::{Storage, StorageBuilder};
30+
use crate::io::StorageBuilderRegistry;
2831
use crate::{Error, ErrorKind, Result};
2932

30-
/// Trait for storage operations in Iceberg
31-
#[async_trait]
32-
pub trait Storage: Debug + Send + Sync {
33-
/// Check if a file exists at the given path
34-
async fn exists(&self, path: &str) -> Result<bool>;
35-
36-
/// Get metadata from an input path
37-
async fn metadata(&self, path: &str) -> Result<FileMetadata>;
38-
39-
/// Read bytes from a path
40-
async fn read(&self, path: &str) -> Result<Bytes>;
41-
42-
/// Get FileRead from a path
43-
async fn reader(&self, path: &str) -> Result<Box<dyn FileRead>>;
44-
45-
/// Write bytes to an output path
46-
async fn write(&self, path: &str, bs: Bytes) -> Result<()>;
47-
48-
/// Get FileWrite from a path
49-
async fn writer(&self, path: &str) -> Result<Box<dyn FileWrite>>;
50-
51-
/// Delete a file at the given path
52-
async fn delete(&self, path: &str) -> Result<()>;
53-
54-
/// Remove a directory and all its contents recursively
55-
async fn remove_dir_all(&self, path: &str) -> Result<()>;
56-
57-
/// Create a new input file for reading
58-
fn new_input(&self, path: &str) -> Result<InputFile>;
59-
60-
/// Create a new output file for writing
61-
fn new_output(&self, path: &str) -> Result<OutputFile>;
62-
}
63-
64-
/// Common interface for all storage builders.
65-
pub trait StorageBuilder: Debug + Send + Sync {
66-
/// Create a new storage instance with the given properties and extensions.
67-
fn build(
68-
&self,
69-
props: HashMap<String, String>,
70-
extensions: Extensions,
71-
) -> Result<Arc<dyn Storage>>;
72-
}
73-
7433
/// FileIO implementation, used to manipulate files in underlying storage.
7534
///
7635
/// # Note
@@ -133,8 +92,6 @@ impl FileIO {
13392
///
13493
/// * path: It should be *absolute* path starting with scheme string used to construct [`FileIO`].
13594
pub async fn delete(&self, path: impl AsRef<str>) -> Result<()> {
136-
// let (op, relative_path) = self.inner.create_operator(&path)?;
137-
// Ok(op.delete(relative_path).await?)
13895
self.inner.delete(path.as_ref()).await
13996
}
14097

@@ -299,11 +256,11 @@ impl FileIOBuilder {
299256
pub fn build(self) -> Result<FileIO> {
300257
// Use the scheme to determine the storage type
301258
let scheme = self.scheme_str.clone().unwrap_or_default();
302-
259+
303260
// Create registry and get builder
304-
let registry = crate::io::StorageBuilderRegistry::new();
261+
let registry = StorageBuilderRegistry::new();
305262
let builder = registry.get_builder(scheme.as_str())?;
306-
263+
307264
// Build storage with props and extensions
308265
let storage = builder.build(self.props.clone(), self.extensions.clone())?;
309266

crates/iceberg/src/io/mod.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,9 @@
6868
6969
mod file_io;
7070
mod storage;
71-
mod storage_builder;
7271

7372
pub use file_io::*;
74-
pub use storage_builder::StorageBuilderRegistry;
73+
pub use storage::{Storage, StorageBuilder, StorageBuilderRegistry};
7574
pub(crate) mod object_cache;
7675

7776
#[cfg(feature = "storage-azdls")]
@@ -89,12 +88,8 @@ mod storage_s3;
8988

9089
#[cfg(feature = "storage-azdls")]
9190
pub use storage_azdls::*;
92-
#[cfg(feature = "storage-fs")]
93-
use storage_fs::*;
9491
#[cfg(feature = "storage-gcs")]
9592
pub use storage_gcs::*;
96-
#[cfg(feature = "storage-memory")]
97-
use storage_memory::*;
9893
#[cfg(feature = "storage-oss")]
9994
pub use storage_oss::*;
10095
#[cfg(feature = "storage-s3")]

0 commit comments

Comments
 (0)