Skip to content

Implement deleteSourceObjects for Compose Operation#12873

Draft
nidhiii-27 wants to merge 1 commit intomainfrom
feat/deleteSourceObjects-compose-10602500430278326901
Draft

Implement deleteSourceObjects for Compose Operation#12873
nidhiii-27 wants to merge 1 commit intomainfrom
feat/deleteSourceObjects-compose-10602500430278326901

Conversation

@nidhiii-27
Copy link
Copy Markdown
Contributor

Implemented the deleteSourceObjects feature for the compose operation in the Google Cloud Storage Java client.

Changes:

  1. Storage.java: Added deleteSourceObjects field to ComposeRequest and its Builder.
  2. StorageRpc.java: Added DELETE_SOURCE_OBJECTS option.
  3. StorageImpl.java: Updated compose to propagate the new option.
  4. GrpcStorageImpl.java: Mapped the option to the gRPC ComposeObjectRequest proto.
  5. HttpStorageRpc.java: Mapped the option to the JSON ComposeRequest model.
  6. StorageImplMockitoTest.java: Added unit test for option propagation.
  7. ITObjectTest.java: Added integration test for the full feature workflow.

PR created automatically by Jules for task 10602500430278326901 started by @nidhiii-27

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>
@google-labs-jules
Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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;
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.

high

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.

Comment on lines +654 to +657
Map<StorageRpc.Option, Object> targetOptions = Maps.newHashMap(targetOpts.getRpcOptions());
if (composeRequest.isDeleteSourceObjects()) {
targetOptions.put(StorageRpc.Option.DELETE_SOURCE_OBJECTS, true);
}
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.

medium

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.

Suggested change
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;
}

Comment on lines +820 to +822
if (Option.DELETE_SOURCE_OBJECTS.getBoolean(targetOptions) != null) {
request.setDeleteSourceObjects(Option.DELETE_SOURCE_OBJECTS.getBoolean(targetOptions));
}
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.

medium

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.

Suggested change
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);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant