docs(storage): add sample for storage_open_multiple_objects_ranged_read#4816
Conversation
d0267d5 to
1d95dcb
Compare
src/storage/examples/src/objects/open_multiple_objects_ranged_read.rs
Outdated
Show resolved
Hide resolved
src/storage/examples/src/objects/open_multiple_objects_ranged_read.rs
Outdated
Show resolved
Hide resolved
d40b654 to
1d04e38
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4816 +/- ##
=======================================
Coverage 94.97% 94.97%
=======================================
Files 205 205
Lines 8094 8094
=======================================
Hits 7687 7687
Misses 407 407 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@coryan I've pushed an update addressing your feedback. The sample now:
Thank you! |
| async fn read_footer( | ||
| client: &Storage, | ||
| bucket_name: &str, | ||
| object_name: &str, | ||
| ) -> anyhow::Result<(ObjectDescriptor, Vec<u8>, String)> { | ||
| // Reading the last 8 bytes is common in Parquet and other column-oriented formats | ||
| // with a footer. | ||
| let (descriptor, mut reader) = client | ||
| .open_object(bucket_name, object_name) | ||
| .send_and_read(ReadRange::tail(8)) | ||
| .await?; | ||
|
|
||
| let mut footer = Vec::new(); | ||
| while let Some(data) = reader.next().await.transpose()? { | ||
| footer.extend_from_slice(&data); | ||
| } | ||
| Ok((descriptor, footer, object_name.to_string())) | ||
| } |
There was a problem hiding this comment.
You could move this outside (or below) the body of the sample() function. Frankly, I am not sure what is best here, you folks will need to develop a style for the samples. Looks good enough as-is.
There was a problem hiding this comment.
Thanks, Carlos.
I considered moving this out and same like you - I'm not sure whether it's better to move it out or keep it as an inner function in the context of a sample. My thought is to keep a highly specific, single-use helper function to where it is used and not expose it to the module level. At least for now.
+1 on developing a style and standard for the samples.
FYI @joshuatants
There was a problem hiding this comment.
Ack, let's discuss this further.
LGTM.
Co-authored-by: Carlos O'Ryan <coryan@google.com>
6dc1208 to
63c04a6
Compare
Add one of the samples requested in #4595.