Skip to content
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

feat: Store file io props to allow re-build it #802

Merged
merged 3 commits into from
Dec 17, 2024
Merged
Changes from 1 commit
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
15 changes: 15 additions & 0 deletions crates/iceberg/src/io/file_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,21 @@ use crate::{Error, ErrorKind, Result};
/// | GCS | `storage-gcs` | `gcs` |
#[derive(Clone, Debug)]
pub struct FileIO {
scheme: String,
props: HashMap<String, String>,

inner: Arc<Storage>,
}

impl FileIO {
/// Split file IO into scheme and props which used to build this FileIO.
///
/// This function is useful when you want serialize and deserialize FileIO across
/// distributed systems.
pub fn into_props(self) -> (String, HashMap<String, String>) {
(self.scheme, self.props)
}

/// Try to infer file io scheme from path. See [`FileIO`] for supported schemes.
///
/// - If it's a valid url, for example `s3://bucket/a`, url scheme will be used, and the rest of the url will be ignored.
Expand Down Expand Up @@ -187,8 +198,12 @@ impl FileIOBuilder {

/// Builds [`FileIO`].
pub fn build(self) -> crate::Result<FileIO> {
let scheme = self.scheme_str.clone().unwrap_or_default();
let props = self.props.clone();
let storage = Storage::build(self)?;
Ok(FileIO {
scheme,
props,
inner: Arc::new(storage),
})
}
Expand Down
Loading