Skip to content
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
1 change: 1 addition & 0 deletions crates/storage/opendal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ impl OpenDalStorage {
multipart_part_size,
..
} => WriteOptions {
// The parser caps this at `i32::MAX`, so the cast can't fail for parsed values.
chunk: Some(usize::try_from(*multipart_part_size).unwrap_or(usize::MAX)),
..WriteOptions::default()
},
Expand Down
3 changes: 3 additions & 0 deletions crates/storage/opendal/src/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ const MULTIPART_PART_SIZE_MAX: u64 = i32::MAX as u64;
/// Matches Java `S3FileIOProperties.MULTIPART_SIZE_DEFAULT`.
const MULTIPART_PART_SIZE_DEFAULT: u64 = 32 * 1024 * 1024;

/// Default part size, also the serde default for `OpenDalStorage::S3::multipart_part_size`.
/// A bare `#[serde(default)]` would read payloads without the field as 0, which OpenDAL
/// raises to 5 MiB instead of 32 MiB.
pub(crate) fn default_multipart_part_size() -> u64 {
MULTIPART_PART_SIZE_DEFAULT
}
Expand Down
22 changes: 11 additions & 11 deletions crates/storage/opendal/tests/file_io_s3_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ mod tests {
.build()
}

/// Number of upload parts S3 recorded for `key`. A multipart upload reports
/// a `<md5>-<part-count>` ETag; a single-request upload reports a bare MD5.
/// Number of upload parts S3 recorded for `key`, or `None` for a single-request
/// upload. A multipart upload reports a `<md5>-<part-count>` ETag; a single-request
/// upload reports a bare MD5.
///
/// A server-side encrypted object can report an ETag without the suffix, so
/// this helper holds only for the object store fixture these tests run against.
async fn upload_part_count(key: &str) -> usize {
async fn upload_part_count(key: &str) -> Option<usize> {
let mut config = opendal::services::S3Config::default();
config.endpoint = Some(get_object_store_endpoint());
config.access_key_id = Some(OBJECT_STORE_ACCESS_KEY_ID.to_string());
Expand All @@ -92,12 +93,11 @@ mod tests {
.etag()
.expect("object store reports an ETag")
.trim_matches('"');
match etag.rsplit_once('-') {
Some((_, parts)) => parts
etag.rsplit_once('-').map(|(_, parts)| {
parts
.parse()
.unwrap_or_else(|e| panic!("unexpected ETag format {etag}: {e}")),
None => 1,
}
.unwrap_or_else(|e| panic!("unexpected ETag format {etag}: {e}"))
})
}

fn roundtrip_file_io(file_io: &FileIO) -> FileIO {
Expand Down Expand Up @@ -181,7 +181,7 @@ mod tests {
.unwrap();
writer.close().await.unwrap();

assert_eq!(upload_part_count(&key).await, PARTS);
assert_eq!(upload_part_count(&key).await, Some(PARTS));
file_io.delete(&path).await.unwrap();
}

Expand All @@ -206,7 +206,7 @@ mod tests {
.await
.unwrap();

assert_eq!(upload_part_count(&key).await, PARTS);
assert_eq!(upload_part_count(&key).await, Some(PARTS));
file_io.delete(&path).await.unwrap();
}

Expand All @@ -230,7 +230,7 @@ mod tests {
.await
.unwrap();

assert_eq!(upload_part_count(&key).await, 1);
assert_eq!(upload_part_count(&key).await, None);
file_io.delete(&path).await.unwrap();
}

Expand Down
Loading