feat(core): Add GoogleCloudStorageOutputStream to the core module and integrate with GcsWriteChannel#291
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #291 +/- ##
============================================
+ Coverage 97.69% 97.87% +0.18%
- Complexity 486 502 +16
============================================
Files 35 36 +1
Lines 1561 1601 +40
Branches 140 144 +4
============================================
+ Hits 1525 1567 +42
+ Misses 17 16 -1
+ Partials 19 18 -1
🚀 New features to boost your workflow:
|
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new GoogleCloudStorageOutputStream to the core module, enabling a standard Java OutputStream interface for writing data to Google Cloud Storage. It integrates with the existing GcsWriteChannel and provides robust exception handling through a new utility class, ensuring consistent error reporting across the library. These changes facilitate easier integration with data processing frameworks that rely on standard Java I/O streams. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces unified writing capabilities to Google Cloud Storage (GCS) by adding GcsWriteOptions, GcsWriteChannel, and GoogleCloudStorageOutputStream to support various upload strategies (such as parallel composite upload and journaling) and proper exception translation. The review feedback highlights two critical improvements: first, ensuring that GoogleCloudStorageOutputStream.write loops until the buffer is fully written to prevent data loss from partial writes; second, delaying setting the closed flag in GcsWriteChannel.close() until after successful execution to allow safe retries upon transient failures or interruptions.
fba5246 to
ad1c93a
Compare
# Conflicts: # client/src/main/java/com/google/cloud/gcs/analyticscore/client/GcsClientImpl.java # client/src/test/java/com/google/cloud/gcs/analyticscore/client/GcsClientImplTest.java
8e0c87b to
83bc9c1
Compare
c363936 to
25e75e7
Compare
# Conflicts: # client/src/main/java/com/google/cloud/gcs/analyticscore/client/ConfigurationUtil.java # client/src/main/java/com/google/cloud/gcs/analyticscore/client/GcsClientImpl.java # client/src/main/java/com/google/cloud/gcs/analyticscore/client/GcsClientOptions.java # client/src/main/java/com/google/cloud/gcs/analyticscore/client/GcsExceptionUtil.java # client/src/main/java/com/google/cloud/gcs/analyticscore/client/GcsWriteOptions.java # core/src/integrationTest/java/com/google/cloud/gcs/analyticscore/core/TestInputStreamInputFile.java
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces GoogleCloudStorageOutputStream, a unified output stream that wraps a WritableByteChannel to provide standard java.io.OutputStream semantics for writing objects to Google Cloud Storage, along with its corresponding unit tests. The review feedback suggests several improvements: replacing the channel.isOpen() check in close() with a direct call to channel.close() to ensure proper upload finalization, and using Preconditions.checkNotNull instead of checkState for validating method arguments. Additionally, the unit tests should be updated to align with these changes by verifying idempotent close behavior and asserting NullPointerException instead of IllegalStateException.
Type of Change
feat: A new featurefix: A bug fixdocs: Documentation only changesstyle: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)refactor: A code change that neither fixes a bug nor adds a featureperf: A code change that improves performancetest: Adding missing tests or correcting existing testschore: Changes to the build process or auxiliary tools and libraries such as documentation generationDescription
What?
GoogleCloudStorageOutputStreamto enable writing to GCS viaGcsWriteChannel.Why?
OutputStreamwrite path that complements the library's existing optimized read path (GoogleCloudStorageInputStream).Checklist
feat(core): Add GoogleCloudStorageOutputStream with tests)Generated/Assisted by Agent? [Yes]