Skip to content

Commit 9eeec28

Browse files
committed
squeaky?
1 parent 1280704 commit 9eeec28

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

crates/iceberg/src/io/storage.rs

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -143,47 +143,42 @@ impl OpenDALStorage {
143143

144144
match scheme {
145145
#[cfg(feature = "storage-memory")]
146-
Scheme::Memory => Ok(OpenDALStorage::Memory(super::memory_config_build()?)),
146+
Scheme::Memory => Ok(Self::Memory(super::memory_config_build()?)),
147147

148148
#[cfg(feature = "storage-fs")]
149-
Scheme::Fs => Ok(OpenDALStorage::LocalFs),
149+
Scheme::Fs => Ok(Self::LocalFs),
150150

151151
#[cfg(feature = "storage-s3")]
152152
Scheme::S3 => {
153-
let config = super::s3_config_parse(props)?;
154-
let customized_credential_load = extensions
155-
.get::<super::CustomAwsCredentialLoader>()
156-
.map(Arc::unwrap_or_clone);
157-
Ok(OpenDALStorage::S3 {
153+
Ok(Self::S3 {
158154
configured_scheme: scheme_str,
159-
config: Arc::new(config),
160-
customized_credential_load,
155+
config: super::s3_config_parse(props)?.into(),
156+
customized_credential_load: extensions
157+
.get::<super::CustomAwsCredentialLoader>()
158+
.map(Arc::unwrap_or_clone),
161159
})
162160
}
163161

164162
#[cfg(feature = "storage-gcs")]
165163
Scheme::Gcs => {
166-
let config = super::gcs_config_parse(props)?;
167-
Ok(OpenDALStorage::Gcs {
168-
config: Arc::new(config),
164+
Ok(Self::Gcs {
165+
config: super::gcs_config_parse(props)?.into(),
169166
})
170167
}
171168

172169
#[cfg(feature = "storage-oss")]
173170
Scheme::Oss => {
174-
let config = super::oss_config_parse(props)?;
175-
Ok(OpenDALStorage::Oss {
176-
config: Arc::new(config),
171+
Ok(Self::Oss {
172+
config: super::oss_config_parse(props)?.into(),
177173
})
178174
}
179175

180176
#[cfg(feature = "storage-azdls")]
181177
Scheme::Azdls => {
182178
let configured_scheme = scheme_str.parse::<super::AzureStorageScheme>()?;
183-
let config = super::azdls_config_parse(props)?;
184-
Ok(OpenDALStorage::Azdls {
179+
Ok(Self::Azdls {
185180
configured_scheme,
186-
config: Arc::new(config),
181+
config: super::azdls_config_parse(props)?.into(),
187182
})
188183
}
189184
// Update doc on [`FileIO`] when adding new schemes.
@@ -209,34 +204,35 @@ impl OpenDALStorage {
209204
fn create_operator<'a>(&self, path: &'a str) -> Result<(Operator, &'a str)> {
210205
let (operator, relative_path): (Operator, &str) = match self {
211206
#[cfg(feature = "storage-memory")]
212-
OpenDALStorage::Memory(op) => {
207+
Self::Memory(op) => {
213208
if let Some(stripped) = path.strip_prefix("memory:/") {
214-
Ok((op.clone(), stripped))
209+
Ok::<_, crate::Error>((op.clone(), stripped))
215210
} else {
216-
Ok((op.clone(), &path[1..]))
211+
Ok::<_, crate::Error>((op.clone(), &path[1..]))
217212
}
218213
}
219214

220215
#[cfg(feature = "storage-fs")]
221-
OpenDALStorage::LocalFs => {
216+
Self::LocalFs => {
222217
let op = super::fs_config_build()?;
223218

224219
if let Some(stripped) = path.strip_prefix("file:/") {
225-
Ok((op, stripped))
220+
Ok::<_, crate::Error>((op, stripped))
226221
} else {
227-
Ok((op, &path[1..]))
222+
Ok::<_, crate::Error>((op, &path[1..]))
228223
}
229224
}
230225

231226
#[cfg(feature = "storage-s3")]
232-
OpenDALStorage::S3 {
227+
Self::S3 {
233228
configured_scheme,
234229
config,
235230
customized_credential_load,
236231
} => {
237232
let op = super::s3_config_build(config, customized_credential_load, path)?;
238233
let op_info = op.info();
239234

235+
// Check prefix of s3 path.
240236
let prefix = format!("{}://{}/", configured_scheme, op_info.name());
241237
if path.starts_with(&prefix) {
242238
Ok((op, &path[prefix.len()..]))
@@ -249,7 +245,7 @@ impl OpenDALStorage {
249245
}
250246

251247
#[cfg(feature = "storage-gcs")]
252-
OpenDALStorage::Gcs { config } => {
248+
Self::Gcs { config } => {
253249
let operator = super::gcs_config_build(config, path)?;
254250
let prefix = format!("gs://{}/", operator.info().name());
255251
if path.starts_with(&prefix) {
@@ -263,8 +259,9 @@ impl OpenDALStorage {
263259
}
264260

265261
#[cfg(feature = "storage-oss")]
266-
OpenDALStorage::Oss { config } => {
262+
Self::Oss { config } => {
267263
let op = super::oss_config_build(config, path)?;
264+
// Check prefix of oss path.
268265
let prefix = format!("oss://{}/", op.info().name());
269266
if path.starts_with(&prefix) {
270267
Ok((op, &path[prefix.len()..]))
@@ -277,7 +274,7 @@ impl OpenDALStorage {
277274
}
278275

279276
#[cfg(feature = "storage-azdls")]
280-
OpenDALStorage::Azdls {
277+
Self::Azdls {
281278
configured_scheme,
282279
config,
283280
} => super::azdls_create_operator(path, config, configured_scheme),

0 commit comments

Comments
 (0)