Skip to content

Commit

Permalink
chore(zarrs_opendal): bump minimum supported opendal to 0.51
Browse files Browse the repository at this point in the history
  • Loading branch information
LDeakin committed Dec 23, 2024
1 parent 724b334 commit ec62841
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 29 deletions.
2 changes: 1 addition & 1 deletion zarrs_opendal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Changed
- **Breaking**: Bump maximum supported `opendal` to 0.51
- **Breaking**: Bump `opendal` to 0.51

## [0.4.0] - 2024-11-15

Expand Down
2 changes: 1 addition & 1 deletion zarrs_opendal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ workspace = true
[dependencies]
async-trait = "0.1.74"
futures = "0.3.29"
opendal = { version = ">=0.46,<0.52", default-features = false }
opendal = { version = ">=0.51,<0.52", default-features = false }
zarrs_storage = { workspace = true, features = ["async"] }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion zarrs_opendal/doc/version_compatibility_matrix.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
| [zarrs_opendal] | [opendal] | [zarrs] ([zarrs_storage]) |
| --------------- | --------- | ------------------------- |
| 0.5 | 0.46-0.51 | 0.18.x (0.3.x) |
| 0.5 | 0.51-0.51 | 0.18.x (0.3.x) |
| 0.4 | 0.46-0.50 | 0.18.x (0.3.x) |
| 0.3 | 0.46-0.50 | 0.17.x (0.2.x) |

Expand Down
47 changes: 34 additions & 13 deletions zarrs_opendal/src/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl AsyncWritableStorageTraits for AsyncOpendalStore {
}

async fn erase(&self, key: &StoreKey) -> Result<(), StorageError> {
handle_result(self.operator.remove(vec![key.to_string()]).await)
handle_result(self.operator.delete(key.as_str()).await)
}

async fn erase_prefix(&self, prefix: &StorePrefix) -> Result<(), StorageError> {
Expand Down Expand Up @@ -157,23 +157,44 @@ impl AsyncListableStorageTraits for AsyncOpendalStore {
}

async fn size_prefix(&self, prefix: &StorePrefix) -> Result<u64, StorageError> {
handle_result_notfound(
let Some(files) = handle_result_notfound(
self.operator
.list_with(prefix.as_str())
.recursive(true)
.metakey(opendal::Metakey::ContentLength)
.await,
)?
.map_or_else(
|| Ok(0),
|list| {
let size = list
.into_iter()
.map(|entry| entry.metadata().content_length())
.sum::<u64>();
Ok(size)
},
)
else {
return Ok(0);

Check warning on line 167 in zarrs_opendal/src/async.rs

View check run for this annotation

Codecov / codecov/patch

zarrs_opendal/src/async.rs#L167

Added line #L167 was not covered by tests
};

if self
.operator
.info()
.full_capability()
.list_has_content_length
{
let size = files
.into_iter()
.filter_map(|entry| {
if entry.metadata().is_file() {
Some(entry.metadata().content_length())

Check warning on line 180 in zarrs_opendal/src/async.rs

View check run for this annotation

Codecov / codecov/patch

zarrs_opendal/src/async.rs#L176-L180

Added lines #L176 - L180 were not covered by tests
} else {
None

Check warning on line 182 in zarrs_opendal/src/async.rs

View check run for this annotation

Codecov / codecov/patch

zarrs_opendal/src/async.rs#L182

Added line #L182 was not covered by tests
}
})
.sum::<u64>();
Ok(size)

Check warning on line 186 in zarrs_opendal/src/async.rs

View check run for this annotation

Codecov / codecov/patch

zarrs_opendal/src/async.rs#L184-L186

Added lines #L184 - L186 were not covered by tests
} else {
// TODO: concurrent
let mut size = 0;
for entry in files {
let meta = handle_result(self.operator.stat(entry.path()).await)?;
if meta.is_file() {
size += meta.content_length();
}
}
Ok(size)
}
}
}

Expand Down
47 changes: 34 additions & 13 deletions zarrs_opendal/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl WritableStorageTraits for OpendalStore {
}

fn erase(&self, key: &StoreKey) -> Result<(), StorageError> {
handle_result(self.operator.remove(vec![key.to_string()]))
handle_result(self.operator.delete(key.as_str()))
}

fn erase_prefix(&self, prefix: &StorePrefix) -> Result<(), StorageError> {
Expand Down Expand Up @@ -145,23 +145,44 @@ impl ListableStorageTraits for OpendalStore {
}

fn size_prefix(&self, prefix: &StorePrefix) -> Result<u64, StorageError> {
handle_result_notfound(
let Some(files) = handle_result_notfound(
self.operator
.list_with(prefix.as_str())
.recursive(true)
.metakey(opendal::Metakey::ContentLength)
.call(),
)?
.map_or_else(
|| Ok(0),
|list| {
let size = list
.into_iter()
.map(|entry| entry.metadata().content_length())
.sum::<u64>();
Ok(size)
},
)
else {
return Ok(0);

Check warning on line 155 in zarrs_opendal/src/sync.rs

View check run for this annotation

Codecov / codecov/patch

zarrs_opendal/src/sync.rs#L155

Added line #L155 was not covered by tests
};

if self
.operator
.info()
.full_capability()
.list_has_content_length
{
let size = files
.into_iter()
.filter_map(|entry| {
if entry.metadata().is_file() {
Some(entry.metadata().content_length())

Check warning on line 168 in zarrs_opendal/src/sync.rs

View check run for this annotation

Codecov / codecov/patch

zarrs_opendal/src/sync.rs#L164-L168

Added lines #L164 - L168 were not covered by tests
} else {
None

Check warning on line 170 in zarrs_opendal/src/sync.rs

View check run for this annotation

Codecov / codecov/patch

zarrs_opendal/src/sync.rs#L170

Added line #L170 was not covered by tests
}
})
.sum::<u64>();
Ok(size)

Check warning on line 174 in zarrs_opendal/src/sync.rs

View check run for this annotation

Codecov / codecov/patch

zarrs_opendal/src/sync.rs#L172-L174

Added lines #L172 - L174 were not covered by tests
} else {
// TODO: concurrent
let mut size = 0;
for entry in files {
let meta = handle_result(self.operator.stat(entry.path()))?;
if meta.is_file() {
size += meta.content_length();
}
}
Ok(size)
}
}
}

Expand Down

0 comments on commit ec62841

Please sign in to comment.