Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
refactor: reduce s3 new cost (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
lanlou1554 authored Apr 28, 2024
1 parent dfd706d commit 8254720
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions storage-node/src/storage_reader/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,12 @@ pub struct S3ReaderStream {
impl S3ReaderStream {
pub fn new(client: Client, bucket: String, keys: Vec<String>) -> Self {
assert!(!keys.is_empty(), "keys should not be empty");
let fut = client
.get_object()
.bucket(&bucket)
.key(&keys[0])
.send()
.boxed();
Self {
client,
bucket,
keys,
current_key: 0,
object_fut: Some(fut),
object_fut: None,
object_body: None,
}
}
Expand Down Expand Up @@ -123,12 +117,11 @@ impl Stream for S3ReaderStream {
},
Poll::Pending => Poll::Pending,
}
} else if self.current_key + 1 >= self.keys.len() {
} else if self.current_key >= self.keys.len() {
// No more data to read in S3.
Poll::Ready(None)
} else {
// There are more files to read in S3. Fetch the next object.
self.current_key += 1;
let fut = self
.client
.get_object()
Expand All @@ -137,6 +130,7 @@ impl Stream for S3ReaderStream {
.send()
.boxed();
self.object_fut = Some(fut);
self.current_key += 1;
self.poll_next(cx)
}
}
Expand Down

0 comments on commit 8254720

Please sign in to comment.