Skip to content

Commit fbf0c71

Browse files
committed
upgrade
Signed-off-by: tison <wander4096@gmail.com>
1 parent 2e7ad95 commit fbf0c71

File tree

7 files changed

+45
-42
lines changed

7 files changed

+45
-42
lines changed

integrations/object_store/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ homepage = "https://opendal.apache.org/"
2525
license = "Apache-2.0"
2626
repository = "https://github.com/apache/opendal"
2727
rust-version = "1.85"
28-
version = "0.55.0"
28+
version = "0.56.0"
2929

3030
[features]
3131
send_wrapper = ["dep:send_wrapper"]

integrations/object_store/src/service/deleter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
use std::sync::Arc;
1919

2020
use futures::stream::{self, StreamExt};
21-
use object_store::ObjectStore;
2221
use object_store::path::Path as ObjectStorePath;
22+
use object_store::{ObjectStore, ObjectStoreExt};
2323
use opendal::raw::oio::BatchDeleteResult;
2424
use opendal::raw::*;
2525
use opendal::*;
@@ -44,7 +44,7 @@ impl oio::BatchDelete for ObjectStoreDeleter {
4444

4545
async fn delete_batch(&self, paths: Vec<(String, OpDelete)>) -> Result<BatchDeleteResult> {
4646
// convert paths to stream, then use [`ObjectStore::delete_stream`] to delete them in batch
47-
let stream = stream::iter(paths.iter())
47+
let stream = stream::iter(paths.clone())
4848
.map(|(path, _)| Ok::<_, object_store::Error>(ObjectStorePath::from(path.as_str())))
4949
.boxed();
5050
let results = self.store.delete_stream(stream).collect::<Vec<_>>().await;

integrations/object_store/src/service/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ mod tests {
166166
let builder = ObjectStoreBuilder::new(store);
167167

168168
let backend = builder.build().expect("build should succeed");
169-
assert!(backend.info().scheme() == OBJECT_STORE_SCHEME);
169+
assert_eq!(backend.info().scheme(), OBJECT_STORE_SCHEME);
170170
}
171171

172172
#[tokio::test]

integrations/object_store/src/store.rs

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use futures::TryStreamExt;
2929
use futures::stream::BoxStream;
3030
use mea::mutex::Mutex;
3131
use mea::oneshot;
32-
use object_store::ListResult;
3332
use object_store::MultipartUpload;
3433
use object_store::ObjectMeta;
3534
use object_store::ObjectStore;
@@ -41,6 +40,7 @@ use object_store::path::Path;
4140
use object_store::{GetOptions, UploadPart};
4241
use object_store::{GetRange, GetResultPayload};
4342
use object_store::{GetResult, PutMode};
43+
use object_store::{ListResult, RenameOptions};
4444
use opendal::Buffer;
4545
use opendal::Writer;
4646
use opendal::options::CopyOptions;
@@ -227,23 +227,6 @@ impl ObjectStore for OpendalStore {
227227
Ok(PutResult { e_tag, version })
228228
}
229229

230-
async fn put_multipart(
231-
&self,
232-
location: &Path,
233-
) -> object_store::Result<Box<dyn MultipartUpload>> {
234-
let decoded_location = percent_decode_path(location.as_ref());
235-
let writer = self
236-
.inner
237-
.writer_with(&decoded_location)
238-
.concurrent(8)
239-
.into_send()
240-
.await
241-
.map_err(|err| format_object_store_error(err, location.as_ref()))?;
242-
let upload = OpendalMultipartUpload::new(writer, location.clone());
243-
244-
Ok(Box::new(upload))
245-
}
246-
247230
async fn put_multipart_opts(
248231
&self,
249232
location: &Path,
@@ -430,15 +413,27 @@ impl ObjectStore for OpendalStore {
430413
})
431414
}
432415

433-
async fn delete(&self, location: &Path) -> object_store::Result<()> {
434-
let decoded_location = percent_decode_path(location.as_ref());
435-
self.inner
436-
.delete(&decoded_location)
437-
.into_send()
438-
.await
439-
.map_err(|err| format_object_store_error(err, location.as_ref()))?;
440-
441-
Ok(())
416+
fn delete_stream(
417+
&self,
418+
locations: BoxStream<'static, object_store::Result<Path>>,
419+
) -> BoxStream<'static, object_store::Result<Path>> {
420+
// TODO: use batch delete to optimize performance
421+
let client = self.inner.clone();
422+
locations
423+
.then(move |location| {
424+
let client = client.clone();
425+
async move {
426+
let location = location?;
427+
let decoded_location = percent_decode_path(location.as_ref());
428+
client
429+
.delete(&decoded_location)
430+
.into_send()
431+
.await
432+
.map_err(|err| format_object_store_error(err, location.as_ref()))?;
433+
Ok(location)
434+
}
435+
})
436+
.boxed()
442437
}
443438

444439
fn list(&self, prefix: Option<&Path>) -> BoxStream<'static, object_store::Result<ObjectMeta>> {
@@ -576,11 +571,23 @@ impl ObjectStore for OpendalStore {
576571
})
577572
}
578573

579-
async fn copy(&self, from: &Path, to: &Path) -> object_store::Result<()> {
580-
self.copy_request(from, to, false).await
574+
async fn copy_opts(
575+
&self,
576+
from: &Path,
577+
to: &Path,
578+
options: object_store::CopyOptions,
579+
) -> object_store::Result<()> {
580+
let if_not_exists = matches!(options.mode, object_store::CopyMode::Create);
581+
self.copy_request(from, to, if_not_exists).await
581582
}
582583

583-
async fn rename(&self, from: &Path, to: &Path) -> object_store::Result<()> {
584+
async fn rename_opts(
585+
&self,
586+
from: &Path,
587+
to: &Path,
588+
// TODO: if we need to support rename options in the future
589+
_options: RenameOptions,
590+
) -> object_store::Result<()> {
584591
self.inner
585592
.rename(
586593
&percent_decode_path(from.as_ref()),
@@ -592,10 +599,6 @@ impl ObjectStore for OpendalStore {
592599

593600
Ok(())
594601
}
595-
596-
async fn copy_if_not_exists(&self, from: &Path, to: &Path) -> object_store::Result<()> {
597-
self.copy_request(from, to, true).await
598-
}
599602
}
600603

601604
/// `MultipartUpload`'s impl based on `Writer` in opendal
@@ -691,7 +694,7 @@ impl Debug for OpendalMultipartUpload {
691694
mod tests {
692695
use bytes::Bytes;
693696
use object_store::path::Path;
694-
use object_store::{ObjectStore, WriteMultipart};
697+
use object_store::{ObjectStore, ObjectStoreExt, WriteMultipart};
695698
use opendal::services;
696699
use rand::prelude::*;
697700
use std::sync::Arc;

integrations/object_store/tests/behavior/delete.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use crate::utils::build_trail;
1919
use bytes::Bytes;
2020
use libtest_mimic::Trial;
21-
use object_store::ObjectStore;
21+
use object_store::ObjectStoreExt;
2222
use object_store::path::Path;
2323
use object_store_opendal::OpendalStore;
2424

integrations/object_store/tests/behavior/get.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::utils::{build_trail, new_file_path};
1919
use anyhow::Result;
2020
use bytes::Bytes;
2121
use libtest_mimic::Trial;
22-
use object_store::{GetOptions, GetRange, ObjectStore};
22+
use object_store::{GetOptions, GetRange, ObjectStore, ObjectStoreExt};
2323
use object_store_opendal::OpendalStore;
2424

2525
pub fn tests(store: &OpendalStore, tests: &mut Vec<Trial>) {

integrations/object_store/tests/behavior/put.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::utils::{build_trail, new_file_path};
1919
use anyhow::Result;
2020
use bytes::Bytes;
2121
use libtest_mimic::Trial;
22-
use object_store::{ObjectStore, PutMode, UpdateVersion};
22+
use object_store::{ObjectStore, ObjectStoreExt, PutMode, UpdateVersion};
2323
use object_store_opendal::OpendalStore;
2424

2525
pub fn tests(store: &OpendalStore, tests: &mut Vec<Trial>) {

0 commit comments

Comments
 (0)