Implement deleteSourceObjects for Compose Operation#12873
Implement deleteSourceObjects for Compose Operation#12873nidhiii-27 wants to merge 1 commit intomainfrom
Conversation
Added deleteSourceObjects to Storage.ComposeRequest and Builder. Updated StorageImpl, GrpcStorageImpl and HttpStorageRpc to support the flag. Added unit test in StorageImplMockitoTest and integration test in ITObjectTest. Co-authored-by: nidhiii-27 <224584462+nidhiii-27@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Code Review
This pull request introduces a deleteSourceObjects flag to the ComposeRequest in Google Cloud Storage, enabling automatic deletion of source blobs after a successful compose operation. The changes update the gRPC and HTTP storage implementations and add corresponding unit and integration tests. Review feedback recommends including the new field in the ComposeRequest boilerplate methods and optimizing the RPC options map logic to improve performance and code clarity.
| private final List<SourceBlob> sourceBlobs; | ||
| private final BlobInfo target; | ||
| private final List<BlobTargetOption> targetOptions; | ||
| private final boolean deleteSourceObjects; |
There was a problem hiding this comment.
The new field deleteSourceObjects should be included in the equals(), hashCode(), and toString() methods of the ComposeRequest class, as well as in the Builder(ComposeRequest) copy constructor. This ensures that the field is correctly handled during object comparison, hashing, and when creating a builder from an existing request.
| Map<StorageRpc.Option, Object> targetOptions = Maps.newHashMap(targetOpts.getRpcOptions()); | ||
| if (composeRequest.isDeleteSourceObjects()) { | ||
| targetOptions.put(StorageRpc.Option.DELETE_SOURCE_OBJECTS, true); | ||
| } |
There was a problem hiding this comment.
A new HashMap is created and populated even when deleteSourceObjects is false. It is more efficient to only create the mutable copy when the option actually needs to be added.
| Map<StorageRpc.Option, Object> targetOptions = Maps.newHashMap(targetOpts.getRpcOptions()); | |
| if (composeRequest.isDeleteSourceObjects()) { | |
| targetOptions.put(StorageRpc.Option.DELETE_SOURCE_OBJECTS, true); | |
| } | |
| Map<StorageRpc.Option, ?> targetOptions = targetOpts.getRpcOptions(); | |
| if (composeRequest.isDeleteSourceObjects()) { | |
| Map<StorageRpc.Option, Object> mutableOptions = Maps.newHashMap(targetOptions); | |
| mutableOptions.put(StorageRpc.Option.DELETE_SOURCE_OBJECTS, true); | |
| targetOptions = mutableOptions; | |
| } |
| if (Option.DELETE_SOURCE_OBJECTS.getBoolean(targetOptions) != null) { | ||
| request.setDeleteSourceObjects(Option.DELETE_SOURCE_OBJECTS.getBoolean(targetOptions)); | ||
| } |
There was a problem hiding this comment.
The DELETE_SOURCE_OBJECTS option is looked up twice in the map. It is better to store the result in a local variable to improve readability and performance.
| if (Option.DELETE_SOURCE_OBJECTS.getBoolean(targetOptions) != null) { | |
| request.setDeleteSourceObjects(Option.DELETE_SOURCE_OBJECTS.getBoolean(targetOptions)); | |
| } | |
| Boolean deleteSourceObjects = Option.DELETE_SOURCE_OBJECTS.getBoolean(targetOptions); | |
| if (deleteSourceObjects != null) { | |
| request.setDeleteSourceObjects(deleteSourceObjects); | |
| } |
Implemented the
deleteSourceObjectsfeature for thecomposeoperation in the Google Cloud Storage Java client.Changes:
deleteSourceObjectsfield toComposeRequestand itsBuilder.DELETE_SOURCE_OBJECTSoption.composeto propagate the new option.ComposeObjectRequestproto.ComposeRequestmodel.PR created automatically by Jules for task 10602500430278326901 started by @nidhiii-27