Skip to content

Commit

Permalink
Stub out ObjectStore::list_with_offset (apache#3970)
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Mar 28, 2023
1 parent b05522f commit d54f642
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion object_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ use crate::util::{coalesce_ranges, collect_bytes, OBJECT_STORE_COALESCE_DEFAULT}
use async_trait::async_trait;
use bytes::Bytes;
use chrono::{DateTime, Utc};
use futures::{stream::BoxStream, StreamExt};
use futures::{stream::BoxStream, StreamExt, TryStreamExt};
use snafu::Snafu;
use std::fmt::{Debug, Formatter};
#[cfg(not(target_arch = "wasm32"))]
Expand Down Expand Up @@ -371,11 +371,32 @@ pub trait ObjectStore: std::fmt::Display + Send + Sync + Debug + 'static {
///
/// Prefixes are evaluated on a path segment basis, i.e. `foo/bar/` is a prefix of `foo/bar/x` but not of
/// `foo/bar_baz/x`.
///
/// Note: the order of returned [`ObjectMeta`] is not guaranteed
async fn list(
&self,
prefix: Option<&Path>,
) -> Result<BoxStream<'_, Result<ObjectMeta>>>;

/// List all the objects with the given prefix and a location greater than `offset`
///
/// Some stores, such as S3 and GCS, may be able to push `offset` down to reduce
/// the number of network requests required
///
/// Note: the order of returned [`ObjectMeta`] is not guaranteed
async fn list_with_offset<'a>(
&'a self,
prefix: Option<&'a Path>,
offset: &'a Path,
) -> Result<BoxStream<'a, Result<ObjectMeta>>> {
let stream = self
.list(prefix)
.await?
.try_filter(|f| futures::future::ready(&f.location > offset))
.boxed();
Ok(stream)
}

/// List objects with the given prefix and an implementation specific
/// delimiter. Returns common prefixes (directories) in addition to object
/// metadata.
Expand Down

0 comments on commit d54f642

Please sign in to comment.