Skip to content

Commit

Permalink
refactor: Polish the implement of Query Based Metadata Cache (#1400)
Browse files Browse the repository at this point in the history
* refactor: Remove unneeded mut requirement

Signed-off-by: Xuanwo <[email protected]>

* Remove

Signed-off-by: Xuanwo <[email protected]>

* Don't fresh metadata every time

Signed-off-by: Xuanwo <[email protected]>

* Remov not needed mut

Signed-off-by: Xuanwo <[email protected]>

* Make everyone happy

Signed-off-by: Xuanwo <[email protected]>

* Rename to metakey

Signed-off-by: Xuanwo <[email protected]>

---------

Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo authored Feb 22, 2023
1 parent 50b0769 commit 0df39ca
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 128 deletions.
2 changes: 1 addition & 1 deletion binaries/oay/src/services/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl Service {
}

async fn put(&self, req: HttpRequest, mut body: web::Payload) -> Result<HttpResponse> {
let mut o = self
let o = self
.op
.object(&percent_decode(req.path().as_bytes()).decode_utf8_lossy());

Expand Down
2 changes: 1 addition & 1 deletion binaries/oli/src/commands/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub async fn main(args: Option<ArgMatches>) -> Result<()> {
.get_one::<String>("destination")
.ok_or_else(|| anyhow!("missing target"))?;
let (dst_op, dst_path) = parse_location(dst)?;
let mut dst_o = dst_op.object(dst_path);
let dst_o = dst_op.object(dst_path);

let size = src_o.stat().await?.content_length();
let reader = src_o.reader().await?;
Expand Down
4 changes: 2 additions & 2 deletions bindings/object_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl std::fmt::Display for OpendalStore {
#[async_trait]
impl ObjectStore for OpendalStore {
async fn put(&self, location: &Path, bytes: Bytes) -> Result<()> {
let mut o = self.inner.object(location.as_ref());
let o = self.inner.object(location.as_ref());
Ok(o.write(bytes)
.await
.map_err(|err| format_object_store_error(err, location.as_ref()))?)
Expand Down Expand Up @@ -127,7 +127,7 @@ impl ObjectStore for OpendalStore {
}

async fn delete(&self, location: &Path) -> Result<()> {
let mut o = self.inner.object(location.as_ref());
let o = self.inner.object(location.as_ref());
o.delete()
.await
.map_err(|err| format_object_store_error(err, location.as_ref()))?;
Expand Down
4 changes: 2 additions & 2 deletions src/layers/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl<A: Accessor> LayeredAccessor for CompleteReaderAccessor<A> {
self.inner.stat(path, args).await.map(|v| {
v.map_metadata(|m| {
let bit = m.bit();
m.with_bit(bit | ObjectMetadataKey::Complete)
m.with_bit(bit | ObjectMetakey::Complete)
})
})
}
Expand All @@ -304,7 +304,7 @@ impl<A: Accessor> LayeredAccessor for CompleteReaderAccessor<A> {
self.inner.blocking_stat(path, args).map(|v| {
v.map_metadata(|m| {
let bit = m.bit();
m.with_bit(bit | ObjectMetadataKey::Complete)
m.with_bit(bit | ObjectMetakey::Complete)
})
})
}
Expand Down
20 changes: 10 additions & 10 deletions src/layers/immutable_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ mod tests {
let mut map = HashMap::new();
let mut set = HashSet::new();
let mut ds = op.object("").list().await?;
while let Some(mut entry) = ds.try_next().await? {
while let Some(entry) = ds.try_next().await? {
debug!("got entry: {}", entry.path());
assert!(
set.insert(entry.path().to_string()),
Expand All @@ -298,7 +298,7 @@ mod tests {
);
map.insert(
entry.path().to_string(),
entry.metadata(ObjectMetadataKey::Mode).await?.mode(),
entry.metadata(ObjectMetakey::Mode).await?.mode(),
);
}

Expand Down Expand Up @@ -327,7 +327,7 @@ mod tests {
let mut ds = op.object("/").scan().await?;
let mut set = HashSet::new();
let mut map = HashMap::new();
while let Some(mut entry) = ds.try_next().await? {
while let Some(entry) = ds.try_next().await? {
debug!("got entry: {}", entry.path());
assert!(
set.insert(entry.path().to_string()),
Expand All @@ -336,7 +336,7 @@ mod tests {
);
map.insert(
entry.path().to_string(),
entry.metadata(ObjectMetadataKey::Mode).await?.mode(),
entry.metadata(ObjectMetakey::Mode).await?.mode(),
);
}

Expand Down Expand Up @@ -372,15 +372,15 @@ mod tests {
let mut map = HashMap::new();
let mut set = HashSet::new();
let mut ds = op.object("/").list().await?;
while let Some(mut entry) = ds.try_next().await? {
while let Some(entry) = ds.try_next().await? {
assert!(
set.insert(entry.path().to_string()),
"duplicated value: {}",
entry.path()
);
map.insert(
entry.path().to_string(),
entry.metadata(ObjectMetadataKey::Mode).await?.mode(),
entry.metadata(ObjectMetakey::Mode).await?.mode(),
);
}

Expand All @@ -391,15 +391,15 @@ mod tests {
let mut map = HashMap::new();
let mut set = HashSet::new();
let mut ds = op.object("dataset/stateful/").list().await?;
while let Some(mut entry) = ds.try_next().await? {
while let Some(entry) = ds.try_next().await? {
assert!(
set.insert(entry.path().to_string()),
"duplicated value: {}",
entry.path()
);
map.insert(
entry.path().to_string(),
entry.metadata(ObjectMetadataKey::Mode).await?.mode(),
entry.metadata(ObjectMetakey::Mode).await?.mode(),
);
}

Expand Down Expand Up @@ -442,15 +442,15 @@ mod tests {

let mut map = HashMap::new();
let mut set = HashSet::new();
while let Some(mut entry) = ds.try_next().await? {
while let Some(entry) = ds.try_next().await? {
assert!(
set.insert(entry.path().to_string()),
"duplicated value: {}",
entry.path()
);
map.insert(
entry.path().to_string(),
entry.metadata(ObjectMetadataKey::Mode).await?.mode(),
entry.metadata(ObjectMetakey::Mode).await?.mode(),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ mod object;
pub use object::Object;
pub use object::ObjectLister;
pub use object::ObjectMetadata;
pub use object::ObjectMetadataKey;
pub use object::ObjectMetakey;
pub use object::ObjectMode;
pub use object::ObjectMultipart;
pub use object::ObjectPart;
Expand Down
Loading

1 comment on commit 0df39ca

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for opendal ready!

✅ Preview
https://opendal-6nh2p0z8b-databend.vercel.app

Built with commit 0df39ca.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.