Skip to content

docs(storage): add sample for storage_open_multiple_objects_ranged_read#4816

Merged
vsharonlynn merged 4 commits intogoogleapis:mainfrom
vsharonlynn:docs/storage_open_multiple_objects_ranged_read
Feb 27, 2026
Merged

docs(storage): add sample for storage_open_multiple_objects_ranged_read#4816
vsharonlynn merged 4 commits intogoogleapis:mainfrom
vsharonlynn:docs/storage_open_multiple_objects_ranged_read

Conversation

@vsharonlynn
Copy link
Copy Markdown
Contributor

Add one of the samples requested in #4595.

@product-auto-label product-auto-label bot added api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples. labels Feb 25, 2026
@vsharonlynn vsharonlynn force-pushed the docs/storage_open_multiple_objects_ranged_read branch 2 times, most recently from d0267d5 to 1d95dcb Compare February 25, 2026 13:33
@vsharonlynn vsharonlynn force-pushed the docs/storage_open_multiple_objects_ranged_read branch from d40b654 to 1d04e38 Compare February 26, 2026 02:38
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.97%. Comparing base (58f2e41) to head (63c04a6).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vsharonlynn
Copy link
Copy Markdown
Contributor Author

@coryan I've pushed an update addressing your feedback. The sample now:

  • Reads the last 8 bytes (simulating a Parquet footer)
  • Handles the data as raw bytes
  • Stores the ObjectDescriptors in a HashMap to demonstrate caching them for future reads
  • Has an code comment to explain the descriptor map

Thank you!

@vsharonlynn vsharonlynn marked this pull request as ready for review February 26, 2026 05:29
@vsharonlynn vsharonlynn requested a review from a team as a code owner February 26, 2026 05:29
Comment on lines +25 to +42
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()))
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ack, let's discuss this further.

LGTM.

@vsharonlynn vsharonlynn force-pushed the docs/storage_open_multiple_objects_ranged_read branch from 6dc1208 to 63c04a6 Compare February 27, 2026 04:21
@vsharonlynn vsharonlynn merged commit f965dba into googleapis:main Feb 27, 2026
35 checks passed
@vsharonlynn vsharonlynn deleted the docs/storage_open_multiple_objects_ranged_read branch February 27, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants