Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add java-storage implementation for copy objects method. #1087

Conversation

shilpi23pandey
Copy link
Contributor

@shilpi23pandey shilpi23pandey commented Dec 19, 2023

java-storage client internally uses gcs rewrite API for copy so we don't need the logic to decide weather to issue a copy or rewrite as opposed to the APIary implementation. https://cloud.google.com/java/docs/reference/google-cloud-storage/latest/com.google.cloud.storage.Storage#com_google_cloud_storage_Storage_copy_com_google_cloud_storage_Storage_CopyRequest_

@shilpi23pandey shilpi23pandey marked this pull request as draft December 19, 2023 11:58
@shilpi23pandey
Copy link
Contributor Author

/gcbrun

@shilpi23pandey
Copy link
Contributor Author

/gcbrun

@shilpi23pandey shilpi23pandey marked this pull request as ready for review December 19, 2023 14:02
CopyWriter copyWriter = storage.copy(copyRequestBuilder.build());
while (!copyWriter.isDone()) {
copyWriter.copyChunk();
logger.atFiner().log(
Copy link
Contributor

Choose a reason for hiding this comment

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

let us make this finest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

if (storageOptions.getMaxRewriteChunkSize() > 0) {
copyRequestBuilder.setMegabytesCopiedPerChunk(
// Convert raw byte size into Mib.
storageOptions.getMaxRewriteChunkSize() / (1024 * 1024));
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is less than 1MB, it will be 0? Is that ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do have checks which enforces that getMaxRewriteChunkSize should be multiple of MiB so I don't think it will ever be zero.

sourceToDestinationObjectsMap.entrySet()) {
StorageResourceId srcObject = entry.getKey();
StorageResourceId dstObject = entry.getValue();
copyInternal(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we not use Rewrite if copyWithRewrite config is enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Veneer does not expose separate methods for rewrite and copy, it internally always uses rewrite and decides number of calls based on the object size. The APIary copy also uses rewrite API but with a single RPC call https://cloud.google.com/storage/docs/json_api/v1/objects/copy

@shilpi23pandey
Copy link
Contributor Author

/gcbrun

@shilpi23pandey shilpi23pandey merged commit c208df4 into GoogleCloudDataproc:master Dec 20, 2023
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants